xref: /haiku/src/kits/game/StreamingGameSound.cpp (revision b028e77473189065f2baefc6f5e10d451cf591e2)
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 	if (error != B_OK) return error;
111 
112 	return BGameSound::Init(sound);
113 }
114 
115 
116 bool
117 BStreamingGameSound::Lock()
118 {
119 	return fLock.Lock();
120 }
121 
122 
123 void
124 BStreamingGameSound::Unlock()
125 {
126 	fLock.Unlock();
127 }
128 
129 
130 /* unimplemented for protection of the user:
131  *
132  * BStreamingGameSound::BStreamingGameSound()
133  * BStreamingGameSound::BStreamingGameSound(const BStreamingGameSound &)
134  * BStreamingGameSound &BStreamingGameSound::operator=(const BStreamingGameSound &)
135  */
136 
137 
138 status_t
139 BStreamingGameSound::_Reserved_BStreamingGameSound_0(int32 arg, ...)
140 {
141 	return B_ERROR;
142 }
143 
144 
145 status_t
146 BStreamingGameSound::_Reserved_BStreamingGameSound_1(int32 arg, ...)
147 {
148 	return B_ERROR;
149 }
150 
151 
152 status_t
153 BStreamingGameSound::_Reserved_BStreamingGameSound_2(int32 arg, ...)
154 {
155 	return B_ERROR;
156 }
157 
158 
159 status_t
160 BStreamingGameSound::_Reserved_BStreamingGameSound_3(int32 arg, ...)
161 {
162 	return B_ERROR;
163 }
164 
165 
166 status_t
167 BStreamingGameSound::_Reserved_BStreamingGameSound_4(int32 arg, ...)
168 {
169 	return B_ERROR;
170 }
171 
172 
173 status_t
174 BStreamingGameSound::_Reserved_BStreamingGameSound_5(int32 arg, ...)
175 {
176 	return B_ERROR;
177 }
178 
179 
180 status_t
181 BStreamingGameSound::_Reserved_BStreamingGameSound_6(int32 arg, ...)
182 {
183 	return B_ERROR;
184 }
185 
186 
187 status_t
188 BStreamingGameSound::_Reserved_BStreamingGameSound_7(int32 arg, ...)
189 {
190 	return B_ERROR;
191 }
192 
193 
194 status_t
195 BStreamingGameSound::_Reserved_BStreamingGameSound_8(int32 arg, ...)
196 {
197 	return B_ERROR;
198 }
199 
200 
201 status_t
202 BStreamingGameSound::_Reserved_BStreamingGameSound_9(int32 arg, ...)
203 {
204 	return B_ERROR;
205 }
206 
207 
208 status_t
209 BStreamingGameSound::_Reserved_BStreamingGameSound_10(int32 arg, ...)
210 {
211 	return B_ERROR;
212 }
213 
214 
215 status_t
216 BStreamingGameSound::_Reserved_BStreamingGameSound_11(int32 arg, ...)
217 {
218 	return B_ERROR;
219 }
220 
221 
222 status_t
223 BStreamingGameSound::_Reserved_BStreamingGameSound_12(int32 arg, ...)
224 {
225 	return B_ERROR;
226 }
227 
228 
229 status_t
230 BStreamingGameSound::_Reserved_BStreamingGameSound_13(int32 arg, ...)
231 {
232 	return B_ERROR;
233 }
234 
235 
236 status_t
237 BStreamingGameSound::_Reserved_BStreamingGameSound_14(int32 arg, ...)
238 {
239 	return B_ERROR;
240 }
241 
242 
243 status_t
244 BStreamingGameSound::_Reserved_BStreamingGameSound_15(int32 arg, ...)
245 {
246 	return B_ERROR;
247 }
248 
249 
250 status_t
251 BStreamingGameSound::_Reserved_BStreamingGameSound_16(int32 arg, ...)
252 {
253 	return B_ERROR;
254 }
255 
256 
257 status_t
258 BStreamingGameSound::_Reserved_BStreamingGameSound_17(int32 arg, ...)
259 {
260 	return B_ERROR;
261 }
262 
263 
264 status_t
265 BStreamingGameSound::_Reserved_BStreamingGameSound_18(int32 arg, ...)
266 {
267 	return B_ERROR;
268 }
269 
270 
271 status_t
272 BStreamingGameSound::_Reserved_BStreamingGameSound_19(int32 arg, ...)
273 {
274 	return B_ERROR;
275 }
276 
277 
278 status_t
279 BStreamingGameSound::_Reserved_BStreamingGameSound_20(int32 arg, ...)
280 {
281 	return B_ERROR;
282 }
283 
284 
285 status_t
286 BStreamingGameSound::_Reserved_BStreamingGameSound_21(int32 arg, ...)
287 {
288 	return B_ERROR;
289 }
290 
291 
292 status_t
293 BStreamingGameSound::_Reserved_BStreamingGameSound_22(int32 arg, ...)
294 {
295 	return B_ERROR;
296 }
297 
298 
299 status_t
300 BStreamingGameSound::_Reserved_BStreamingGameSound_23(int32 arg, ...)
301 {
302 	return B_ERROR;
303 }
304 
305 
306