If a sound is started, plays for a while, then stopped, repositioned and
started quickly, queued position data from the previous play will still be flushed. We clear already-flushed data in StopMixing (pos_map.clear()) so we don't have stale data, but some is being re-flushed afterwards because we have the same ID. Change sound IDs when stopping a sound. (The symptom was the first frame in Play mode in the editor would process using an old position; the position was usually later in the song, which sometimes marked hold notes as dead.)
This commit is contained in:
@@ -72,7 +72,9 @@ RageSound::RageSound():
|
|||||||
databuf.reserve(internal_buffer_size);
|
databuf.reserve(internal_buffer_size);
|
||||||
|
|
||||||
/* Register ourself. */
|
/* Register ourself. */
|
||||||
ID = SOUNDMAN->RegisterSound( this );
|
SOUNDMAN->RegisterSound( this );
|
||||||
|
|
||||||
|
ID = SOUNDMAN->GetUniqueID();
|
||||||
}
|
}
|
||||||
|
|
||||||
RageSound::~RageSound()
|
RageSound::~RageSound()
|
||||||
@@ -98,8 +100,11 @@ RageSound::RageSound(const RageSound &cpy):
|
|||||||
|
|
||||||
*this = cpy;
|
*this = cpy;
|
||||||
|
|
||||||
/* Register ourself. We have a different ID than our parent. */
|
/* Register ourself. */
|
||||||
ID = SOUNDMAN->RegisterSound( this );
|
SOUNDMAN->RegisterSound( this );
|
||||||
|
|
||||||
|
/* We have a different ID than our parent. */
|
||||||
|
ID = SOUNDMAN->GetUniqueID();
|
||||||
}
|
}
|
||||||
|
|
||||||
RageSound &RageSound::operator=( const RageSound &cpy )
|
RageSound &RageSound::operator=( const RageSound &cpy )
|
||||||
@@ -605,6 +610,12 @@ void RageSound::StopPlaying()
|
|||||||
|
|
||||||
max_driver_frame = 0;
|
max_driver_frame = 0;
|
||||||
pos_map.Clear();
|
pos_map.Clear();
|
||||||
|
|
||||||
|
/* We may still have positions queued up in RageSoundManager. We need to make sure
|
||||||
|
* that we don't accept those; otherwise, if we start playing again quickly, they'll
|
||||||
|
* confuse GetPositionSeconds(). Do this by changing our ID. */
|
||||||
|
ID = SOUNDMAN->GetUniqueID();
|
||||||
|
|
||||||
// LOG->Trace("StopPlaying %p finished (%s)", this, this->GetLoadedFilePath().c_str());
|
// LOG->Trace("StopPlaying %p finished (%s)", this, this->GetLoadedFilePath().c_str());
|
||||||
|
|
||||||
m_Mutex.Unlock();
|
m_Mutex.Unlock();
|
||||||
|
|||||||
@@ -122,14 +122,11 @@ void RageSoundManager::Update(float delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Register the given sound, and return a unique ID. */
|
/* Register the given sound, and return a unique ID. */
|
||||||
int RageSoundManager::RegisterSound( RageSound *p )
|
void RageSoundManager::RegisterSound( RageSound *p )
|
||||||
{
|
{
|
||||||
LockMut(g_SoundManMutex); /* lock for access to all_sounds and iID */
|
g_SoundManMutex.Lock(); /* lock for access to all_sounds */
|
||||||
|
|
||||||
all_sounds.insert( p );
|
all_sounds.insert( p );
|
||||||
|
g_SoundManMutex.Unlock(); /* finished with all_sounds */
|
||||||
static int iID = 0;
|
|
||||||
return ++iID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSoundManager::UnregisterSound( RageSound *p )
|
void RageSoundManager::UnregisterSound( RageSound *p )
|
||||||
@@ -139,6 +136,14 @@ void RageSoundManager::UnregisterSound( RageSound *p )
|
|||||||
g_SoundManMutex.Unlock(); /* finished with all_sounds */
|
g_SoundManMutex.Unlock(); /* finished with all_sounds */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return a unique ID. */
|
||||||
|
int RageSoundManager::GetUniqueID()
|
||||||
|
{
|
||||||
|
LockMut(g_SoundManMutex); /* serialize iID */
|
||||||
|
static int iID = 0;
|
||||||
|
return ++iID;
|
||||||
|
}
|
||||||
|
|
||||||
void RageSoundManager::RegisterPlayingSound( RageSound *p )
|
void RageSoundManager::RegisterPlayingSound( RageSound *p )
|
||||||
{
|
{
|
||||||
g_SoundManMutex.Lock(); /* lock for access to playing_sounds */
|
g_SoundManMutex.Lock(); /* lock for access to playing_sounds */
|
||||||
|
|||||||
@@ -44,8 +44,9 @@ public:
|
|||||||
void StartMixing( RageSoundBase *snd ); /* used by RageSound */
|
void StartMixing( RageSoundBase *snd ); /* used by RageSound */
|
||||||
void StopMixing( RageSoundBase *snd ); /* used by RageSound */
|
void StopMixing( RageSoundBase *snd ); /* used by RageSound */
|
||||||
int64_t GetPosition( const RageSoundBase *snd ) const; /* used by RageSound */
|
int64_t GetPosition( const RageSoundBase *snd ) const; /* used by RageSound */
|
||||||
int RegisterSound( RageSound *p ); /* used by RageSound */
|
void RegisterSound( RageSound *p ); /* used by RageSound */
|
||||||
void UnregisterSound( RageSound *p ); /* used by RageSound */
|
void UnregisterSound( RageSound *p ); /* used by RageSound */
|
||||||
|
int GetUniqueID(); /* used by RageSound */
|
||||||
void RegisterPlayingSound( RageSound *p ); /* used by RageSound */
|
void RegisterPlayingSound( RageSound *p ); /* used by RageSound */
|
||||||
void UnregisterPlayingSound( RageSound *p ); /* used by RageSound */
|
void UnregisterPlayingSound( RageSound *p ); /* used by RageSound */
|
||||||
void CommitPlayingPosition( int ID, int64_t frameno, int pos, int got_bytes ); /* used by drivers */
|
void CommitPlayingPosition( int ID, int64_t frameno, int pos, int got_bytes ); /* used by drivers */
|
||||||
|
|||||||
Reference in New Issue
Block a user