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: FileGameSound.h 23 // Author: Christopher ML Zumwalt May (zummy@users.sf.net) 24 // Description: BFileGameSound is a class that streams data out of a file. 25 //------------------------------------------------------------------------------ 26 27 #ifndef _PUSHGAMESOUND_H 28 #define _PUSHGAMESOUND_H 29 30 #include <StreamingGameSound.h> 31 32 33 class BPushGameSound : public BStreamingGameSound 34 { 35 public: 36 BPushGameSound(size_t inBufferFrameCount, 37 const gs_audio_format * format, 38 size_t inBufferCount = 2, 39 BGameSoundDevice * device = NULL); 40 41 virtual ~BPushGameSound(); 42 43 enum lock_status { 44 lock_failed = -1, // not yet time to do more 45 lock_ok = 0, // do more 46 lock_ok_frames_dropped // you may have missed some buffers 47 }; 48 49 virtual lock_status LockNextPage(void ** out_pagePtr, 50 size_t * out_pageSize); 51 virtual status_t UnlockPage(void * in_pagePtr); 52 53 virtual lock_status LockForCyclic(void ** out_basePtr, 54 size_t * out_size); 55 virtual status_t UnlockCyclic(); 56 virtual size_t CurrentPosition(); 57 58 virtual BGameSound * Clone() const; 59 60 virtual status_t Perform(int32 selector, void * data); 61 62 protected: 63 64 BPushGameSound(BGameSoundDevice * device); 65 66 virtual status_t SetParameters(size_t inBufferFrameCount, 67 const gs_audio_format * format, 68 size_t inBufferCount); 69 70 virtual status_t SetStreamHook(void (*hook)(void * inCookie, void * inBuffer, size_t inByteCount, BStreamingGameSound * me), 71 void * cookie); 72 73 virtual void FillBuffer(void * inBuffer, 74 size_t inByteCount); 75 76 77 private: 78 79 /* leave these declarations private unless you plan on actually implementing and using them. */ 80 BPushGameSound(); 81 BPushGameSound(const BPushGameSound&); 82 BPushGameSound& operator=(const BPushGameSound&); 83 84 bool BytesReady(size_t * bytes); 85 86 sem_id fLock; 87 BList * fPageLocked; 88 89 size_t fLockPos; 90 size_t fPlayPos; 91 92 char * fBuffer; 93 size_t fPageSize; 94 int32 fPageCount; 95 size_t fBufferSize; 96 97 /* fbc data and virtuals */ 98 99 uint32 _reserved_BPushGameSound_[12]; 100 101 virtual status_t _Reserved_BPushGameSound_0(int32 arg, ...); 102 virtual status_t _Reserved_BPushGameSound_1(int32 arg, ...); 103 virtual status_t _Reserved_BPushGameSound_2(int32 arg, ...); 104 virtual status_t _Reserved_BPushGameSound_3(int32 arg, ...); 105 virtual status_t _Reserved_BPushGameSound_4(int32 arg, ...); 106 virtual status_t _Reserved_BPushGameSound_5(int32 arg, ...); 107 virtual status_t _Reserved_BPushGameSound_6(int32 arg, ...); 108 virtual status_t _Reserved_BPushGameSound_7(int32 arg, ...); 109 virtual status_t _Reserved_BPushGameSound_8(int32 arg, ...); 110 virtual status_t _Reserved_BPushGameSound_9(int32 arg, ...); 111 virtual status_t _Reserved_BPushGameSound_10(int32 arg, ...); 112 virtual status_t _Reserved_BPushGameSound_11(int32 arg, ...); 113 virtual status_t _Reserved_BPushGameSound_12(int32 arg, ...); 114 virtual status_t _Reserved_BPushGameSound_13(int32 arg, ...); 115 virtual status_t _Reserved_BPushGameSound_14(int32 arg, ...); 116 virtual status_t _Reserved_BPushGameSound_15(int32 arg, ...); 117 virtual status_t _Reserved_BPushGameSound_16(int32 arg, ...); 118 virtual status_t _Reserved_BPushGameSound_17(int32 arg, ...); 119 virtual status_t _Reserved_BPushGameSound_18(int32 arg, ...); 120 virtual status_t _Reserved_BPushGameSound_19(int32 arg, ...); 121 virtual status_t _Reserved_BPushGameSound_20(int32 arg, ...); 122 virtual status_t _Reserved_BPushGameSound_21(int32 arg, ...); 123 virtual status_t _Reserved_BPushGameSound_22(int32 arg, ...); 124 virtual status_t _Reserved_BPushGameSound_23(int32 arg, ...); 125 126 }; 127 128 #endif // _PUSH_GAME_SOUND_H 129