Am 20.06.2010 20:00, schrieb Stefan Fendt:
> OK, ... the segfault with the send-value is still there... it sometimes
> works and sometimes crashes badly... :(
>   

OK, this one works without the "mysterious" segfault... (see comments or
make a diff of the diff).

I hope it works not only for me... ;-), so have fun with it...
Stefan

diff --git a/include/FxMixer.h b/include/FxMixer.h
index 660d2ea..6b47d2c 100644
--- a/include/FxMixer.h
+++ b/include/FxMixer.h
@@ -63,7 +63,7 @@ class FxChannel : public ThreadableJob
 
 		virtual bool requiresProcessing() const { return true; }
 
-	private:
+//	private:
 		virtual void doProcessing( sampleFrame * _working_buffer );
 };
 
diff --git a/src/core/FxMixer.cpp b/src/core/FxMixer.cpp
index ce43d71..308c162 100644
--- a/src/core/FxMixer.cpp
+++ b/src/core/FxMixer.cpp
@@ -59,6 +59,7 @@ FxChannel::~FxChannel()
 }
 
 
+#include <iostream>
 
 void FxChannel::doProcessing( sampleFrame * _buf )
 {
@@ -74,6 +75,15 @@ void FxChannel::doProcessing( sampleFrame * _buf )
 	// <tobydox> this improves cache hit rate
 	_buf = m_buffer;
 
+  // SMF: OK, due to the fact, that the data from the audio-tracks has been 
+  //      written into our buffer already, all which needs to be done at this
+  //      stage is to process inter-channel sends. I really don't like the idea
+  //      of using threads for this -- it just doesn't make any sense and wastes
+  //      cpu-cylces... so I just go through every child of this channel and
+  //      call the acc. doProcessing() directly. 
+
+  // Take the old code out of business without erasing it, just for now...
+  #if 0
 	if( ! m_muteModel.value() )
 	{
 		// do mixer sends. loop through the channels that send to this one
@@ -82,6 +92,9 @@ void FxChannel::doProcessing( sampleFrame * _buf )
 			fx_ch_t senderIndex = m_receives[i];
 			FxChannel * sender = fxm->effectChannel(senderIndex);
 
+      std::cerr << "channel: " << m_name.toStdString();
+      std::cerr << " input:" << sender->m_name.toStdString() << "\n";
+
 			// mix it with this one
 			float amt = fxm->channelSendModel(senderIndex,
 											  m_channelIndex)->value();
@@ -126,7 +139,49 @@ void FxChannel::doProcessing( sampleFrame * _buf )
 			}
 		}
 	}
+#else
+  // the new code ... this does not click any more...
+
+	if( ! m_muteModel.value() )
+	{
+    // OK, we are not muted, so we go recursively through all the channels 
+    // which send to us (our "childs")...
+		for( int i = 0; i < m_receives.size(); ++i)
+		{
+      // we must assume that these are _not_ ready, already, so we trigger their
+      // doProcessing from here...
+
+			fx_ch_t senderIndex = m_receives[i];
+			FxChannel * sender = fxm->effectChannel(senderIndex);
+
+      // run that channels doProcessing() if it was not run before...
+      if( sender->m_state != ThreadableJob::Done )
+      {
+        sender->doProcessing( NULL );
+      }
+
+      // get the send-level...
+      float amt = 1.0;
+      if( (int)m_channelIndex >=0 ) // how can our own channel index get negative?
+        amt = fxm->channelSendModel(senderIndex, m_channelIndex)->value();
+      
+			// mix it's output with this one's output 
+			CPU::bufMixCoeff( _buf, sender->m_buffer,
+								sender->m_volumeModel.value() * amt, fpp );
+    }
+  }
+
+	const float v = m_volumeModel.value();
 
+	m_fxChain.startRunning();
+	m_stillRunning = m_fxChain.processAudioBuffer( _buf, fpp );
+	m_peakLeft = engine::getMixer()->peakValueLeft( _buf, fpp ) * v;
+	m_peakRight = engine::getMixer()->peakValueRight( _buf, fpp ) * v;
+
+  // Ok, we do not really use threads here... but the flag is fine... ;-)
+  m_state = ThreadableJob::Done;
+
+#endif
 }
 
 
@@ -418,6 +473,15 @@ FloatModel * FxMixer::channelSendModel(fx_ch_t fromChannel, fx_ch_t toChannel)
 
 void FxMixer::mixToChannel( const sampleFrame * _buf, fx_ch_t _ch )
 {
+  // SMF: it seems like here the track-channels are mixed in... but from where
+  //      is this called and when and why...?!?
+  //
+  //      OK, found it (git grep is your friend...): This is the next part, 
+  //      where there is a mix between push and pull model inside the core, as
+  //      the audio-tracks *push* their data into the fx-channels hopefully just
+  //      before the Mixer-Channels are processed... Sorry to say this: but this
+  //      took me senseless hours to find out and is silly, too...
+
 	if( m_fxChannels[_ch]->m_muteModel.value() == false )
 	{
 		m_fxChannels[_ch]->m_lock.lock();
@@ -476,12 +540,27 @@ 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.
+
+  #if 0
 	MixerWorkerThread::resetJobQueue( MixerWorkerThread::JobQueue::Dynamic );
 	addChannelLeaf( 0, _buf );
 	while( m_fxChannels[0]->state() != ThreadableJob::Done )
 	{
 		MixerWorkerThread::startAndWaitForJobs();
 	}
+  #else
+  // SMF: unlike before just trigger the first channel (Master)...
+  //      the "mysterious" segfault happened due to the fact that the old code
+  //      did tell the channels their respective channel-Nr. while I didn't ...
+  //      I silently assumed this were handled by add and delete Channel methods
+  //      but this was not the case, so m_channelIndex was -1 for all channels
+  //      other than master... OK, so we tell them here...
+  for(int n=0; n<m_fxChannels.size(); n++)
+  {
+    m_fxChannels[n]->m_channelIndex = n;
+  }
+  m_fxChannels[0]->doProcessing( NULL );
+  #endif
 
 	memcpy( _buf, m_fxChannels[0]->m_buffer, sizeof( sampleFrame ) * fpp );
 
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
LMMS-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lmms-devel

Reply via email to