summaryrefslogtreecommitdiff
path: root/indra/llaudio
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llaudio')
-rw-r--r--indra/llaudio/llaudioengine.cpp142
-rwxr-xr-xindra/llaudio/llaudioengine.h13
-rw-r--r--indra/llaudio/llaudioengine_fmodstudio.cpp11
-rw-r--r--indra/llaudio/llaudioengine_fmodstudio.h1
4 files changed, 81 insertions, 86 deletions
diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp
index 008e1827c5..a387bb23cd 100644
--- a/indra/llaudio/llaudioengine.cpp
+++ b/indra/llaudio/llaudioengine.cpp
@@ -123,18 +123,16 @@ void LLAudioEngine::shutdown()
cleanupWind();
// Clean up audio sources
- source_map::iterator iter_src;
- for (iter_src = mAllSources.begin(); iter_src != mAllSources.end(); iter_src++)
+ for (source_map::value_type& src_pair : mAllSources)
{
- delete iter_src->second;
+ delete src_pair.second;
}
// Clean up audio data
- data_map::iterator iter_data;
- for (iter_data = mAllData.begin(); iter_data != mAllData.end(); iter_data++)
+ for (data_map::value_type& data_pair : mAllData)
{
- delete iter_data->second;
+ delete data_pair.second;
}
@@ -206,7 +204,8 @@ std::string LLAudioEngine::getInternetStreamURL()
{
if (mStreamingAudioImpl)
return mStreamingAudioImpl->getURL();
- else return std::string();
+
+ return std::string();
}
@@ -310,12 +309,12 @@ void LLAudioEngine::idle()
updateChannels();
// Update queued sounds (switch to next queued data if the current has finished playing)
- for (iter = mAllSources.begin(); iter != mAllSources.end(); ++iter)
+ for (source_map::value_type& src_pair : mAllSources)
{
// This is lame, instead of this I could actually iterate through all the sources
// attached to each channel, since only those with active channels
// can have anything interesting happen with their queue? (Maybe not true)
- LLAudioSource *sourcep = iter->second;
+ LLAudioSource *sourcep = src_pair.second;
if (!sourcep->mQueuedDatap || sourcep->isMuted())
{
// Muted, or nothing queued, so we don't care.
@@ -347,42 +346,43 @@ void LLAudioEngine::idle()
}
continue;
}
- else
+
+ // Check to see if the current sound is done playing.
+ if (!channelp->isPlaying())
{
- // Check to see if the current sound is done playing, or looped.
- if (!channelp->isPlaying())
+ sourcep->mCurrentDatap = sourcep->mQueuedDatap;
+ sourcep->mQueuedDatap = NULL;
+
+ // Reset the timer so the source doesn't die.
+ sourcep->mAgeTimer.reset();
+
+ // Make sure we have the buffer set up if we just decoded the data
+ if (sourcep->mCurrentDatap)
{
- sourcep->mCurrentDatap = sourcep->mQueuedDatap;
- sourcep->mQueuedDatap = NULL;
+ updateBufferForData(sourcep->mCurrentDatap);
+ }
- // Reset the timer so the source doesn't die.
- sourcep->mAgeTimer.reset();
+ // Actually play the associated data.
+ sourcep->setupChannel();
+ channelp->updateBuffer();
+ sourcep->getChannel()->play();
+ continue;
+ }
- // Make sure we have the buffer set up if we just decoded the data
- if (sourcep->mCurrentDatap)
- {
- updateBufferForData(sourcep->mCurrentDatap);
- }
+ // Check to see if the current sound is looped.
+ if (sourcep->isLoop())
+ {
+ // It's a loop, we need to check and see if we're done with it.
+ if (channelp->mLoopedThisFrame)
+ {
+ sourcep->mCurrentDatap = sourcep->mQueuedDatap;
+ sourcep->mQueuedDatap = NULL;
- // Actually play the associated data.
+ // Actually, should do a time sync so if we're a loop master/slave
+ // we don't drift away.
sourcep->setupChannel();
- channelp->updateBuffer();
sourcep->getChannel()->play();
}
- else if (sourcep->isLoop())
- {
- // It's a loop, we need to check and see if we're done with it.
- if (channelp->mLoopedThisFrame)
- {
- sourcep->mCurrentDatap = sourcep->mQueuedDatap;
- sourcep->mQueuedDatap = NULL;
-
- // Actually, should do a time sync so if we're a loop master/slave
- // we don't drift away.
- sourcep->setupChannel();
- sourcep->getChannel()->play();
- }
- }
}
}
@@ -395,21 +395,14 @@ void LLAudioEngine::idle()
LLAudioSource *sync_masterp = NULL;
LLAudioChannel *master_channelp = NULL;
F32 max_sm_priority = -1.f;
- for (iter = mAllSources.begin(); iter != mAllSources.end(); ++iter)
+ for (source_map::value_type& src_pair : mAllSources)
{
- LLAudioSource *sourcep = iter->second;
- if (sourcep->isMuted())
+ LLAudioSource *sourcep = src_pair.second;
+ if (sourcep->isMuted() && sourcep->isSyncMaster() && sourcep->getPriority() > max_sm_priority)
{
- continue;
- }
- if (sourcep->isSyncMaster())
- {
- if (sourcep->getPriority() > max_sm_priority)
- {
- sync_masterp = sourcep;
- master_channelp = sync_masterp->getChannel();
- max_sm_priority = sourcep->getPriority();
- }
+ sync_masterp = sourcep;
+ master_channelp = sync_masterp->getChannel();
+ max_sm_priority = sourcep->getPriority();
}
}
@@ -417,9 +410,9 @@ void LLAudioEngine::idle()
{
// Synchronize loop slaves with their masters
// Update queued sounds (switch to next queued data if the current has finished playing)
- for (iter = mAllSources.begin(); iter != mAllSources.end(); ++iter)
+ for (source_map::value_type& src_pair : mAllSources)
{
- LLAudioSource *sourcep = iter->second;
+ LLAudioSource *sourcep = src_pair.second;
if (!sourcep->isSyncSlave())
{
@@ -739,7 +732,7 @@ F64 LLAudioEngine::mapWindVecToGain(LLVector3 wind_vec)
}
return (gain);
-}
+}
F64 LLAudioEngine::mapWindVecToPitch(LLVector3 wind_vec)
@@ -966,12 +959,11 @@ void LLAudioEngine::cleanupAudioSource(LLAudioSource *asp)
else
{
LL_DEBUGS("AudioEngine") << "Cleaning up audio sources for "<< asp->getID() <<LL_ENDL;
- delete asp;
- mAllSources.erase(iter);
-}
+ delete asp;
+ mAllSources.erase(iter);
+ }
}
-
bool LLAudioEngine::hasDecodedFile(const LLUUID &uuid)
{
std::string uuid_str;
@@ -1115,9 +1107,9 @@ void LLAudioEngine::startNextTransfer()
}
- for (data_iter = asp->mPreloadMap.begin(); data_iter != asp->mPreloadMap.end(); data_iter++)
+ for (data_map::value_type& preload_pair : asp->mPreloadMap)
{
- LLAudioData *adp = data_iter->second;
+ LLAudioData *adp = preload_pair.second;
if (!adp)
{
continue;
@@ -1137,9 +1129,9 @@ void LLAudioEngine::startNextTransfer()
{
max_pri = -1.f;
source_map::iterator source_iter;
- for (source_iter = mAllSources.begin(); source_iter != mAllSources.end(); source_iter++)
+ for (source_map::value_type& source_pair : mAllSources)
{
- asp = source_iter->second;
+ asp = source_pair.second;
if (!asp)
{
continue;
@@ -1166,9 +1158,9 @@ void LLAudioEngine::startNextTransfer()
continue;
}
- for (data_iter = asp->mPreloadMap.begin(); data_iter != asp->mPreloadMap.end(); data_iter++)
+ for (data_map::value_type& preload_pair : asp->mPreloadMap)
{
- LLAudioData *adp = data_iter->second;
+ LLAudioData *adp = preload_pair.second;
if (!adp)
{
continue;
@@ -1603,10 +1595,9 @@ void LLAudioSource::addAudioData(LLAudioData *adp, const bool set_current)
bool LLAudioSource::hasPendingPreloads() const
{
// Check to see if we've got any preloads on deck for this source
- data_map::const_iterator iter;
- for (iter = mPreloadMap.begin(); iter != mPreloadMap.end(); iter++)
+ for (const data_map::value_type& preload_pair : mPreloadMap)
{
- LLAudioData *adp = iter->second;
+ LLAudioData *adp = preload_pair.second;
// note: a bad UUID will forever be !hasDecodedData()
// but also hasDecodeFailed(), hence the check for hasDecodeFailed()
if (!adp)
@@ -1690,20 +1681,19 @@ void LLAudioChannel::setSource(LLAudioSource *sourcep)
{
LL_DEBUGS("AudioEngine") << "( id: " << sourcep->getID() << ")" << LL_ENDL;
- if (sourcep == mCurrentSourcep)
- {
- // Don't reallocate the channel, this will make FMOD goofy.
- //LL_INFOS() << "Calling setSource with same source!" << LL_ENDL;
- }
+ if (sourcep == mCurrentSourcep)
+ {
+ // Don't reallocate the channel, this will make FMOD goofy.
+ //LL_INFOS() << "Calling setSource with same source!" << LL_ENDL;
+ }
- mCurrentSourcep = sourcep;
+ mCurrentSourcep = sourcep;
- updateBuffer();
- update3DPosition();
-}
+ updateBuffer();
+ update3DPosition();
+ }
}
-
bool LLAudioChannel::updateBuffer()
{
if (!gAudiop)
diff --git a/indra/llaudio/llaudioengine.h b/indra/llaudio/llaudioengine.h
index 0fe8b3d756..a133898969 100755
--- a/indra/llaudio/llaudioengine.h
+++ b/indra/llaudio/llaudioengine.h
@@ -90,6 +90,7 @@ public:
// initialization/startup/shutdown
virtual bool init(void *userdata, const std::string &app_title);
virtual std::string getDriverName(bool verbose) = 0;
+ virtual LLStreamingAudioInterface *createDefaultStreamingAudioImpl() const = 0;
virtual void shutdown();
// Used by the mechanics of the engine
@@ -468,13 +469,13 @@ struct SoundData
const LLUUID& owner_id,
const F32 gain,
const S32 type = LLAudioEngine::AUDIO_TYPE_NONE,
- const LLVector3d &pos_global = LLVector3d::zero)
+ const LLVector3d &pos_global = LLVector3d::zero) :
+ audio_uuid(audio_uuid),
+ owner_id(owner_id),
+ gain(gain),
+ type(type),
+ pos_global(pos_global)
{
- this->audio_uuid = audio_uuid;
- this->owner_id = owner_id;
- this->gain = gain;
- this->type = type;
- this->pos_global = pos_global;
}
};
diff --git a/indra/llaudio/llaudioengine_fmodstudio.cpp b/indra/llaudio/llaudioengine_fmodstudio.cpp
index ba743020b5..c6313ea289 100644
--- a/indra/llaudio/llaudioengine_fmodstudio.cpp
+++ b/indra/llaudio/llaudioengine_fmodstudio.cpp
@@ -208,10 +208,6 @@ bool LLAudioEngine_FMODSTUDIO::init(void* userdata, const std::string &app_title
}
#endif
- // set up our favourite FMOD-native streaming audio implementation if none has already been added
- if (!getStreamingAudioImpl()) // no existing implementation added
- setStreamingAudioImpl(new LLStreamingAudio_FMODSTUDIO(mSystem));
-
LL_INFOS("AppInit") << "LLAudioEngine_FMODSTUDIO::init() FMOD Studio initialized correctly" << LL_ENDL;
int r_numbuffers, r_samplerate, r_channels;
@@ -253,6 +249,13 @@ std::string LLAudioEngine_FMODSTUDIO::getDriverName(bool verbose)
}
+// create our favourite FMOD-native streaming audio implementation
+LLStreamingAudioInterface *LLAudioEngine_FMODSTUDIO::createDefaultStreamingAudioImpl() const
+{
+ return new LLStreamingAudio_FMODSTUDIO(mSystem);
+}
+
+
void LLAudioEngine_FMODSTUDIO::allocateListener(void)
{
mListenerp = (LLListener *) new LLListener_FMODSTUDIO(mSystem);
diff --git a/indra/llaudio/llaudioengine_fmodstudio.h b/indra/llaudio/llaudioengine_fmodstudio.h
index d3d6d69685..29e7bc6bf0 100644
--- a/indra/llaudio/llaudioengine_fmodstudio.h
+++ b/indra/llaudio/llaudioengine_fmodstudio.h
@@ -53,6 +53,7 @@ public:
// initialization/startup/shutdown
virtual bool init(void *user_data, const std::string &app_title);
virtual std::string getDriverName(bool verbose);
+ virtual LLStreamingAudioInterface* createDefaultStreamingAudioImpl() const;
virtual void allocateListener();
virtual void shutdown();