* lock playHandle mutex in mixer::clear()

* moved implementation of mixer::removePlayHandle() from header to source-file
* only delete play-handle in mixer::removePlayHandle() if it was found in playHandle vector (fixes crash when previewing a preset under high load)



git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1698 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-09-23 10:45:05 +00:00
parent eb2f5e9cc2
commit 4583e48c3d
2 changed files with 31 additions and 25 deletions

View File

@@ -735,6 +735,7 @@ const surroundSampleFrame * mixer::renderNextBuffer( void )
void mixer::clear( void )
{
// TODO: m_midiClient->noteOffAll();
lockPlayHandles();
lockPlayHandlesToRemove();
for( playHandleVector::iterator it = m_playHandles.begin();
it != m_playHandles.end(); ++it )
@@ -747,6 +748,7 @@ void mixer::clear( void )
}
}
unlockPlayHandlesToRemove();
unlockPlayHandles();
}
@@ -953,6 +955,34 @@ void mixer::restoreAudioDevice( void )
void mixer::removePlayHandle( playHandle * _ph )
{
// check thread affinity as we must not delete play-handles
// which were created in a thread different than mixer thread
if( _ph->affinityMatters() &&
_ph->affinity() == QThread::currentThread() )
{
lockPlayHandles();
playHandleVector::iterator it =
qFind( m_playHandles.begin(),
m_playHandles.end(), _ph );
if( it != m_playHandles.end() )
{
m_playHandles.erase( it );
delete _ph;
}
unlockPlayHandles();
}
else
{
lockPlayHandlesToRemove();
m_playHandlesToRemove.push_back( _ph );
unlockPlayHandlesToRemove();
}
}
void mixer::removePlayHandles( track * _track )
{
lockPlayHandles();