From 97e6c15e935666c1b295b7508a182d0da4b481f1 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Wed, 19 Nov 2008 12:51:29 -0600 Subject: VWR-2662: OpenAL support (patch by Tofu Linden) --- linden/indra/llaudio/audioengine.h | 130 ++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 66 deletions(-) (limited to 'linden/indra/llaudio/audioengine.h') diff --git a/linden/indra/llaudio/audioengine.h b/linden/indra/llaudio/audioengine.h index e38413f..94134f5 100644 --- a/linden/indra/llaudio/audioengine.h +++ b/linden/indra/llaudio/audioengine.h @@ -45,6 +45,8 @@ #include "llframetimer.h" #include "llassettype.h" +class LLMediaBase; + const F32 LL_WIND_UPDATE_INTERVAL = 0.1f; const F32 LL_ROLLOFF_MULTIPLIER_UNDER_WATER = 5.f; // How much sounds are weaker under water const F32 LL_WIND_UNDERWATER_CENTER_FREQ = 20.f; @@ -82,9 +84,7 @@ public: virtual ~LLAudioEngine(); // initialization/startup/shutdown - //virtual BOOL init(); - - virtual BOOL init(const S32 num_channels, void *userdata); + virtual bool init(const S32 num_channels, void *userdata); virtual void shutdown(); // Used by the mechanics of the engine @@ -97,14 +97,14 @@ public: // // "End user" functionality // - virtual BOOL isWindEnabled(); - virtual void enableWind(BOOL state_b); + virtual bool isWindEnabled(); + virtual void enableWind(bool state_b); // Use these for temporarily muting the audio system. // Does not change buffers, initialization, etc. but // stops playing new sounds. - virtual void setMuted(BOOL muted); - virtual BOOL getMuted() const { return mMuted; } + virtual void setMuted(bool muted); + virtual bool getMuted() const { return mMuted; } F32 getMasterGain(); void setMasterGain(F32 gain); @@ -123,7 +123,7 @@ public: // Methods actually related to setting up and removing sounds // Owner ID is the owner of the object making the request void triggerSound(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, const LLVector3d &pos_global = LLVector3d::zero); - BOOL preloadSound(const LLUUID &id); + bool preloadSound(const LLUUID &id); void addAudioSource(LLAudioSource *asp); void cleanupAudioSource(LLAudioSource *asp); @@ -132,14 +132,16 @@ public: LLAudioData *getAudioData(const LLUUID &audio_uuid); - virtual void startInternetStream(const std::string& url) = 0; - virtual void stopInternetStream() = 0; - virtual void pauseInternetStream(int pause) = 0; - virtual int isInternetStreamPlaying() = 0; - virtual void getInternetStreamInfo(char* artist, char* title) { artist[0] = 0; title[0] = 0; } + // Internet stream methods + virtual void startInternetStream(const std::string& url); + virtual void stopInternetStream(); + virtual void pauseInternetStream(int pause); + virtual void updateInternetStream(); + virtual int isInternetStreamPlaying(); + virtual void getInternetStreamInfo(char* artist, char* title); // use a value from 0.0 to 1.0, inclusive - virtual void setInternetStreamGain(F32 vol) { mInternetStreamGain = vol; } - virtual const std::string& getInternetStreamURL() { return LLStringUtil::null; } + virtual void setInternetStreamGain(F32 vol); + virtual const std::string& getInternetStreamURL(); // For debugging usage virtual LLVector3 getListenerPos(); @@ -148,17 +150,16 @@ public: LLAudioChannel *getFreeChannel(const F32 priority); // Get a free channel or flush an existing one if your priority is higher void cleanupBuffer(LLAudioBuffer *bufferp); - BOOL hasDecodedFile(const LLUUID &uuid); - BOOL hasLocalFile(const LLUUID &uuid); + bool hasDecodedFile(const LLUUID &uuid); + bool hasLocalFile(const LLUUID &uuid); - BOOL updateBufferForData(LLAudioData *adp, const LLUUID &audio_uuid = LLUUID::null); + bool updateBufferForData(LLAudioData *adp, const LLUUID &audio_uuid = LLUUID::null); // Asset callback when we're retrieved a sound from the asset server. void startNextTransfer(); static void assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 result_code, LLExtStat ext_status); - friend class LLPipeline; // For debugging public: F32 mMaxWindGain; // Hack. Public to set before fade in? @@ -176,11 +177,6 @@ protected: virtual void allocateListener() = 0; - // Internet stream methods - virtual void initInternetStream() {} - virtual void updateInternetStream() {} - - // listener methods virtual void setListenerPos(LLVector3 vec); virtual void setListenerVelocity(LLVector3 vec); @@ -195,13 +191,13 @@ protected: protected: LLListener *mListenerp; - BOOL mMuted; + bool mMuted; void* mUserData; S32 mLastStatus; S32 mNumChannels; - BOOL mEnableWind; + bool mEnableWind; LLUUID mCurrentTransfer; // Audio file currently being transferred by the system LLFrameTimer mCurrentTransferTimer; @@ -225,6 +221,7 @@ protected: // Hack! Internet streams are treated differently from other sources! F32 mInternetStreamGain; + std::string mInternetStreamURL; F32 mNextWindUpdate; @@ -232,6 +229,7 @@ protected: private: void setDefaults(); + LLMediaBase *mInternetStreamMedia; }; @@ -255,24 +253,24 @@ public: void preload(const LLUUID &audio_id); // Only used for preloading UI sounds, now. - void addAudioData(LLAudioData *adp, BOOL set_current = TRUE); + void addAudioData(LLAudioData *adp, bool set_current = TRUE); - void setAmbient(const BOOL ambient) { mAmbient = ambient; } - BOOL isAmbient() const { return mAmbient; } + void setAmbient(const bool ambient) { mAmbient = ambient; } + bool isAmbient() const { return mAmbient; } - void setLoop(const BOOL loop) { mLoop = loop; } - BOOL isLoop() const { return mLoop; } + void setLoop(const bool loop) { mLoop = loop; } + bool isLoop() const { return mLoop; } - void setSyncMaster(const BOOL master) { mSyncMaster = master; } - BOOL isSyncMaster() const { return mSyncMaster; } + void setSyncMaster(const bool master) { mSyncMaster = master; } + bool isSyncMaster() const { return mSyncMaster; } - void setSyncSlave(const BOOL slave) { mSyncSlave = slave; } - BOOL isSyncSlave() const { return mSyncSlave; } + void setSyncSlave(const bool slave) { mSyncSlave = slave; } + bool isSyncSlave() const { return mSyncSlave; } - void setQueueSounds(const BOOL queue) { mQueueSounds = queue; } - BOOL isQueueSounds() const { return mQueueSounds; } + void setQueueSounds(const bool queue) { mQueueSounds = queue; } + bool isQueueSounds() const { return mQueueSounds; } - void setPlayedOnce(const BOOL played_once) { mPlayedOnce = played_once; } + void setPlayedOnce(const bool played_once) { mPlayedOnce = played_once; } void setPositionGlobal(const LLVector3d &position_global) { mPositionGlobal = position_global; } LLVector3d getPositionGlobal() const { return mPositionGlobal; } @@ -284,16 +282,16 @@ public: virtual void setGain(const F32 gain) { mGain = llclamp(gain, 0.f, 1.f); } const LLUUID &getID() const { return mID; } - BOOL isDone(); + bool isDone(); LLAudioData *getCurrentData(); LLAudioData *getQueuedData(); LLAudioBuffer *getCurrentBuffer(); - BOOL setupChannel(); - BOOL play(const LLUUID &audio_id); // Start the audio source playing + bool setupChannel(); + bool play(const LLUUID &audio_id); // Start the audio source playing - BOOL hasPendingPreloads() const; // Has preloads that haven't been done yet + bool hasPendingPreloads() const; // Has preloads that haven't been done yet friend class LLAudioEngine; friend class LLAudioChannel; @@ -306,12 +304,12 @@ protected: LLUUID mOwnerID; // owner of the object playing the sound F32 mPriority; F32 mGain; - BOOL mAmbient; - BOOL mLoop; - BOOL mSyncMaster; - BOOL mSyncSlave; - BOOL mQueueSounds; - BOOL mPlayedOnce; + bool mAmbient; + bool mLoop; + bool mSyncMaster; + bool mSyncSlave; + bool mQueueSounds; + bool mPlayedOnce; LLVector3d mPositionGlobal; LLVector3 mVelocity; @@ -340,27 +338,27 @@ class LLAudioData { public: LLAudioData(const LLUUID &uuid); - BOOL load(); + bool load(); LLUUID getID() const { return mID; } LLAudioBuffer *getBuffer() const { return mBufferp; } - BOOL hasLocalData() const { return mHasLocalData; } - BOOL hasDecodedData() const { return mHasDecodedData; } - BOOL hasValidData() const { return mHasValidData; } + bool hasLocalData() const { return mHasLocalData; } + bool hasDecodedData() const { return mHasDecodedData; } + bool hasValidData() const { return mHasValidData; } - void setHasLocalData(const BOOL hld) { mHasLocalData = hld; } - void setHasDecodedData(const BOOL hdd) { mHasDecodedData = hdd; } - void setHasValidData(const BOOL hvd) { mHasValidData = hvd; } + void setHasLocalData(const bool hld) { mHasLocalData = hld; } + void setHasDecodedData(const bool hdd) { mHasDecodedData = hdd; } + void setHasValidData(const bool hvd) { mHasValidData = hvd; } friend class LLAudioEngine; // Severe laziness, bad. protected: LLUUID mID; LLAudioBuffer *mBufferp; // If this data is being used by the audio system, a pointer to the buffer will be set here. - BOOL mHasLocalData; - BOOL mHasDecodedData; - BOOL mHasValidData; + bool mHasLocalData; + bool mHasDecodedData; + bool mHasValidData; }; @@ -386,18 +384,18 @@ protected: virtual void play() = 0; virtual void playSynced(LLAudioChannel *channelp) = 0; virtual void cleanup() = 0; - virtual BOOL isPlaying() = 0; - void setWaiting(const BOOL waiting) { mWaiting = waiting; } - BOOL isWaiting() const { return mWaiting; } + virtual bool isPlaying() = 0; + void setWaiting(const bool waiting) { mWaiting = waiting; } + bool isWaiting() const { return mWaiting; } - virtual BOOL updateBuffer(); // Check to see if the buffer associated with the source changed, and update if necessary. + virtual bool updateBuffer(); // Check to see if the buffer associated with the source changed, and update if necessary. virtual void update3DPosition() = 0; virtual void updateLoop() = 0; // Update your loop/completion status, for use by queueing/syncing. protected: LLAudioSource *mCurrentSourcep; LLAudioBuffer *mCurrentBufferp; - BOOL mLoopedThisFrame; - BOOL mWaiting; // Waiting for sync. + bool mLoopedThisFrame; + bool mWaiting; // Waiting for sync. }; @@ -412,14 +410,14 @@ class LLAudioBuffer { public: virtual ~LLAudioBuffer() {}; - virtual BOOL loadWAV(const std::string& filename) = 0; + virtual bool loadWAV(const std::string& filename) = 0; virtual U32 getLength() = 0; friend class LLAudioEngine; friend class LLAudioChannel; friend class LLAudioData; protected: - BOOL mInUse; + bool mInUse; LLAudioData *mAudioDatap; LLFrameTimer mLastUseTimer; }; -- cgit v1.1 From 0b208f1539f79f5154a61214876b74a11374bec5 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Sat, 6 Dec 2008 11:27:57 -0700 Subject: openal on windows branch --- linden/indra/llaudio/audioengine.h | 75 ++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 24 deletions(-) (limited to 'linden/indra/llaudio/audioengine.h') diff --git a/linden/indra/llaudio/audioengine.h b/linden/indra/llaudio/audioengine.h index 94134f5..937a8e1 100644 --- a/linden/indra/llaudio/audioengine.h +++ b/linden/indra/llaudio/audioengine.h @@ -80,11 +80,23 @@ class LLAudioBuffer; class LLAudioEngine { public: + enum LLAudioType + { + AUDIO_TYPE_NONE = 0, + AUDIO_TYPE_SFX = 1, + AUDIO_TYPE_UI = 2, + AUDIO_TYPE_AMBIENT = 3, + AUDIO_TYPE_COUNT = 4 // last + }; + LLAudioEngine(); virtual ~LLAudioEngine(); // initialization/startup/shutdown - virtual bool init(const S32 num_channels, void *userdata); + //virtual BOOL init(); + + virtual BOOL init(const S32 num_channels); + virtual std::string getDriverName(bool verbose) = 0; virtual void shutdown(); // Used by the mechanics of the engine @@ -109,6 +121,9 @@ public: F32 getMasterGain(); void setMasterGain(F32 gain); + F32 getSecondaryGain(S32 type); + void setSecondaryGain(S32 type, F32 gain); + F32 getInternetStreamGain(); virtual void setDopplerFactor(F32 factor); @@ -122,8 +137,10 @@ public: // Methods actually related to setting up and removing sounds // Owner ID is the owner of the object making the request - void triggerSound(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, const LLVector3d &pos_global = LLVector3d::zero); - bool preloadSound(const LLUUID &id); + void triggerSound(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, + const S32 type = LLAudioEngine::AUDIO_TYPE_NONE, + const LLVector3d &pos_global = LLVector3d::zero); + BOOL preloadSound(const LLUUID &id); void addAudioSource(LLAudioSource *asp); void cleanupAudioSource(LLAudioSource *asp); @@ -132,16 +149,15 @@ public: LLAudioData *getAudioData(const LLUUID &audio_uuid); - // Internet stream methods - virtual void startInternetStream(const std::string& url); - virtual void stopInternetStream(); - virtual void pauseInternetStream(int pause); - virtual void updateInternetStream(); - virtual int isInternetStreamPlaying(); - virtual void getInternetStreamInfo(char* artist, char* title); + virtual void startInternetStream(const std::string& url) = 0; + virtual void stopInternetStream() = 0; + virtual void pauseInternetStream(int pause) = 0; + virtual int isInternetStreamPlaying() = 0; + virtual void getInternetStreamInfo(char* artist, char* title) { artist[0] = 0; title[0] = 0; } // use a value from 0.0 to 1.0, inclusive - virtual void setInternetStreamGain(F32 vol); - virtual const std::string& getInternetStreamURL(); + virtual void setInternetStreamGain(F32 vol) { mInternetStreamGain = vol; } + virtual const std::string& getInternetStreamURL() { return LLStringUtil::null; } + virtual void InitStreamer() = 0; // For debugging usage virtual LLVector3 getListenerPos(); @@ -177,6 +193,11 @@ protected: virtual void allocateListener() = 0; + // Internet stream methods + virtual void initInternetStream() {} + virtual void updateInternetStream() {} + + // listener methods virtual void setListenerPos(LLVector3 vec); virtual void setListenerVelocity(LLVector3 vec); @@ -191,8 +212,7 @@ protected: protected: LLListener *mListenerp; - bool mMuted; - void* mUserData; + BOOL mMuted; S32 mLastStatus; @@ -218,10 +238,10 @@ protected: LLAudioBuffer *mBuffers[MAX_BUFFERS]; F32 mMasterGain; + F32 mSecondaryGain[AUDIO_TYPE_COUNT]; // Hack! Internet streams are treated differently from other sources! F32 mInternetStreamGain; - std::string mInternetStreamURL; F32 mNextWindUpdate; @@ -229,7 +249,6 @@ protected: private: void setDefaults(); - LLMediaBase *mInternetStreamMedia; }; @@ -272,6 +291,9 @@ public: void setPlayedOnce(const bool played_once) { mPlayedOnce = played_once; } + void setType(S32 type) { mType = type; } + S32 getType() { return mType; } + void setPositionGlobal(const LLVector3d &position_global) { mPositionGlobal = position_global; } LLVector3d getPositionGlobal() const { return mPositionGlobal; } LLVector3 getVelocity() const { return mVelocity; } @@ -304,12 +326,13 @@ protected: LLUUID mOwnerID; // owner of the object playing the sound F32 mPriority; F32 mGain; - bool mAmbient; - bool mLoop; - bool mSyncMaster; - bool mSyncSlave; - bool mQueueSounds; - bool mPlayedOnce; + BOOL mAmbient; + BOOL mLoop; + BOOL mSyncMaster; + BOOL mSyncSlave; + BOOL mQueueSounds; + BOOL mPlayedOnce; + S32 mType; LLVector3d mPositionGlobal; LLVector3 mVelocity; @@ -378,6 +401,9 @@ public: virtual void setSource(LLAudioSource *sourcep); LLAudioSource *getSource() const { return mCurrentSourcep; } + void setSecondaryGain(F32 gain) { mSecondaryGain = gain; } + F32 getSecondaryGain() { return mSecondaryGain; } + friend class LLAudioEngine; friend class LLAudioSource; protected: @@ -394,8 +420,9 @@ protected: protected: LLAudioSource *mCurrentSourcep; LLAudioBuffer *mCurrentBufferp; - bool mLoopedThisFrame; - bool mWaiting; // Waiting for sync. + BOOL mLoopedThisFrame; + BOOL mWaiting; // Waiting for sync. + F32 mSecondaryGain; }; -- cgit v1.1 From b29b13ad98c5c79fd63bae10b4b099a03fa9dc35 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Sat, 6 Dec 2008 14:03:10 -0600 Subject: Updated audio engine to LL's openal branch r1532. --- linden/indra/llaudio/audioengine.h | 56 +++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'linden/indra/llaudio/audioengine.h') diff --git a/linden/indra/llaudio/audioengine.h b/linden/indra/llaudio/audioengine.h index 937a8e1..aff7759 100644 --- a/linden/indra/llaudio/audioengine.h +++ b/linden/indra/llaudio/audioengine.h @@ -69,6 +69,7 @@ class LLVFS; class LLAudioSource; class LLAudioData; class LLAudioChannel; +class LLAudioChannelOpenAL; class LLAudioBuffer; @@ -79,8 +80,10 @@ class LLAudioBuffer; class LLAudioEngine { + friend class LLAudioChannelOpenAL; // bleh. channel needs some listener methods. + public: - enum LLAudioType + typedef enum LLAudioType { AUDIO_TYPE_NONE = 0, AUDIO_TYPE_SFX = 1, @@ -93,9 +96,7 @@ public: virtual ~LLAudioEngine(); // initialization/startup/shutdown - //virtual BOOL init(); - - virtual BOOL init(const S32 num_channels); + virtual bool init(const S32 num_channels, void *userdata); virtual std::string getDriverName(bool verbose) = 0; virtual void shutdown(); @@ -140,7 +141,7 @@ public: void triggerSound(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, const S32 type = LLAudioEngine::AUDIO_TYPE_NONE, const LLVector3d &pos_global = LLVector3d::zero); - BOOL preloadSound(const LLUUID &id); + bool preloadSound(const LLUUID &id); void addAudioSource(LLAudioSource *asp); void cleanupAudioSource(LLAudioSource *asp); @@ -149,15 +150,16 @@ public: LLAudioData *getAudioData(const LLUUID &audio_uuid); - virtual void startInternetStream(const std::string& url) = 0; - virtual void stopInternetStream() = 0; - virtual void pauseInternetStream(int pause) = 0; - virtual int isInternetStreamPlaying() = 0; - virtual void getInternetStreamInfo(char* artist, char* title) { artist[0] = 0; title[0] = 0; } + // Internet stream methods + virtual void startInternetStream(const std::string& url); + virtual void stopInternetStream(); + virtual void pauseInternetStream(int pause); + virtual void updateInternetStream(); + virtual int isInternetStreamPlaying(); + virtual void getInternetStreamInfo(char* artist, char* title); // use a value from 0.0 to 1.0, inclusive - virtual void setInternetStreamGain(F32 vol) { mInternetStreamGain = vol; } - virtual const std::string& getInternetStreamURL() { return LLStringUtil::null; } - virtual void InitStreamer() = 0; + virtual void setInternetStreamGain(F32 vol); + virtual const std::string& getInternetStreamURL(); // For debugging usage virtual LLVector3 getListenerPos(); @@ -193,11 +195,6 @@ protected: virtual void allocateListener() = 0; - // Internet stream methods - virtual void initInternetStream() {} - virtual void updateInternetStream() {} - - // listener methods virtual void setListenerPos(LLVector3 vec); virtual void setListenerVelocity(LLVector3 vec); @@ -212,7 +209,8 @@ protected: protected: LLListener *mListenerp; - BOOL mMuted; + bool mMuted; + void* mUserData; S32 mLastStatus; @@ -242,6 +240,7 @@ protected: // Hack! Internet streams are treated differently from other sources! F32 mInternetStreamGain; + std::string mInternetStreamURL; F32 mNextWindUpdate; @@ -249,6 +248,7 @@ protected: private: void setDefaults(); + LLMediaBase *mInternetStreamMedia; }; @@ -264,7 +264,7 @@ class LLAudioSource public: // owner_id is the id of the agent responsible for making this sound // play, for example, the owner of the object currently playing it - LLAudioSource(const LLUUID &id, const LLUUID& owner_id, const F32 gain); + LLAudioSource(const LLUUID &id, const LLUUID& owner_id, const F32 gain, const S32 type = LLAudioEngine::AUDIO_TYPE_NONE); virtual ~LLAudioSource(); virtual void update(); // Update this audio source @@ -326,12 +326,12 @@ protected: LLUUID mOwnerID; // owner of the object playing the sound F32 mPriority; F32 mGain; - BOOL mAmbient; - BOOL mLoop; - BOOL mSyncMaster; - BOOL mSyncSlave; - BOOL mQueueSounds; - BOOL mPlayedOnce; + bool mAmbient; + bool mLoop; + bool mSyncMaster; + bool mSyncSlave; + bool mQueueSounds; + bool mPlayedOnce; S32 mType; LLVector3d mPositionGlobal; LLVector3 mVelocity; @@ -420,8 +420,8 @@ protected: protected: LLAudioSource *mCurrentSourcep; LLAudioBuffer *mCurrentBufferp; - BOOL mLoopedThisFrame; - BOOL mWaiting; // Waiting for sync. + bool mLoopedThisFrame; + bool mWaiting; // Waiting for sync. F32 mSecondaryGain; }; -- cgit v1.1