Hacks.
[dcpomatic.git] / src / lib / silence_decoder.cc
index 9eee5bb108baa495d96ea7c4d3056a228fe32ad3..8cff80ed2a950ae6a9c36eab2c1039bc8657d624 100644 (file)
 #include "audio_buffers.h"
 
 using std::min;
+using std::cout;
 using boost::shared_ptr;
 
 SilenceDecoder::SilenceDecoder (shared_ptr<const Film> f, shared_ptr<NullContent> c)
        : Decoder (f)
-       , AudioDecoder (f, c)
+       , AudioDecoder (f)
+       , _null_content (c)
 {
        
 }
@@ -36,21 +38,15 @@ SilenceDecoder::pass ()
 {
        shared_ptr<const Film> film = _film.lock ();
        assert (film);
-       
-       Time const this_time = min (_audio_content->length() - _next_audio, TIME_HZ / 2);
-       shared_ptr<AudioBuffers> data (new AudioBuffers (MAX_AUDIO_CHANNELS, film->time_to_audio_frames (this_time)));
-       data->make_silent ();
-       audio (data, _next_audio);
-}
 
-void
-SilenceDecoder::seek (Time t)
-{
-       _next_audio = t;
+       AudioContent::Frame const this_time = min (_null_content->audio_length() - _next_audio_frame, int64_t (_null_content->output_audio_frame_rate() / 2));
+       shared_ptr<AudioBuffers> data (new AudioBuffers (film->dcp_audio_channels(), this_time));
+       data->make_silent ();
+       audio (data, _next_audio_frame);
 }
 
-Time
-SilenceDecoder::next () const
+bool
+SilenceDecoder::done () const
 {
-       return _next_audio;
+       return _next_audio_frame > _null_content->audio_length ();
 }