00001 00033 #ifndef LL_AUDIOENGINE_FMOD_H 00034 #define LL_AUDIOENGINE_FMOD_H 00035 00036 #include "audioengine.h" 00037 00038 #if LL_FMOD 00039 00040 #include "listener_fmod.h" 00041 00042 #include "fmod.h" 00043 00044 class LLAudioStreamFMOD; 00045 00046 class LLAudioEngine_FMOD : public LLAudioEngine 00047 { 00048 public: 00049 LLAudioEngine_FMOD(); 00050 virtual ~LLAudioEngine_FMOD(); 00051 00052 // initialization/startup/shutdown 00053 virtual BOOL init(const S32 num_channels, void *user_data); 00054 virtual void allocateListener(); 00055 00056 virtual void shutdown(); 00057 00058 virtual void idle(F32 max_decode_time = 0.f); 00059 00060 // Internet stream methods 00061 virtual void initInternetStream(); 00062 virtual void startInternetStream(const char* url); 00063 virtual void updateInternetStream(); 00064 virtual void stopInternetStream(); 00065 virtual void pauseInternetStream(int pause); 00066 virtual int isInternetStreamPlaying(); 00067 virtual void getInternetStreamInfo(char* artist, char* title); 00068 virtual void setInternetStreamGain(F32 vol); 00069 virtual const char* getInternetStreamURL(); 00070 00071 /*virtual*/ void initWind(); 00072 /*virtual*/ void cleanupWind(); 00073 00074 /*virtual*/void updateWind(LLVector3 direction, F32 camera_height_above_water); 00075 00076 protected: 00077 /*virtual*/ LLAudioBuffer *createBuffer(); // Get a free buffer, or flush an existing one if you have to. 00078 /*virtual*/ LLAudioChannel *createChannel(); // Create a new audio channel. 00079 00080 /*virtual*/ void setInternalGain(F32 gain); 00081 protected: 00082 static signed char F_CALLBACKAPI callbackMetaData(char* name, char* value, void* userdata); 00083 00084 LLAudioStreamFMOD *mCurrentInternetStreamp; 00085 char mInternetStreamURL[1024]; /*Flawfinder: ignore*/ 00086 int mInternetStreamChannel; 00087 00088 std::list<LLAudioStreamFMOD *> mDeadStreams; 00089 00090 //F32 mMinDistance[MAX_BUFFERS]; 00091 //F32 mMaxDistance[MAX_BUFFERS]; 00092 00093 S32 mFadeIn; 00094 BOOL mInited; 00095 00096 // On Windows, userdata is the HWND of the application window. 00097 void* mUserData; 00098 00099 }; 00100 00101 00102 class LLAudioChannelFMOD : public LLAudioChannel 00103 { 00104 public: 00105 LLAudioChannelFMOD(); 00106 virtual ~LLAudioChannelFMOD(); 00107 00108 protected: 00109 /*virtual*/ void play(); 00110 /*virtual*/ void playSynced(LLAudioChannel *channelp); 00111 /*virtual*/ void cleanup(); 00112 /*virtual*/ BOOL isPlaying(); 00113 00114 /*virtual*/ BOOL updateBuffer(); 00115 /*virtual*/ void update3DPosition(); 00116 /*virtual*/ void updateLoop(); 00117 00118 protected: 00119 int mChannelID; 00120 S32 mLastSamplePos; 00121 }; 00122 00123 00124 class LLAudioBufferFMOD : public LLAudioBuffer 00125 { 00126 public: 00127 LLAudioBufferFMOD(); 00128 virtual ~LLAudioBufferFMOD(); 00129 00130 /*virtual*/ BOOL loadWAV(const char *filename); 00131 /*virtual*/ U32 getLength(); 00132 friend class LLAudioChannelFMOD; 00133 00134 void set3DMode(BOOL use3d); 00135 protected: 00136 FSOUND_SAMPLE *getSample() { return mSamplep; } 00137 protected: 00138 FSOUND_SAMPLE *mSamplep; 00139 }; 00140 00141 class LLAudioStreamFMOD 00142 { 00143 public: 00144 LLAudioStreamFMOD(const char *url); 00145 int startStream(); 00146 BOOL stopStream(); // Returns true if the stream was successfully stopped. 00147 BOOL ready(); 00148 00149 char *getURL() { return mInternetStreamURL; } 00150 00151 int getOpenState(); 00152 protected: 00153 FSOUND_STREAM* mInternetStream; 00154 BOOL mReady; 00155 00156 char mInternetStreamURL[1024]; /*Flawfinder: ignore*/ 00157 }; 00158 00159 #endif 00160 00161 #endif 00162