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 #ifndef _FILEGAMESOUND_H 27 #define _FILEGAMESOUND_H 28 29 30 #include <StreamingGameSound.h> 31 32 struct entry_ref; 33 struct _gs_media_tracker; 34 struct _gs_ramp; 35 36 37 class BFileGameSound : public BStreamingGameSound { 38 public: 39 BFileGameSound(const entry_ref * file, 40 bool looping = true, 41 BGameSoundDevice * device = NULL); 42 BFileGameSound(const char * file, 43 bool looping = true, 44 BGameSoundDevice * device = NULL); 45 46 virtual ~BFileGameSound(); 47 48 virtual BGameSound * Clone() const; 49 50 virtual status_t StartPlaying(); 51 virtual status_t StopPlaying(); 52 status_t Preload(); // if you have stopped and want to start quickly again 53 54 virtual void FillBuffer(void * inBuffer, 55 size_t inByteCount); 56 virtual status_t Perform(int32 selector, void * data); 57 virtual status_t SetPaused(bool isPaused, 58 bigtime_t rampTime); 59 enum { 60 B_NOT_PAUSED, 61 B_PAUSE_IN_PROGRESS, 62 B_PAUSED 63 }; 64 int32 IsPaused(); 65 66 private: 67 _gs_media_tracker * fAudioStream; 68 69 bool fStopping; 70 bool fLooping; 71 char fReserved; 72 char * fBuffer; 73 74 size_t fFrameSize; 75 size_t fBufferSize; 76 size_t fPlayPosition; 77 78 thread_id fReadThread; 79 port_id fPort; 80 81 _gs_ramp * fPausing; 82 bool fPaused; 83 float fPauseGain; 84 85 status_t Init(const entry_ref* file); 86 87 bool Load(); 88 bool Read(void * buffer, size_t bytes); 89 90 /* leave these declarations private unless you plan on actually implementing and using them. */ 91 BFileGameSound(); 92 BFileGameSound(const BFileGameSound&); 93 BFileGameSound& operator=(const BFileGameSound&); 94 95 /* fbc data and virtuals */ 96 97 uint32 _reserved_BFileGameSound_[9]; 98 99 status_t _Reserved_BFileGameSound_0(int32 arg, ...); /* SetPaused(bool paused, bigtime_t ramp); */ 100 virtual status_t _Reserved_BFileGameSound_1(int32 arg, ...); 101 virtual status_t _Reserved_BFileGameSound_2(int32 arg, ...); 102 virtual status_t _Reserved_BFileGameSound_3(int32 arg, ...); 103 virtual status_t _Reserved_BFileGameSound_4(int32 arg, ...); 104 virtual status_t _Reserved_BFileGameSound_5(int32 arg, ...); 105 virtual status_t _Reserved_BFileGameSound_6(int32 arg, ...); 106 virtual status_t _Reserved_BFileGameSound_7(int32 arg, ...); 107 virtual status_t _Reserved_BFileGameSound_8(int32 arg, ...); 108 virtual status_t _Reserved_BFileGameSound_9(int32 arg, ...); 109 virtual status_t _Reserved_BFileGameSound_10(int32 arg, ...); 110 virtual status_t _Reserved_BFileGameSound_11(int32 arg, ...); 111 virtual status_t _Reserved_BFileGameSound_12(int32 arg, ...); 112 virtual status_t _Reserved_BFileGameSound_13(int32 arg, ...); 113 virtual status_t _Reserved_BFileGameSound_14(int32 arg, ...); 114 virtual status_t _Reserved_BFileGameSound_15(int32 arg, ...); 115 virtual status_t _Reserved_BFileGameSound_16(int32 arg, ...); 116 virtual status_t _Reserved_BFileGameSound_17(int32 arg, ...); 117 virtual status_t _Reserved_BFileGameSound_18(int32 arg, ...); 118 virtual status_t _Reserved_BFileGameSound_19(int32 arg, ...); 119 virtual status_t _Reserved_BFileGameSound_20(int32 arg, ...); 120 virtual status_t _Reserved_BFileGameSound_21(int32 arg, ...); 121 virtual status_t _Reserved_BFileGameSound_22(int32 arg, ...); 122 virtual status_t _Reserved_BFileGameSound_23(int32 arg, ...); 123 }; 124 125 #endif // _FILEGAMESOUND_H 126