remove DeleteSoundWhenFinished
This commit is contained in:
@@ -57,15 +57,6 @@ void RageSoundManager::Init()
|
|||||||
|
|
||||||
RageSoundManager::~RageSoundManager()
|
RageSoundManager::~RageSoundManager()
|
||||||
{
|
{
|
||||||
g_SoundManMutex.Lock(); /* lock for access to owned_sounds */
|
|
||||||
set<RageSound *> sounds = owned_sounds;
|
|
||||||
g_SoundManMutex.Unlock(); /* finished with owned_sounds */
|
|
||||||
|
|
||||||
/* Clear any sounds that we own and havn't freed yet. */
|
|
||||||
set<RageSound *>::iterator j = sounds.begin();
|
|
||||||
while(j != sounds.end())
|
|
||||||
delete *(j++);
|
|
||||||
|
|
||||||
/* Don't lock while deleting the driver (the decoder thread might deadlock). */
|
/* Don't lock while deleting the driver (the decoder thread might deadlock). */
|
||||||
delete m_pDriver;
|
delete m_pDriver;
|
||||||
}
|
}
|
||||||
@@ -131,26 +122,7 @@ void RageSoundManager::Update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scan the owned_sounds list for sounds that are no longer playing, and delete them. */
|
g_SoundManMutex.Unlock(); /* finished with m_mapPreloadedSounds */
|
||||||
set<RageSound *> ToDelete;
|
|
||||||
for( set<RageSound *>::iterator it = owned_sounds.begin(); it != owned_sounds.end(); ++it )
|
|
||||||
{
|
|
||||||
RageSound *pSound = *it;
|
|
||||||
if( pSound->IsPlaying() )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
LOG->Trace("XXX: deleting '%s'", pSound->GetLoadedFilePath().c_str());
|
|
||||||
|
|
||||||
ToDelete.insert( pSound );
|
|
||||||
}
|
|
||||||
|
|
||||||
for( set<RageSound *>::iterator it = ToDelete.begin(); it != ToDelete.end(); ++it )
|
|
||||||
owned_sounds.erase( *it );
|
|
||||||
g_SoundManMutex.Unlock(); /* finished with owned_sounds */
|
|
||||||
|
|
||||||
/* Be sure to release g_SoundManMutex before deleting sounds. */
|
|
||||||
for( set<RageSound *>::iterator it = ToDelete.begin(); it != ToDelete.end(); ++it )
|
|
||||||
delete *it;
|
|
||||||
|
|
||||||
if( m_pDriver != NULL )
|
if( m_pDriver != NULL )
|
||||||
m_pDriver->Update();
|
m_pDriver->Update();
|
||||||
@@ -199,13 +171,6 @@ RageSound *RageSoundManager::PlayCopyOfSound( RageSound &snd, const RageSoundPar
|
|||||||
return pSound;
|
return pSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSoundManager::DeleteSoundWhenFinished( RageSound *pSound )
|
|
||||||
{
|
|
||||||
g_SoundManMutex.Lock(); /* lock for access to owned_sounds */
|
|
||||||
owned_sounds.insert( pSound );
|
|
||||||
g_SoundManMutex.Unlock(); /* finished with owned_sounds */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the given path is loaded, return a copy; otherwise return NULL.
|
/* If the given path is loaded, return a copy; otherwise return NULL.
|
||||||
* It's the caller's responsibility to delete the result. */
|
* It's the caller's responsibility to delete the result. */
|
||||||
RageSoundReader *RageSoundManager::GetLoadedSound( const RString &sPath_ )
|
RageSoundReader *RageSoundManager::GetLoadedSound( const RString &sPath_ )
|
||||||
|
|||||||
@@ -42,8 +42,6 @@ public:
|
|||||||
float GetPlayLatency() const;
|
float GetPlayLatency() const;
|
||||||
int GetDriverSampleRate() const;
|
int GetDriverSampleRate() const;
|
||||||
|
|
||||||
void DeleteSoundWhenFinished( RageSound *pSound );
|
|
||||||
|
|
||||||
RageSoundReader *GetLoadedSound( const RString &sPath );
|
RageSoundReader *GetLoadedSound( const RString &sPath );
|
||||||
void AddLoadedSound( const RString &sPath, RageSoundReader_Preload *pSound );
|
void AddLoadedSound( const RString &sPath, RageSoundReader_Preload *pSound );
|
||||||
|
|
||||||
@@ -53,10 +51,6 @@ public:
|
|||||||
RageSound *PlayCopyOfSound( RageSound &snd, const RageSoundParams *params = NULL );
|
RageSound *PlayCopyOfSound( RageSound &snd, const RageSoundParams *params = NULL );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* Set of sounds that we've taken over (and are responsible for deleting
|
|
||||||
* when they're finished playing): */
|
|
||||||
set<RageSound *> owned_sounds;
|
|
||||||
|
|
||||||
map<RString, RageSoundReader_Preload *> m_mapPreloadedSounds;
|
map<RString, RageSoundReader_Preload *> m_mapPreloadedSounds;
|
||||||
|
|
||||||
RageSoundDriver *m_pDriver;
|
RageSoundDriver *m_pDriver;
|
||||||
|
|||||||
Reference in New Issue
Block a user