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 34BStreamingGameSound::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 50BStreamingGameSound::BStreamingGameSound(BGameSoundDevice *device) 51 : 52 BGameSound(device), 53 fStreamHook(NULL), 54 fStreamCookie(NULL) 55{ 56} 57 58 59BStreamingGameSound::~BStreamingGameSound() 60{ 61} 62 63 64BGameSound * 65BStreamingGameSound::Clone() const 66{ 67 return NULL; 68} 69 70 71status_t 72BStreamingGameSound::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 82void 83BStreamingGameSound::FillBuffer(void *inBuffer, 84 size_t inByteCount) 85{ 86 if (fStreamHook) 87 (fStreamHook)(fStreamCookie, inBuffer, inByteCount, this); 88} 89 90 91status_t 92BStreamingGameSound::Perform(int32 selector, void *data) 93{ 94 return B_ERROR; 95} 96 97 98status_t 99BStreamingGameSound::SetAttributes(gs_attribute * inAttributes, 100 size_t inAttributeCount) 101{ 102 return BGameSound::SetAttributes(inAttributes, inAttributeCount); 103} 104 105 106status_t 107BStreamingGameSound::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 119bool 120BStreamingGameSound::Lock() 121{ 122 return fLock.Lock(); 123} 124 125 126void 127BStreamingGameSound::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 141status_t 142BStreamingGameSound::_Reserved_BStreamingGameSound_0(int32 arg, ...) 143{ 144 return B_ERROR; 145} 146 147 148status_t 149BStreamingGameSound::_Reserved_BStreamingGameSound_1(int32 arg, ...) 150{ 151 return B_ERROR; 152} 153 154 155status_t 156BStreamingGameSound::_Reserved_BStreamingGameSound_2(int32 arg, ...) 157{ 158 return B_ERROR; 159} 160 161 162status_t 163BStreamingGameSound::_Reserved_BStreamingGameSound_3(int32 arg, ...) 164{ 165 return B_ERROR; 166} 167 168 169status_t 170BStreamingGameSound::_Reserved_BStreamingGameSound_4(int32 arg, ...) 171{ 172 return B_ERROR; 173} 174 175 176status_t 177BStreamingGameSound::_Reserved_BStreamingGameSound_5(int32 arg, ...) 178{ 179 return B_ERROR; 180} 181 182 183status_t 184BStreamingGameSound::_Reserved_BStreamingGameSound_6(int32 arg, ...) 185{ 186 return B_ERROR; 187} 188 189 190status_t 191BStreamingGameSound::_Reserved_BStreamingGameSound_7(int32 arg, ...) 192{ 193 return B_ERROR; 194} 195 196 197status_t 198BStreamingGameSound::_Reserved_BStreamingGameSound_8(int32 arg, ...) 199{ 200 return B_ERROR; 201} 202 203 204status_t 205BStreamingGameSound::_Reserved_BStreamingGameSound_9(int32 arg, ...) 206{ 207 return B_ERROR; 208} 209 210 211status_t 212BStreamingGameSound::_Reserved_BStreamingGameSound_10(int32 arg, ...) 213{ 214 return B_ERROR; 215} 216 217 218status_t 219BStreamingGameSound::_Reserved_BStreamingGameSound_11(int32 arg, ...) 220{ 221 return B_ERROR; 222} 223 224 225status_t 226BStreamingGameSound::_Reserved_BStreamingGameSound_12(int32 arg, ...) 227{ 228 return B_ERROR; 229} 230 231 232status_t 233BStreamingGameSound::_Reserved_BStreamingGameSound_13(int32 arg, ...) 234{ 235 return B_ERROR; 236} 237 238 239status_t 240BStreamingGameSound::_Reserved_BStreamingGameSound_14(int32 arg, ...) 241{ 242 return B_ERROR; 243} 244 245 246status_t 247BStreamingGameSound::_Reserved_BStreamingGameSound_15(int32 arg, ...) 248{ 249 return B_ERROR; 250} 251 252 253status_t 254BStreamingGameSound::_Reserved_BStreamingGameSound_16(int32 arg, ...) 255{ 256 return B_ERROR; 257} 258 259 260status_t 261BStreamingGameSound::_Reserved_BStreamingGameSound_17(int32 arg, ...) 262{ 263 return B_ERROR; 264} 265 266 267status_t 268BStreamingGameSound::_Reserved_BStreamingGameSound_18(int32 arg, ...) 269{ 270 return B_ERROR; 271} 272 273 274status_t 275BStreamingGameSound::_Reserved_BStreamingGameSound_19(int32 arg, ...) 276{ 277 return B_ERROR; 278} 279 280 281status_t 282BStreamingGameSound::_Reserved_BStreamingGameSound_20(int32 arg, ...) 283{ 284 return B_ERROR; 285} 286 287 288status_t 289BStreamingGameSound::_Reserved_BStreamingGameSound_21(int32 arg, ...) 290{ 291 return B_ERROR; 292} 293 294 295status_t 296BStreamingGameSound::_Reserved_BStreamingGameSound_22(int32 arg, ...) 297{ 298 return B_ERROR; 299} 300 301 302status_t 303BStreamingGameSound::_Reserved_BStreamingGameSound_23(int32 arg, ...) 304{ 305 return B_ERROR; 306} 307