Permalink
Browse files

Prevented segfault when starting with no data channels

  • Loading branch information...
1 parent f549c23 commit 5693792829822c8c0094034cf2452f06b9b8df32 aacuevas committed Nov 21, 2012
Showing with 25 additions and 22 deletions.
  1. +25 −22 Source/Processors/AudioNode.cpp
@@ -166,32 +166,35 @@ void AudioNode::process(AudioSampleBuffer &buffer,
// clear the left and right channels
buffer.clear(0,0,buffer.getNumSamples());
buffer.clear(1,0,buffer.getNumSamples());
-
- for (int i = 2; i < buffer.getNumChannels(); i++)
+
+ if (channelPointers.size() > 0)
{
-
- if (channelPointers[i-2]->isMonitored)
+ for (int i = 2; i < buffer.getNumChannels(); i++)
{
- buffer.addFrom(0, // destination channel
- 0, // destination start sample
- buffer, // source
- i, // source channel
- 0, // source start sample
- buffer.getNumSamples(), // number of samples
- volume // gain to apply
- );
-
- buffer.addFrom(1, // destination channel
- 0, // destination start sample
- buffer, // source
- i, // source channel
- 0, // source start sample
- buffer.getNumSamples(), // number of samples
- volume // gain to apply
- );
- }
+ if (channelPointers[i-2]->isMonitored)
+ {
+ buffer.addFrom(0, // destination channel
+ 0, // destination start sample
+ buffer, // source
+ i, // source channel
+ 0, // source start sample
+ buffer.getNumSamples(), // number of samples
+ volume // gain to apply
+ );
+
+ buffer.addFrom(1, // destination channel
+ 0, // destination start sample
+ buffer, // source
+ i, // source channel
+ 0, // source start sample
+ buffer.getNumSamples(), // number of samples
+ volume // gain to apply
+ );
+
+ }
+ }
}
}

0 comments on commit 5693792

Please sign in to comment.