1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2001-2002, Haiku 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 29 #include "StreamingGameSound.h" 30 31 #include "GameSoundDevice.h" 32 33 34 BStreamingGameSound::BStreamingGameSound(size_t inBufferFrameCount, 35 const gs_audio_format *format, size_t inBufferCount, 36 BGameSoundDevice *device) 37 : 38 BGameSound(device), 39 fStreamHook(NULL), 40 fStreamCookie(NULL) 41 { 42 if (InitCheck() == B_OK) { 43 status_t error = SetParameters(inBufferFrameCount, format, 44 inBufferCount); 45 SetInitError(error); 46 } 47 } 48 49 50 BStreamingGameSound::BStreamingGameSound(BGameSoundDevice *device) 51 : 52 BGameSound(device), 53 fStreamHook(NULL), 54 fStreamCookie(NULL) 55 { 56 } 57 58 59 BStreamingGameSound::~BStreamingGameSound() 60 { 61 } 62 63 64 BGameSound * 65 BStreamingGameSound::Clone() const 66 { 67 return NULL; 68 } 69 70 71 status_t 72 BStreamingGameSound::SetStreamHook(void (*hook)(void* inCookie, void* inBuffer, 73 size_t inByteCount, BStreamingGameSound * me), void * cookie) 74 { 75 fStreamHook = hook; 76 fStreamCookie = cookie; 77 78 return B_OK; 79 } 80 81 82 void 83 BStreamingGameSound::FillBuffer(void *inBuffer, 84 size_t inByteCount) 85 { 86 if (fStreamHook) 87 (fStreamHook)(fStreamCookie, inBuffer, inByteCount, this); 88 } 89 90 91 status_t 92 BStreamingGameSound::Perform(int32 selector, void *data) 93 { 94 return B_ERROR; 95 } 96 97 98 status_t 99 BStreamingGameSound::SetAttributes(gs_attribute * inAttributes, 100 size_t inAttributeCount) 101 { 102 return BGameSound::SetAttributes(inAttributes, inAttributeCount); 103 } 104 105 106 status_t 107 BStreamingGameSound::SetParameters(size_t inBufferFrameCount, 108 const gs_audio_format *format, size_t inBufferCount) 109 { 110 gs_id sound; 111 status_t error = Device()->CreateBuffer(&sound, this, format, 112 inBufferFrameCount, inBufferCount); 113 if (error != B_OK) return error; 114 115 return BGameSound::Init(sound); 116 } 117 118 119 bool 120 BStreamingGameSound::Lock() 121 { 122 return fLock.Lock(); 123 } 124 125 126 void 127 BStreamingGameSound::Unlock() 128 { 129 fLock.Unlock(); 130 } 131 132 133 /* unimplemented for protection of the user: 134 * 135 * BStreamingGameSound::BStreamingGameSound() 136 * BStreamingGameSound::BStreamingGameSound(const BStreamingGameSound &) 137 * BStreamingGameSound &BStreamingGameSound::operator=(const BStreamingGameSound &) 138 */ 139 140 141 status_t 142 BStreamingGameSound::_Reserved_BStreamingGameSound_0(int32 arg, ...) 143 { 144 return B_ERROR; 145 } 146 147 148 status_t 149 BStreamingGameSound::_Reserved_BStreamingGameSound_1(int32 arg, ...) 150 { 151 return B_ERROR; 152 } 153 154 155 status_t 156 BStreamingGameSound::_Reserved_BStreamingGameSound_2(int32 arg, ...) 157 { 158 return B_ERROR; 159 } 160 161 162 status_t 163 BStreamingGameSound::_Reserved_BStreamingGameSound_3(int32 arg, ...) 164 { 165 return B_ERROR; 166 } 167 168 169 status_t 170 BStreamingGameSound::_Reserved_BStreamingGameSound_4(int32 arg, ...) 171 { 172 return B_ERROR; 173 } 174 175 176 status_t 177 BStreamingGameSound::_Reserved_BStreamingGameSound_5(int32 arg, ...) 178 { 179 return B_ERROR; 180 } 181 182 183 status_t 184 BStreamingGameSound::_Reserved_BStreamingGameSound_6(int32 arg, ...) 185 { 186 return B_ERROR; 187 } 188 189 190 status_t 191 BStreamingGameSound::_Reserved_BStreamingGameSound_7(int32 arg, ...) 192 { 193 return B_ERROR; 194 } 195 196 197 status_t 198 BStreamingGameSound::_Reserved_BStreamingGameSound_8(int32 arg, ...) 199 { 200 return B_ERROR; 201 } 202 203 204 status_t 205 BStreamingGameSound::_Reserved_BStreamingGameSound_9(int32 arg, ...) 206 { 207 return B_ERROR; 208 } 209 210 211 status_t 212 BStreamingGameSound::_Reserved_BStreamingGameSound_10(int32 arg, ...) 213 { 214 return B_ERROR; 215 } 216 217 218 status_t 219 BStreamingGameSound::_Reserved_BStreamingGameSound_11(int32 arg, ...) 220 { 221 return B_ERROR; 222 } 223 224 225 status_t 226 BStreamingGameSound::_Reserved_BStreamingGameSound_12(int32 arg, ...) 227 { 228 return B_ERROR; 229 } 230 231 232 status_t 233 BStreamingGameSound::_Reserved_BStreamingGameSound_13(int32 arg, ...) 234 { 235 return B_ERROR; 236 } 237 238 239 status_t 240 BStreamingGameSound::_Reserved_BStreamingGameSound_14(int32 arg, ...) 241 { 242 return B_ERROR; 243 } 244 245 246 status_t 247 BStreamingGameSound::_Reserved_BStreamingGameSound_15(int32 arg, ...) 248 { 249 return B_ERROR; 250 } 251 252 253 status_t 254 BStreamingGameSound::_Reserved_BStreamingGameSound_16(int32 arg, ...) 255 { 256 return B_ERROR; 257 } 258 259 260 status_t 261 BStreamingGameSound::_Reserved_BStreamingGameSound_17(int32 arg, ...) 262 { 263 return B_ERROR; 264 } 265 266 267 status_t 268 BStreamingGameSound::_Reserved_BStreamingGameSound_18(int32 arg, ...) 269 { 270 return B_ERROR; 271 } 272 273 274 status_t 275 BStreamingGameSound::_Reserved_BStreamingGameSound_19(int32 arg, ...) 276 { 277 return B_ERROR; 278 } 279 280 281 status_t 282 BStreamingGameSound::_Reserved_BStreamingGameSound_20(int32 arg, ...) 283 { 284 return B_ERROR; 285 } 286 287 288 status_t 289 BStreamingGameSound::_Reserved_BStreamingGameSound_21(int32 arg, ...) 290 { 291 return B_ERROR; 292 } 293 294 295 status_t 296 BStreamingGameSound::_Reserved_BStreamingGameSound_22(int32 arg, ...) 297 { 298 return B_ERROR; 299 } 300 301 302 status_t 303 BStreamingGameSound::_Reserved_BStreamingGameSound_23(int32 arg, ...) 304 { 305 return B_ERROR; 306 } 307