Mixer: selectively remove PlayHandles in removePlayHandles()

This commit allows finer control of which kind of PlayHandles get
removed in Mixer::removePlayHandles().

This is now used by InstrumentTrack which only removes NotePlayHandles
in InstrumentTrack::silenceAllNotes(). Fixes broken preview of resources
loaded by IPH-based instruments.

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
Tobias Doerffel
2009-07-05 16:38:58 +02:00
parent d1353247d9
commit e3fa8762ef
4 changed files with 18 additions and 13 deletions

View File

@@ -232,7 +232,8 @@ public:
return m_playHandles;
}
void removePlayHandles( track * _track );
void removePlayHandles( track * _track,
playHandle::Type _type = playHandle::NumPlayHandleTypes );
inline bool hasPlayHandles( void ) const
{

View File

@@ -36,15 +36,16 @@ class track;
class playHandle
{
public:
enum types
enum Types
{
NotePlayHandle,
InstrumentPlayHandle,
SamplePlayHandle,
PresetPreviewHandle
NumPlayHandleTypes
} ;
typedef Types Type;
playHandle( const types _type, f_cnt_t _offset = 0 ) :
playHandle( const Type _type, f_cnt_t _offset = 0 ) :
m_type( _type ),
m_offset( _offset ),
m_affinity( QThread::currentThread() )
@@ -55,27 +56,27 @@ public:
{
}
virtual inline bool affinityMatters( void ) const
virtual inline bool affinityMatters() const
{
return false;
}
const QThread * affinity( void ) const
const QThread * affinity() const
{
return m_affinity;
}
inline types type( void ) const
inline Type type() const
{
return m_type;
}
virtual void play( sampleFrame * _working_buffer ) = 0;
virtual bool done( void ) const = 0;
virtual bool done() const = 0;
// returns how many frames this play-handle is aligned ahead, i.e.
// at which position it is inserted in the according buffer
inline f_cnt_t offset( void ) const
inline f_cnt_t offset() const
{
return m_offset;
}
@@ -90,7 +91,7 @@ public:
private:
types m_type;
Type m_type;
f_cnt_t m_offset;
const QThread * m_affinity;

View File

@@ -914,13 +914,15 @@ void mixer::removePlayHandle( playHandle * _ph )
void mixer::removePlayHandles( track * _track )
void mixer::removePlayHandles( track * _track, playHandle::Type _type )
{
lock();
PlayHandleList::Iterator it = m_playHandles.begin();
while( it != m_playHandles.end() )
{
if( ( *it )->isFromTrack( _track ) )
if( ( _type == playHandle::NumPlayHandleTypes ||
( *it )->type() == _type ) &&
( *it )->isFromTrack( _track ) )
{
delete *it;
it = m_playHandles.erase( it );

View File

@@ -419,7 +419,8 @@ void instrumentTrack::silenceAllNotes()
// invalidate all NotePlayHandles linked to this track
m_processHandles.clear();
engine::getMixer()->removePlayHandles( this );
engine::getMixer()->removePlayHandles( this,
playHandle::NotePlayHandle );
engine::getMixer()->unlock();
}