Fix glitchness at the start by not seeking to -ve times.
[dcpomatic.git] / src / lib / audio_buffers.cc
index 403babaf7f84bd4b0ff0974d67a4fb5471b93234..7b3af91e0069324efb4ca69f5e7c41a19ead512a 100644 (file)
@@ -144,6 +144,18 @@ AudioBuffers::make_silent (int c)
        }
 }
 
+void
+AudioBuffers::make_silent (int from, int frames)
+{
+       assert ((from + frames) <= _allocated_frames);
+
+       for (int c = 0; c < _channels; ++c) {
+               for (int i = from; i < (from + frames); ++i) {
+                       _data[c][i] = 0;
+               }
+       }
+}
+
 /** Copy data from another AudioBuffers to this one.  All channels are copied.
  *  @param from AudioBuffers to copy from; must have the same number of channels as this.
  *  @param frames_to_copy Number of frames to copy.
@@ -197,6 +209,7 @@ AudioBuffers::accumulate_channel (AudioBuffers const * from, int from_channel, i
 {
        int const N = frames ();
        assert (from->frames() == N);
+       assert (to_channel <= _channels);
 
        float* s = from->data (from_channel);
        float* d = _data[to_channel];