Fix fill_2d not doing what it is specified to do.
[dcpomatic.git] / src / lib / audio_decoder.cc
index bd9dff8c98a695945e12c5957510ff7da84223a6..31dcf2ef910289899b6776b3bfad4209698822a2 100644 (file)
@@ -22,6 +22,7 @@
 #include "audio_processor.h"
 #include "resampler.h"
 #include "util.h"
+#include <iostream>
 
 #include "i18n.h"
 
@@ -173,6 +174,13 @@ AudioDecoder::audio (shared_ptr<const AudioBuffers> data, ContentTime time)
 void
 AudioDecoder::add (shared_ptr<const AudioBuffers> data)
 {
+       if (!_audio_position) {
+               /* This should only happen when there is a seek followed by a flush, but
+                  we need to cope with it.
+               */
+               return;
+       }
+       
        /* Resize _decoded_audio to fit the new data */
        int new_size = 0;
        if (_decoded_audio.audio->frames() == 0) {