Various fixes to make audio analysis sort-of work.
[dcpomatic.git] / src / lib / audio_buffers.cc
index c3e89f1302e5315e01495c374a994975b19b806b..403babaf7f84bd4b0ff0974d67a4fb5471b93234 100644 (file)
@@ -206,6 +206,9 @@ AudioBuffers::accumulate_channel (AudioBuffers const * from, int from_channel, i
        }
 }
 
+/** Ensure we have space for at least a certain number of frames.  If we extend
+ *  the buffers, fill the new space with silence.
+ */
 void
 AudioBuffers::ensure_size (int frames)
 {
@@ -218,6 +221,9 @@ AudioBuffers::ensure_size (int frames)
                if (!_data[i]) {
                        throw bad_alloc ();
                }
+               for (int j = _allocated_frames; j < frames; ++j) {
+                       _data[i][j] = 0;
+               }
        }
 
        _allocated_frames = frames;