Merge pull request #846 from diizy/stable-1.1

FxMixer: Fix channel delete and other bugs
This commit is contained in:
Tobias Doerffel
2014-06-15 23:31:02 +02:00
3 changed files with 22 additions and 18 deletions

View File

@@ -22,8 +22,8 @@
*
*/
#ifndef _FX_MIXER_H
#define _FX_MIXER_H
#ifndef FX_MIXER_H
#define FX_MIXER_H
#include "Model.h"
#include "Mixer.h"
@@ -140,6 +140,7 @@ private:
// make sure we have at least num channels
void allocateChannelsTo(int num);
QMutex m_sendsMutex;
void addChannelLeaf( int _ch, sampleFrame * _buf );

View File

@@ -394,7 +394,7 @@ float AutomatableModel::fittedValue( float value ) const
void AutomatableModel::linkModel( AutomatableModel* model )
{
if( !m_linkedModels.contains( model ) )
if( !m_linkedModels.contains( model ) && model != this )
{
m_linkedModels.push_back( model );
m_hasLinkedModels = true;
@@ -426,8 +426,8 @@ void AutomatableModel::unlinkModel( AutomatableModel* model )
void AutomatableModel::linkModels( AutomatableModel* model1, AutomatableModel* model2 )
{
model1->linkModel( model2 );
model2->linkModel( model1 );
model1->linkModel( model2 );
model2->linkModel( model1 );
}

View File

@@ -207,13 +207,13 @@ void FxMixer::deleteChannel(int index)
}
// delete all of this channel's sends and receives
for(int i=0; i<m_fxChannels[index]->m_sends.size(); ++i)
while( ! m_fxChannels[index]->m_sends.isEmpty() )
{
deleteChannelSend(index, m_fxChannels[index]->m_sends[i]);
deleteChannelSend( index, m_fxChannels[index]->m_sends.first() );
}
for(int i=0; i<m_fxChannels[index]->m_receives.size(); ++i)
while( ! m_fxChannels[index]->m_receives.isEmpty() )
{
deleteChannelSend(m_fxChannels[index]->m_receives[i], index);
deleteChannelSend( m_fxChannels[index]->m_receives.first(), index );
}
for(int i=0; i<m_fxChannels.size(); ++i)
@@ -252,7 +252,7 @@ void FxMixer::moveChannelLeft(int index)
{
return;
}
m_sendsMutex.lock();
// channels to swap
int a = index - 1, b = index;
@@ -314,6 +314,7 @@ void FxMixer::moveChannelLeft(int index)
FxChannel * tmpChannel = m_fxChannels[a];
m_fxChannels[a] = m_fxChannels[b];
m_fxChannels[b] = tmpChannel;
m_sendsMutex.unlock();
}
@@ -340,7 +341,7 @@ void FxMixer::createChannelSend(fx_ch_t fromChannel, fx_ch_t toChannel,
}
// connection does not exist. create a new one
m_sendsMutex.lock();
// add to from's sends
from->m_sends.push_back(toChannel);
from->m_sendAmount.push_back(new FloatModel(amount, 0, 1, 0.001, NULL,
@@ -348,7 +349,7 @@ void FxMixer::createChannelSend(fx_ch_t fromChannel, fx_ch_t toChannel,
// add to to's receives
m_fxChannels[toChannel]->m_receives.push_back(fromChannel);
m_sendsMutex.unlock();
}
@@ -359,7 +360,7 @@ void FxMixer::deleteChannelSend(fx_ch_t fromChannel, fx_ch_t toChannel)
// delete the send
FxChannel * from = m_fxChannels[fromChannel];
FxChannel * to = m_fxChannels[toChannel];
m_sendsMutex.lock();
// find and delete the send entry
for(int i=0; i<from->m_sends.size(); ++i) {
if( from->m_sends[i] == toChannel )
@@ -382,6 +383,7 @@ void FxMixer::deleteChannelSend(fx_ch_t fromChannel, fx_ch_t toChannel)
break;
}
}
m_sendsMutex.unlock();
}
@@ -480,6 +482,7 @@ void FxMixer::masterMix( sampleFrame * _buf )
// and add all channels to job list that have no dependencies
// when the channel completes it will check its parent to see if it needs
// to be processed.
m_sendsMutex.lock();
MixerWorkerThread::resetJobQueue( MixerWorkerThread::JobQueue::Dynamic );
addChannelLeaf( 0, _buf );
while( m_fxChannels[0]->state() != ThreadableJob::Done )
@@ -487,6 +490,7 @@ void FxMixer::masterMix( sampleFrame * _buf )
MixerWorkerThread::startAndWaitForJobs();
}
//m_fxChannels[0]->doProcessing( NULL );
m_sendsMutex.unlock();
const float v = m_fxChannels[0]->m_volumeModel.value();
MixHelpers::addMultiplied( _buf, m_fxChannels[0]->m_buffer, v, fpp );
@@ -534,9 +538,9 @@ void FxMixer::clearChannel(fx_ch_t index)
if( index > 0)
{
// delete existing sends
for( int i=0; i<ch->m_sends.size(); ++i)
while( ! ch->m_sends.isEmpty() )
{
deleteChannelSend(index, ch->m_sends[i]);
deleteChannelSend( index, ch->m_sends.first() );
}
// add send to master
@@ -544,11 +548,10 @@ void FxMixer::clearChannel(fx_ch_t index)
}
// delete receives
for( int i=0; i<ch->m_receives.size(); ++i)
while( ! ch->m_receives.isEmpty() )
{
deleteChannelSend(ch->m_receives[i], index);
deleteChannelSend( ch->m_receives.first(), index );
}
}
void FxMixer::saveSettings( QDomDocument & _doc, QDomElement & _this )