Minor RageSound improvements
Nothing major here - updating C style casts, moving repeated function calls into variables, changing lrint's... **RageSound.cpp** - Initialize m_pSource to nullptr in the member initializer list, rather than in the body of the constructor - Define an undefined variable `iSourceFrame` - Change a `lrint` to a `static_cast<int>+0.5` - Implement missing error handling in `SetStopModeFromString` with a log message **RageSoundManager** - Combined the iterator increment and the erase operation for `Update` into one line to prevent needing to create the `next` variable, since GameLoop calls this method frequently **RageSoundReader** - This method is called from RageSound just after making sure iFrames isn't equal to 0, so it's not needed for RageSoundReader to do it again. - We will never fail to read a file 100 times. If we do, it's because of I/O errors, so make that more clear.
This commit is contained in:
@@ -112,20 +112,18 @@ void RageSoundManager::Update()
|
||||
/* Scan m_mapPreloadedSounds for sounds that are no longer loaded, and delete them. */
|
||||
g_SoundManMutex.Lock(); /* lock for access to m_mapPreloadedSounds, owned_sounds */
|
||||
{
|
||||
std::map<RString, RageSoundReader_Preload*>::iterator it, next;
|
||||
it = m_mapPreloadedSounds.begin();
|
||||
|
||||
while( it != m_mapPreloadedSounds.end() )
|
||||
for( auto it = m_mapPreloadedSounds.begin(); it != m_mapPreloadedSounds.end(); )
|
||||
{
|
||||
next = it; ++next;
|
||||
if( it->second->GetReferenceCount() == 1 )
|
||||
{
|
||||
LOG->Trace( "Deleted old sound \"%s\"", it->first.c_str() );
|
||||
delete it->second;
|
||||
m_mapPreloadedSounds.erase( it );
|
||||
it = m_mapPreloadedSounds.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
|
||||
it = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user