avoid holding GameSoundManager lock while stopping sounds
This commit is contained in:
@@ -93,9 +93,12 @@ CHECKPOINT;
|
|||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
if( ToPlay.file.empty() )
|
if( ToPlay.file.empty() )
|
||||||
{
|
{
|
||||||
if( g_Playing->m_Music->IsPlaying() )
|
/* StopPlaying() can take a while, so don't hold the lock while we stop. */
|
||||||
g_Playing->m_Music->StopPlaying();
|
MusicPlaying *pOldPlaying = g_Playing;
|
||||||
g_Playing->m_Music->Unload();
|
g_Playing = new MusicPlaying( new RageSound );
|
||||||
|
L.Unlock();
|
||||||
|
|
||||||
|
delete pOldPlaying;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
@@ -105,6 +108,7 @@ CHECKPOINT;
|
|||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
|
||||||
/* See if we can find timing data, if it's not already loaded. */
|
/* See if we can find timing data, if it's not already loaded. */
|
||||||
|
/* XXX: don't IsAFile while holding g_Mutex */
|
||||||
if( !ToPlay.HasTiming && IsAFile(ToPlay.timing_file) )
|
if( !ToPlay.HasTiming && IsAFile(ToPlay.timing_file) )
|
||||||
{
|
{
|
||||||
LOG->Trace("Found '%s'", ToPlay.timing_file.c_str());
|
LOG->Trace("Found '%s'", ToPlay.timing_file.c_str());
|
||||||
@@ -282,10 +286,13 @@ static void StartQueuedSounds()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
LockMutex L( *g_Mutex );
|
/* StopPlaying() can take a while, so don't hold the lock while we stop. */
|
||||||
if( g_Playing->m_Music->IsPlaying() )
|
g_Mutex->Lock();
|
||||||
g_Playing->m_Music->StopPlaying();
|
MusicPlaying *pOldPlaying = g_Playing;
|
||||||
g_Playing->m_Music->Unload();
|
g_Playing = new MusicPlaying( new RageSound );
|
||||||
|
g_Mutex->Unlock();
|
||||||
|
|
||||||
|
delete pOldPlaying;
|
||||||
}
|
}
|
||||||
delete pMusic;
|
delete pMusic;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user