diff options
Diffstat (limited to 'indra/llaudio/llaudioengine.cpp')
-rwxr-xr-x | indra/llaudio/llaudioengine.cpp | 66 |
1 files changed, 55 insertions, 11 deletions
diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp index ca614f5395..ecdfcaf73a 100755 --- a/indra/llaudio/llaudioengine.cpp +++ b/indra/llaudio/llaudioengine.cpp @@ -674,8 +674,8 @@ void LLAudioEngine::cleanupBuffer(LLAudioBuffer *bufferp) bool LLAudioEngine::preloadSound(const LLUUID &uuid) { LL_DEBUGS("AudioEngine")<<"( "<<uuid<<" )"<<LL_ENDL; - - gAudiop->getAudioData(uuid); // We don't care about the return value, this is just to make sure + + getAudioData(uuid); // We don't care about the return value, this is just to make sure // that we have an entry, which will mean that the audio engine knows about this if (gAudioDecodeMgrp->addDecodeRequest(uuid)) @@ -828,7 +828,7 @@ void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_i source_id.generate(); LLAudioSource *asp = new LLAudioSource(source_id, owner_id, gain, type); - gAudiop->addAudioSource(asp); + addAudioSource(asp); if (pos_global.isExactlyZero()) { asp->setAmbient(true); @@ -1211,8 +1211,8 @@ void LLAudioEngine::startNextTransfer() if (asset_id.notNull()) { LL_INFOS("AudioEngine") << "Getting audio asset data for: " << asset_id << LL_ENDL; - gAudiop->mCurrentTransfer = asset_id; - gAudiop->mCurrentTransferTimer.reset(); + mCurrentTransfer = asset_id; + mCurrentTransferTimer.reset(); gAssetStorage->getAssetData(asset_id, LLAssetType::AT_SOUND, assetCallback, NULL); } @@ -1226,6 +1226,12 @@ void LLAudioEngine::startNextTransfer() // static void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 result_code, LLExtStat ext_status) { + if (!gAudiop) + { + LL_WARNS("AudioEngine") << "LLAudioEngine instance doesn't exist!" << LL_ENDL; + return; + } + if (result_code) { LL_INFOS("AudioEngine") << "Boom, error in audio file transfer: " << LLAssetStorage::getErrorString( result_code ) << " (" << result_code << ")" << LL_ENDL; @@ -1350,7 +1356,12 @@ void LLAudioSource::updatePriority() // Priority is based on distance LLVector3 dist_vec; dist_vec.setVec(getPositionGlobal()); - dist_vec -= gAudiop->getListenerPos(); + + if (gAudiop) + { + dist_vec -= gAudiop->getListenerPos(); + } + F32 dist_squared = llmax(1.f, dist_vec.magVecSquared()); mPriority = mGain / dist_squared; @@ -1367,6 +1378,11 @@ bool LLAudioSource::setupChannel() return false; } + if (!gAudiop) + { + LL_WARNS("AudioEngine") << "LLAudioEngine instance doesn't exist!" << LL_ENDL; + return false; + } if (!mChannelp) { @@ -1410,6 +1426,12 @@ bool LLAudioSource::play(const LLUUID &audio_uuid) // Reset our age timeout if someone attempts to play the source. mAgeTimer.reset(); + if (!gAudiop) + { + LL_WARNS("AudioEngine") << "LLAudioEngine instance doesn't exist!" << LL_ENDL; + return false; + } + LLAudioData *adp = gAudiop->getAudioData(audio_uuid); addAudioData(adp); @@ -1517,6 +1539,13 @@ void LLAudioSource::addAudioData(LLAudioData *adp, const bool set_current) { // Only handle a single piece of audio data associated with a source right now, // until I implement prefetch. + + if (!gAudiop) + { + LL_WARNS("AudioEngine") << "LLAudioEngine instance doesn't exist!" << LL_ENDL; + return; + } + if (set_current) { if (!mCurrentDatap) @@ -1685,6 +1714,12 @@ void LLAudioChannel::setSource(LLAudioSource *sourcep) bool LLAudioChannel::updateBuffer() { + if (!gAudiop) + { + LL_WARNS("AudioEngine") << "LLAudioEngine instance doesn't exist!" << LL_ENDL; + return false; + } + if (!mCurrentSourcep) { // This channel isn't associated with any source, nothing @@ -1693,10 +1728,7 @@ bool LLAudioChannel::updateBuffer() } // Initialize the channel's gain setting for this sound. - if(gAudiop) - { - setSecondaryGain(gAudiop->getSecondaryGain(mCurrentSourcep->getType())); - } + setSecondaryGain(gAudiop->getSecondaryGain(mCurrentSourcep->getType())); LLAudioBuffer *bufferp = mCurrentSourcep->getCurrentBuffer(); if (bufferp == mCurrentBufferp) @@ -1753,8 +1785,14 @@ LLAudioData::LLAudioData(const LLUUID &uuid) : // This is a null sound. return; } + + if (!gAudiop) + { + LL_WARNS("AudioEngine") << "LLAudioEngine instance doesn't exist!" << LL_ENDL; + return; + } - if (gAudiop && gAudiop->hasDecodedFile(uuid)) + if (gAudiop->hasDecodedFile(uuid)) { // Already have a decoded version, don't need to decode it. setHasLocalData(true); @@ -1777,6 +1815,12 @@ bool LLAudioData::load() LL_INFOS("AudioEngine") << "Already have a buffer for this sound, don't bother loading!" << LL_ENDL; return true; } + + if (!gAudiop) + { + LL_WARNS("AudioEngine") << "LLAudioEngine instance doesn't exist!" << LL_ENDL; + return false; + } mBufferp = gAudiop->getFreeBuffer(); if (!mBufferp) |