* ensure correct thread affinity when deleting play handles - fixes crash when previewing samples and LMMS was linked against Qt 4.3.x
* renamed destroyed()-signals for not conflicting with QObject::destroyed() in Qt 4.3 * made effectChain creation in audioPort optional * fixed various compiler warnings git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1602 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -30,13 +30,14 @@
|
||||
#include <QtCore/QMutex>
|
||||
#include <QtCore/QMutexLocker>
|
||||
|
||||
#include "effect_chain.h"
|
||||
#include "mixer.h"
|
||||
|
||||
class effectChain;
|
||||
|
||||
class audioPort
|
||||
{
|
||||
public:
|
||||
audioPort( const QString & _name );
|
||||
audioPort( const QString & _name, bool _has_effect_chain = true );
|
||||
~audioPort();
|
||||
|
||||
inline sampleFrame * firstBuffer( void )
|
||||
@@ -90,7 +91,7 @@ public:
|
||||
|
||||
inline effectChain * getEffects( void )
|
||||
{
|
||||
return( &m_effects );
|
||||
return( m_effects );
|
||||
}
|
||||
|
||||
void setNextFxChannel( const fx_ch_t _chnl )
|
||||
@@ -131,7 +132,7 @@ private:
|
||||
|
||||
QString m_name;
|
||||
|
||||
effectChain m_effects;
|
||||
effectChain * m_effects;
|
||||
|
||||
|
||||
friend class mixer;
|
||||
|
||||
@@ -88,8 +88,8 @@ struct midiEvent
|
||||
{
|
||||
midiEvent( MidiEventTypes _type = MidiActiveSensing,
|
||||
Sint8 _channel = 0,
|
||||
Uint16 _param1 = 0,
|
||||
Uint16 _param2 = 0 ) :
|
||||
Sint16 _param1 = 0,
|
||||
Sint16 _param2 = 0 ) :
|
||||
m_type( _type ),
|
||||
m_channel( _channel ),
|
||||
m_sysExData( NULL )
|
||||
@@ -119,22 +119,22 @@ struct midiEvent
|
||||
return m_channel;
|
||||
}
|
||||
|
||||
inline Uint16 key( void ) const
|
||||
inline Sint16 key( void ) const
|
||||
{
|
||||
return( m_data.m_param[0] );
|
||||
}
|
||||
|
||||
inline Uint16 & key( void )
|
||||
inline Sint16 & key( void )
|
||||
{
|
||||
return( m_data.m_param[0] );
|
||||
}
|
||||
|
||||
inline Uint16 velocity( void ) const
|
||||
inline Sint16 velocity( void ) const
|
||||
{
|
||||
return( m_data.m_param[1] );
|
||||
}
|
||||
|
||||
inline Uint16 & velocity( void )
|
||||
inline Sint16 & velocity( void )
|
||||
{
|
||||
return( m_data.m_param[1] );
|
||||
}
|
||||
@@ -149,9 +149,9 @@ struct midiEvent
|
||||
Sint8 m_channel; // MIDI channel
|
||||
union
|
||||
{
|
||||
Uint16 m_param[2]; // first/second parameter (key/velocity)
|
||||
Sint16 m_param[2]; // first/second parameter (key/velocity)
|
||||
Uint8 m_bytes[4]; // raw bytes
|
||||
Uint32 m_sysExDataLen; // len of m_sysExData
|
||||
Sint32 m_sysExDataLen; // len of m_sysExData
|
||||
} m_data;
|
||||
|
||||
const char * m_sysExData;
|
||||
|
||||
@@ -243,11 +243,30 @@ public:
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
inline void removePlayHandle( const playHandle * _ph )
|
||||
void removePlayHandle( playHandle * _ph )
|
||||
{
|
||||
lockPlayHandlesToRemove();
|
||||
m_playHandlesToRemove.push_back( _ph );
|
||||
unlockPlayHandlesToRemove();
|
||||
// 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 );
|
||||
}
|
||||
unlockPlayHandles();
|
||||
delete _ph;
|
||||
}
|
||||
else
|
||||
{
|
||||
lockPlayHandlesToRemove();
|
||||
m_playHandlesToRemove.push_back( _ph );
|
||||
unlockPlayHandlesToRemove();
|
||||
}
|
||||
}
|
||||
|
||||
inline playHandleVector & playHandles( void )
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#ifndef _PLAY_HANDLE_H
|
||||
#define _PLAY_HANDLE_H
|
||||
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QVector>
|
||||
|
||||
#include "types.h"
|
||||
@@ -47,7 +48,8 @@ public:
|
||||
|
||||
playHandle( const types _type, f_cnt_t _offset = 0 ) :
|
||||
m_type( _type ),
|
||||
m_offset( _offset )
|
||||
m_offset( _offset ),
|
||||
m_affinity( QThread::currentThread() )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -55,6 +57,16 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual inline bool affinityMatters( void ) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const QThread * affinity( void ) const
|
||||
{
|
||||
return( m_affinity );
|
||||
}
|
||||
|
||||
inline types type( void ) const
|
||||
{
|
||||
return( m_type );
|
||||
@@ -92,6 +104,7 @@ public:
|
||||
private:
|
||||
types m_type;
|
||||
f_cnt_t m_offset;
|
||||
QThread * m_affinity;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
@@ -46,6 +46,12 @@ public:
|
||||
samplePlayHandle( pattern * _pattern );
|
||||
virtual ~samplePlayHandle();
|
||||
|
||||
virtual inline bool affinityMatters( void ) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual void play( bool _try_parallelizing,
|
||||
sampleFrame * _working_buffer );
|
||||
virtual bool done( void ) const;
|
||||
|
||||
@@ -126,7 +126,7 @@ protected:
|
||||
signals:
|
||||
void lengthChanged( void );
|
||||
void positionChanged( void );
|
||||
void destroyed( void );
|
||||
void destroyedTCO( void );
|
||||
|
||||
|
||||
private:
|
||||
@@ -463,7 +463,7 @@ private:
|
||||
|
||||
|
||||
signals:
|
||||
void destroyed( void );
|
||||
void destroyedTrack( void );
|
||||
void nameChanged( void );
|
||||
void trackContentObjectAdded( trackContentObject * );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user