Fixed the audio/visual screwups

With the help of Toby, effects in the channels work and the peak
displays correctly. However the freeze-up bug is still wreaking havoc.
This commit is contained in:
Andrew Kelley
2009-10-13 02:21:13 -07:00
parent f6f4414c98
commit 95eb60f05f
3 changed files with 28 additions and 9 deletions

View File

@@ -52,6 +52,7 @@ class FxChannel : public ThreadableJob
QString m_name;
QMutex m_lock;
int m_channelIndex; // what channel index are we
bool m_queued; // are we queued up for rendering yet?
// pointers to other channels that this one sends to
QVector<fx_ch_t> m_sends;

View File

@@ -569,11 +569,16 @@ public:
}
}
template<typename T>
static void fillJobQueue( const T & _vec )
static void resetJobQueue()
{
s_jobQueue.queueSize = 0;
s_jobQueue.itemsDone = 0;
}
template<typename T>
static void fillJobQueue( const T & _vec )
{
resetJobQueue();
for( typename T::ConstIterator it = _vec.begin(); it != _vec.end(); ++it )
{
addJob( *it );

View File

@@ -43,7 +43,8 @@ FxChannel::FxChannel( Model * _parent ) :
m_muteModel( false, _parent ),
m_volumeModel( 1.0, 0.0, 2.0, 0.01, _parent ),
m_name(),
m_lock()
m_lock(),
m_queued( false )
{
engine::getMixer()->clearAudioBuffer( m_buffer,
engine::getMixer()->framesPerPeriod() );
@@ -62,12 +63,16 @@ FxChannel::~FxChannel()
void FxChannel::doProcessing(sampleFrame * _buf)
{
FxMixer * fxm = engine::fxMixer();
const fpp_t fpp = engine::getMixer()->framesPerPeriod();
if( _buf == NULL )
{
_buf = m_buffer;
}
// <tobydox> ignore the passed _buf
// <tobydox> always use m_buffer
// <tobydox> this is just an auxilliary buffer if doProcessing()
// needs one for processing while running
// <tobydox> particularly important for playHandles, so Instruments
// can operate on this buffer the whole time
// <tobydox> this improves cache hit rate
_buf = m_buffer;
if( ! m_muteModel.value() )
{
@@ -454,6 +459,10 @@ void FxMixer::addChannelLeaf( int _ch, sampleFrame * _buf )
// remember what channel number we are, 'cause we need it later
thisCh->m_channelIndex = _ch;
// if we're muted or this channel is seen already, discount it
if( thisCh->m_muteModel.value() || thisCh->m_queued )
return;
int numDeps = thisCh->m_receives.size();
if( numDeps > 0 )
{
@@ -465,6 +474,7 @@ void FxMixer::addChannelLeaf( int _ch, sampleFrame * _buf )
else
{
// add this channel to job list
thisCh->m_queued = true;
MixerWorkerThread::addJob( thisCh );
}
@@ -475,15 +485,17 @@ void FxMixer::addChannelLeaf( int _ch, sampleFrame * _buf )
void FxMixer::masterMix( sampleFrame * _buf )
{
const int fpp = engine::getMixer()->framesPerPeriod();
memcpy( _buf, m_fxChannels[0]->m_buffer, sizeof( sampleFrame ) * fpp );
// recursively loop through channel dependency chain
// 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.
MixerWorkerThread::resetJobQueue();
addChannelLeaf( 0, _buf );
MixerWorkerThread::startAndWaitForJobs();
memcpy( _buf, m_fxChannels[0]->m_buffer, sizeof( sampleFrame ) * fpp );
const float v = m_fxChannels[0]->m_volumeModel.value();
for( f_cnt_t f = 0; f < engine::getMixer()->framesPerPeriod(); ++f )
{
@@ -501,6 +513,7 @@ void FxMixer::masterMix( sampleFrame * _buf )
engine::getMixer()->clearAudioBuffer( m_fxChannels[i]->m_buffer,
engine::getMixer()->framesPerPeriod() );
m_fxChannels[i]->reset();
m_fxChannels[i]->m_queued = false;
}
}