more consistent code path: call SoundIsFinishedPlaying when the driver stops mixing, even if it's due to RageSoundDriver::StopMixing
This commit is contained in:
@@ -335,26 +335,8 @@ void RageSound::StopPlaying()
|
|||||||
if( !m_bPlaying )
|
if( !m_bPlaying )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_iStoppedSourceFrame = (int) GetPositionSecondsInternal();
|
|
||||||
|
|
||||||
/* Tell the sound driver to stop mixing this sound. */
|
/* Tell the sound driver to stop mixing this sound. */
|
||||||
SOUNDMAN->StopMixing(this);
|
SOUNDMAN->StopMixing(this);
|
||||||
|
|
||||||
/* Lock the mutex after calling UnregisterPlayingSound. We must not make driver
|
|
||||||
* calls with our mutex locked (driver mutex < sound mutex). Nobody else will
|
|
||||||
* see our sound as not playing until we set playing = false. */
|
|
||||||
m_Mutex.Lock();
|
|
||||||
|
|
||||||
// LOG->Trace("set playing false for %p (StopPlaying) (%s)", this, this->GetLoadedFilePath().c_str());
|
|
||||||
m_bPlaying = false;
|
|
||||||
|
|
||||||
m_iMaxDriverFrame = 0;
|
|
||||||
m_HardwareToStreamMap.Clear();
|
|
||||||
m_StreamToSourceMap.Clear();
|
|
||||||
|
|
||||||
// LOG->Trace("StopPlaying %p finished (%s)", this, this->GetLoadedFilePath().c_str());
|
|
||||||
|
|
||||||
m_Mutex.Unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is similar to StopPlaying, except it's called by sound drivers when we're done
|
/* This is similar to StopPlaying, except it's called by sound drivers when we're done
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ void RageSoundDriver::StartMixing( RageSoundBase *pSound )
|
|||||||
void RageSoundDriver::StopMixing( RageSoundBase *pSound )
|
void RageSoundDriver::StopMixing( RageSoundBase *pSound )
|
||||||
{
|
{
|
||||||
/* Lock, to make sure the decoder thread isn't running on this sound while we do this. */
|
/* Lock, to make sure the decoder thread isn't running on this sound while we do this. */
|
||||||
LockMut( m_Mutex );
|
m_Mutex.Lock();
|
||||||
|
|
||||||
/* Find the sound. */
|
/* Find the sound. */
|
||||||
unsigned i;
|
unsigned i;
|
||||||
@@ -368,6 +368,7 @@ void RageSoundDriver::StopMixing( RageSoundBase *pSound )
|
|||||||
break;
|
break;
|
||||||
if( i == ARRAYLEN(m_Sounds) )
|
if( i == ARRAYLEN(m_Sounds) )
|
||||||
{
|
{
|
||||||
|
m_Mutex.Unlock();
|
||||||
LOG->Trace( "not stopping a sound because it's not playing" );
|
LOG->Trace( "not stopping a sound because it's not playing" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -375,6 +376,7 @@ void RageSoundDriver::StopMixing( RageSoundBase *pSound )
|
|||||||
/* If we're already in STOPPED, there's nothing to do. */
|
/* If we're already in STOPPED, there's nothing to do. */
|
||||||
if( m_Sounds[i].m_State == Sound::STOPPED )
|
if( m_Sounds[i].m_State == Sound::STOPPED )
|
||||||
{
|
{
|
||||||
|
m_Mutex.Unlock();
|
||||||
LOG->Trace( "not stopping a sound because it's already in STOPPED" );
|
LOG->Trace( "not stopping a sound because it's already in STOPPED" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -389,6 +391,10 @@ void RageSoundDriver::StopMixing( RageSoundBase *pSound )
|
|||||||
* it. Once this call returns, the sound may no longer exist. */
|
* it. Once this call returns, the sound may no longer exist. */
|
||||||
m_Sounds[i].m_pSound = NULL;
|
m_Sounds[i].m_pSound = NULL;
|
||||||
// LOG->Trace("end StopMixing");
|
// LOG->Trace("end StopMixing");
|
||||||
|
|
||||||
|
m_Mutex.Unlock();
|
||||||
|
|
||||||
|
pSound->SoundIsFinishedPlaying();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user