xref: /haiku/src/kits/game/StreamingGameSound.cpp (revision e7be020ce59cd8a50dcb9a782b3b15cfa769396c)
1 //------------------------------------------------------------------------------
2 //	Copyright (c) 2001-2002, OpenBeOS
3 //
4 //	Permission is hereby granted, free of charge, to any person obtaining a
5 //	copy of this software and associated documentation files (the "Software"),
6 //	to deal in the Software without restriction, including without limitation
7 //	the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 //	and/or sell copies of the Software, and to permit persons to whom the
9 //	Software is furnished to do so, subject to the following conditions:
10 //
11 //	The above copyright notice and this permission notice shall be included in
12 //	all copies or substantial portions of the Software.
13 //
14 //	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 //	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 //	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 //	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 //	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 //	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 //	DEALINGS IN THE SOFTWARE.
21 //
22 //	File Name:		StreamingGameSound.cpp
23 //	Author:			Christopher ML Zumwalt May (zummy@users.sf.net)
24 //	Description:	BStreamingGameSound is a class for all kinds of streaming
25 //					(data not known beforehand) game sounds.
26 //------------------------------------------------------------------------------
27 
28 #include "GameSoundDevice.h"
29 #include "StreamingGameSound.h"
30 
31 
32 BStreamingGameSound::BStreamingGameSound(size_t inBufferFrameCount,
33 										 const gs_audio_format *format,
34 										 size_t inBufferCount,
35 										 BGameSoundDevice *device)
36  	:	BGameSound(device),
37  		fStreamHook(NULL),
38  		fStreamCookie(NULL)
39 {
40 	if (InitCheck() == B_OK) {
41 		status_t error = SetParameters(inBufferFrameCount, format, inBufferCount);
42 		SetInitError(error);
43 	}
44 }
45 
46 
47 BStreamingGameSound::BStreamingGameSound(BGameSoundDevice *device)
48  	:	BGameSound(device),
49  		fStreamHook(NULL),
50  		fStreamCookie(NULL)
51 {
52 }
53 
54 
55 BStreamingGameSound::~BStreamingGameSound()
56 {
57 }
58 
59 
60 BGameSound *
61 BStreamingGameSound::Clone() const
62 {
63 	return NULL;
64 }
65 
66 
67 status_t
68 BStreamingGameSound::SetStreamHook(void (*hook)(void * inCookie, void * inBuffer, size_t inByteCount, BStreamingGameSound * me),
69 								   void * cookie)
70 {
71 	fStreamHook = hook;
72 	fStreamCookie = cookie;
73 
74 	return B_OK;
75 }
76 
77 
78 void
79 BStreamingGameSound::FillBuffer(void *inBuffer,
80 								size_t inByteCount)
81 {
82 	if (fStreamHook)
83 		(fStreamHook)(fStreamCookie, inBuffer, inByteCount, this);
84 }
85 
86 
87 status_t
88 BStreamingGameSound::Perform(int32 selector,
89 							 void *data)
90 {
91 	return B_ERROR;
92 }
93 
94 
95 status_t
96 BStreamingGameSound::SetAttributes(gs_attribute * inAttributes,
97 									size_t inAttributeCount)
98 {
99 	return BGameSound::SetAttributes(inAttributes, inAttributeCount);
100 }
101 
102 
103 status_t
104 BStreamingGameSound::SetParameters(size_t inBufferFrameCount,
105 						  const gs_audio_format *format,
106 						  size_t inBufferCount)
107 {
108 	gs_id sound;
109 	status_t error = Device()->CreateBuffer(&sound, this, format,
110 		inBufferFrameCount, inBufferCount);
111 	if (error != B_OK) return error;
112 
113 	return BGameSound::Init(sound);
114 }
115 
116 
117 bool
118 BStreamingGameSound::Lock()
119 {
120 	return fLock.Lock();
121 }
122 
123 
124 void
125 BStreamingGameSound::Unlock()
126 {
127 	fLock.Unlock();
128 }
129 
130 
131 /* unimplemented for protection of the user:
132  *
133  * BStreamingGameSound::BStreamingGameSound()
134  * BStreamingGameSound::BStreamingGameSound(const BStreamingGameSound &)
135  * BStreamingGameSound &BStreamingGameSound::operator=(const BStreamingGameSound &)
136  */
137 
138 
139 status_t
140 BStreamingGameSound::_Reserved_BStreamingGameSound_0(int32 arg, ...)
141 {
142 	return B_ERROR;
143 }
144 
145 
146 status_t
147 BStreamingGameSound::_Reserved_BStreamingGameSound_1(int32 arg, ...)
148 {
149 	return B_ERROR;
150 }
151 
152 
153 status_t
154 BStreamingGameSound::_Reserved_BStreamingGameSound_2(int32 arg, ...)
155 {
156 	return B_ERROR;
157 }
158 
159 
160 status_t
161 BStreamingGameSound::_Reserved_BStreamingGameSound_3(int32 arg, ...)
162 {
163 	return B_ERROR;
164 }
165 
166 
167 status_t
168 BStreamingGameSound::_Reserved_BStreamingGameSound_4(int32 arg, ...)
169 {
170 	return B_ERROR;
171 }
172 
173 
174 status_t
175 BStreamingGameSound::_Reserved_BStreamingGameSound_5(int32 arg, ...)
176 {
177 	return B_ERROR;
178 }
179 
180 
181 status_t
182 BStreamingGameSound::_Reserved_BStreamingGameSound_6(int32 arg, ...)
183 {
184 	return B_ERROR;
185 }
186 
187 
188 status_t
189 BStreamingGameSound::_Reserved_BStreamingGameSound_7(int32 arg, ...)
190 {
191 	return B_ERROR;
192 }
193 
194 
195 status_t
196 BStreamingGameSound::_Reserved_BStreamingGameSound_8(int32 arg, ...)
197 {
198 	return B_ERROR;
199 }
200 
201 
202 status_t
203 BStreamingGameSound::_Reserved_BStreamingGameSound_9(int32 arg, ...)
204 {
205 	return B_ERROR;
206 }
207 
208 
209 status_t
210 BStreamingGameSound::_Reserved_BStreamingGameSound_10(int32 arg, ...)
211 {
212 	return B_ERROR;
213 }
214 
215 
216 status_t
217 BStreamingGameSound::_Reserved_BStreamingGameSound_11(int32 arg, ...)
218 {
219 	return B_ERROR;
220 }
221 
222 
223 status_t
224 BStreamingGameSound::_Reserved_BStreamingGameSound_12(int32 arg, ...)
225 {
226 	return B_ERROR;
227 }
228 
229 
230 status_t
231 BStreamingGameSound::_Reserved_BStreamingGameSound_13(int32 arg, ...)
232 {
233 	return B_ERROR;
234 }
235 
236 
237 status_t
238 BStreamingGameSound::_Reserved_BStreamingGameSound_14(int32 arg, ...)
239 {
240 	return B_ERROR;
241 }
242 
243 
244 status_t
245 BStreamingGameSound::_Reserved_BStreamingGameSound_15(int32 arg, ...)
246 {
247 	return B_ERROR;
248 }
249 
250 
251 status_t
252 BStreamingGameSound::_Reserved_BStreamingGameSound_16(int32 arg, ...)
253 {
254 	return B_ERROR;
255 }
256 
257 
258 status_t
259 BStreamingGameSound::_Reserved_BStreamingGameSound_17(int32 arg, ...)
260 {
261 	return B_ERROR;
262 }
263 
264 
265 status_t
266 BStreamingGameSound::_Reserved_BStreamingGameSound_18(int32 arg, ...)
267 {
268 	return B_ERROR;
269 }
270 
271 
272 status_t
273 BStreamingGameSound::_Reserved_BStreamingGameSound_19(int32 arg, ...)
274 {
275 	return B_ERROR;
276 }
277 
278 
279 status_t
280 BStreamingGameSound::_Reserved_BStreamingGameSound_20(int32 arg, ...)
281 {
282 	return B_ERROR;
283 }
284 
285 
286 status_t
287 BStreamingGameSound::_Reserved_BStreamingGameSound_21(int32 arg, ...)
288 {
289 	return B_ERROR;
290 }
291 
292 
293 status_t
294 BStreamingGameSound::_Reserved_BStreamingGameSound_22(int32 arg, ...)
295 {
296 	return B_ERROR;
297 }
298 
299 
300 status_t
301 BStreamingGameSound::_Reserved_BStreamingGameSound_23(int32 arg, ...)
302 {
303 	return B_ERROR;
304 }
305 
306 
307