mirror of
https://github.com/LMMS/lmms.git
synced 2026-03-15 20:50:08 -04:00
Fix two crashes when deleting FX channels
Lock the mixer before performing a channel delete to prevent any race conditions causing a crash. Also, update the audioport FX channel when an InstrumentTrack's FX channel is changed to prevent the audioport mixing to a nonexistent channel.
This commit is contained in:
@@ -56,7 +56,6 @@ class FxChannel : public ThreadableJob
|
||||
BoolModel m_soloModel;
|
||||
FloatModel m_volumeModel;
|
||||
QString m_name;
|
||||
QMutex m_lock;
|
||||
int m_channelIndex; // what channel index are we
|
||||
bool m_queued; // are we queued up for rendering yet?
|
||||
bool m_muted; // are we muted? updated per period so we don't have to call m_muteModel.value() twice
|
||||
|
||||
@@ -227,6 +227,7 @@ protected slots:
|
||||
void updateBaseNote();
|
||||
void updatePitch();
|
||||
void updatePitchRange();
|
||||
void updateEffectChannel();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -68,7 +68,6 @@ FxChannel::FxChannel( int idx, Model * _parent ) :
|
||||
m_soloModel( false, _parent ),
|
||||
m_volumeModel( 1.0, 0.0, 2.0, 0.001, _parent ),
|
||||
m_name(),
|
||||
m_lock(),
|
||||
m_channelIndex( idx ),
|
||||
m_queued( false ),
|
||||
m_dependenciesMet( 0 )
|
||||
@@ -284,7 +283,8 @@ void FxMixer::toggledSolo()
|
||||
|
||||
void FxMixer::deleteChannel( int index )
|
||||
{
|
||||
m_fxChannels[index]->m_lock.lock();
|
||||
// lock the mixer so channel deletion is performed between mixer rounds
|
||||
Engine::mixer()->lock();
|
||||
|
||||
FxChannel * ch = m_fxChannels[index];
|
||||
|
||||
@@ -344,6 +344,8 @@ void FxMixer::deleteChannel( int index )
|
||||
r->updateName();
|
||||
}
|
||||
}
|
||||
|
||||
Engine::mixer()->unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -543,15 +545,10 @@ FloatModel * FxMixer::channelSendModel( fx_ch_t fromChannel, fx_ch_t toChannel )
|
||||
|
||||
void FxMixer::mixToChannel( const sampleFrame * _buf, fx_ch_t _ch )
|
||||
{
|
||||
// The first check is for the case where the last fxchannel was deleted but
|
||||
// there was a race condition where it had to be processed.
|
||||
if( _ch < m_fxChannels.size() &&
|
||||
m_fxChannels[_ch]->m_muteModel.value() == false )
|
||||
if( m_fxChannels[_ch]->m_muteModel.value() == false )
|
||||
{
|
||||
m_fxChannels[_ch]->m_lock.lock();
|
||||
MixHelpers::add( m_fxChannels[_ch]->m_buffer, _buf, Engine::mixer()->framesPerPeriod() );
|
||||
m_fxChannels[_ch]->m_hasInput = true;
|
||||
m_fxChannels[_ch]->m_lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@ InstrumentTrack::InstrumentTrack( TrackContainer* tc ) :
|
||||
connect( &m_baseNoteModel, SIGNAL( dataChanged() ), this, SLOT( updateBaseNote() ) );
|
||||
connect( &m_pitchModel, SIGNAL( dataChanged() ), this, SLOT( updatePitch() ) );
|
||||
connect( &m_pitchRangeModel, SIGNAL( dataChanged() ), this, SLOT( updatePitchRange() ) );
|
||||
connect( &m_effectChannelModel, SIGNAL( dataChanged() ), this, SLOT( updateEffectChannel() ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -220,8 +221,6 @@ void InstrumentTrack::processAudioBuffer( sampleFrame* buf, const fpp_t frames,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_audioPort.setNextFxChannel( m_effectChannelModel.value() );
|
||||
}
|
||||
|
||||
|
||||
@@ -558,6 +557,14 @@ void InstrumentTrack::updatePitchRange()
|
||||
|
||||
|
||||
|
||||
void InstrumentTrack::updateEffectChannel()
|
||||
{
|
||||
m_audioPort.setNextFxChannel( m_effectChannelModel.value() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int InstrumentTrack::masterKey( int _midi_key ) const
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user