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