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:
sukibaby
2024-06-08 17:15:04 -07:00
committed by teejusb
parent 48c1fe3856
commit cb1e2843de
3 changed files with 24 additions and 24 deletions
+6 -8
View File
@@ -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;
}
}