Zero 'lost' frames when audio buffer frame counts are dropped.
authorCarl Hetherington <cth@carlh.net>
Thu, 25 Jul 2013 12:23:07 +0000 (13:23 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 25 Jul 2013 12:23:07 +0000 (13:23 +0100)
src/lib/audio_buffers.cc

index 090c0108134d3d17a49af6332f551092f1b43b0f..a15288a3b86c64b66f5567a3f93e7321e6e48279 100644 (file)
@@ -110,13 +110,21 @@ AudioBuffers::data (int c) const
 }
 
 /** Set the number of frames that these AudioBuffers will report themselves
- *  as having.
+ *  as having.  If we reduce the number of frames, the `lost' frames will
+ *  be silenced.
  *  @param f Frames; must be less than or equal to the number of allocated frames.
  */
 void
 AudioBuffers::set_frames (int f)
 {
        assert (f <= _allocated_frames);
+
+       for (int c = 0; c < _channels; ++c) {
+               for (int i = f; i < _frames; ++i) {
+                       _data[c][i] = 0;
+               }
+       }
+       
        _frames = f;
 }