Various fixes to make audio analysis sort-of work.
[dcpomatic.git] / src / lib / audio_decoder.cc
index 9b8d15bf163927c69cbe201e5c7427825013db76..a9e01908c4782a6095821d080800b0568ce71214 100644 (file)
@@ -27,6 +27,7 @@
 using std::stringstream;
 using std::list;
 using std::pair;
+using std::cout;
 using boost::optional;
 using boost::shared_ptr;
 
@@ -58,10 +59,10 @@ AudioDecoder::AudioDecoder (shared_ptr<const Film> f, shared_ptr<const AudioCont
 
                _swr_context = swr_alloc_set_opts (
                        0,
-                       av_get_default_channel_layout (MAX_AUDIO_CHANNELS),
+                       av_get_default_channel_layout (_audio_content->audio_channels ()),
                        AV_SAMPLE_FMT_FLTP,
                        _audio_content->output_audio_frame_rate(),
-                       av_get_default_channel_layout (MAX_AUDIO_CHANNELS),
+                       av_get_default_channel_layout (_audio_content->audio_channels ()),
                        AV_SAMPLE_FMT_FLTP,
                        _audio_content->content_audio_frame_rate(),
                        0, 0
@@ -154,4 +155,12 @@ AudioDecoder::audio (shared_ptr<const AudioBuffers> data, Time time)
        _next_audio = time + film->audio_frames_to_time (data->frames());
 }
 
-               
+bool
+AudioDecoder::audio_done () const
+{
+       shared_ptr<const Film> film = _film.lock ();
+       assert (film);
+       
+       return (_audio_content->length() - _next_audio) < film->audio_frames_to_time (1);
+}
+