Fixed a shutdown crash in LLAudioEngine::assetCallback, and fixed behavior when soundsource re-issues a sound whilst a sound is currently playing for same source. (LLAudioChannel[Impl]::play now re-starts sound if already playing)

This commit is contained in:
Shyotl
2013-10-13 16:22:24 -05:00
parent daa07d031c
commit dbfd0cb7a6
5 changed files with 35 additions and 8 deletions

View File

@@ -1249,6 +1249,9 @@ 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)
return;
if (result_code)
{
LL_INFOS("AudioEngine") << "Boom, error in audio file transfer: " << LLAssetStorage::getErrorString( result_code ) << " (" << result_code << ")" << LL_ENDL;
@@ -1469,6 +1472,19 @@ bool LLAudioSource::play(const LLUUID &audio_uuid)
return true;
}
}
else if(mCurrentDatap == adp) //Desired sound did not change. Just re-play it.
{
if(getChannel() && getChannel()->isPlaying())
getChannel()->play();
return true;
}
else //Desired sound did change. Release the old channel if set.
{
if(getChannel())
getChannel()->cleanup();
mPlayedOnce = false; //Reset the played flag so the new sound is actually started up.
}
mCurrentDatap = adp;
// Make sure the audio engine knows that we want to request this sound.

View File

@@ -600,6 +600,12 @@ void LLAudioChannelFMOD::play()
llwarns << "Playing without a channelID, aborting" << llendl;
return;
}
if(!FSOUND_IsPaused(mChannelID))
{
FSOUND_SetPaused(mChannelID, true);
FSOUND_SetCurrentPosition(mChannelID, 0);
}
if (!FSOUND_SetPaused(mChannelID, false))
{

View File

@@ -823,6 +823,13 @@ void LLAudioChannelFMODEX::play()
gSoundCheck.assertActiveState(this,true);
bool paused=true;
Check_FMOD_Error(mChannelp->getPaused(&paused), "FMOD::Channel::getPaused");
if(!paused)
{
Check_FMOD_Error(mChannelp->setPaused(true), "FMOD::Channel::setPaused");
Check_FMOD_Error(mChannelp->setPosition(0,FMOD_TIMEUNIT_PCMBYTES), "FMOD::Channel::setPosition");
}
Check_FMOD_Error(mChannelp->setPaused(false), "FMOD::Channel::setPaused");
if(sVerboseDebugging)

View File

@@ -199,11 +199,13 @@ void LLAudioChannelOpenAL::play()
return;
}
if(!isPlaying())
if(isPlaying())
{
alSourcePlay(mALSource);
getSource()->setPlayedOnce(true);
alSourceStop(mALSource);
}
alSourcePlay(mALSource);
getSource()->setPlayedOnce(true);
}
void LLAudioChannelOpenAL::playSynced(LLAudioChannel *channelp)

View File

@@ -4901,11 +4901,7 @@ void LLViewerObject::setAttachedSound(const LLUUID &audio_uuid, const LLUUID& ow
mAudioSourcep->setSyncMaster(flags & LL_SOUND_FLAG_SYNC_MASTER);
mAudioSourcep->setSyncSlave(flags & LL_SOUND_FLAG_SYNC_SLAVE);
mAudioSourcep->setQueueSounds(queue);
if(!queue) // stop any current sound first to avoid "farts of doom" (SL-1541) -MG
{
mAudioSourcep->play(LLUUID::null);
}
// Play this sound if region maturity permits
if( gAgent.canAccessMaturityAtGlobal(this->getPositionGlobal()) )
{