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