dcp_trim -> trim
[dcpomatic.git] / src / lib / external_audio_decoder.cc
index 29668d922836fc5ceea9100d28e041690a4a7cd4..36605141886aed7ec596bb024b0425bfedc23f94 100644 (file)
@@ -17,6 +17,7 @@
 
 */
 
+#include <iostream>
 #include <sndfile.h>
 #include "external_audio_decoder.h"
 #include "film.h"
@@ -30,7 +31,7 @@ using std::cout;
 using boost::shared_ptr;
 using boost::optional;
 
-ExternalAudioDecoder::ExternalAudioDecoder (shared_ptr<Film> f, shared_ptr<const Options> o, Job* j)
+ExternalAudioDecoder::ExternalAudioDecoder (shared_ptr<Film> f, DecodeOptions o, Job* j)
        : Decoder (f, o, j)
        , AudioDecoder (f, o, j)
 {
@@ -106,9 +107,10 @@ ExternalAudioDecoder::pass ()
                return true;
        }
 
-       sf_count_t const block = 65536;
-
-       cout << frames << " audio frames.\n";
+       /* Do things in half second blocks as I think there may be limits
+          to what FFmpeg (and in particular the resampler) can cope with.
+       */
+       sf_count_t const block = _audio_stream->sample_rate() / 2;
 
        shared_ptr<AudioBuffers> audio (new AudioBuffers (_audio_stream->channels(), block));
        while (frames > 0) {
@@ -121,6 +123,7 @@ ExternalAudioDecoder::pass ()
                        }
                }
 
+               audio->set_frames (this_time);
                Audio (audio);
                frames -= this_time;
        }