X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Faudio_decoder.cc;h=2944357bac7fe0f279bb8da163915c1e730f65e9;hb=e25bf0c33f4085f6caa3d0d19a083399a422146a;hp=20c8ea1ea812c60b7b33fd62a8d1300fe8c3958d;hpb=0a93237cb5e4642d3b698ff9b7d0cfae5401478c;p=dcpomatic.git diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index 20c8ea1ea..2944357ba 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -20,6 +20,7 @@ #include "audio_decoder.h" #include "audio_buffers.h" #include "audio_decoder_stream.h" +#include "audio_content.h" #include #include @@ -29,8 +30,10 @@ using std::cout; using std::map; using boost::shared_ptr; -AudioDecoder::AudioDecoder (shared_ptr content) +AudioDecoder::AudioDecoder (shared_ptr content, bool fast) : _audio_content (content) + , _ignore_audio (false) + , _fast (fast) { BOOST_FOREACH (AudioStreamPtr i, content->audio_streams ()) { _streams[i] = shared_ptr (new AudioDecoderStream (_audio_content, i, this)); @@ -46,6 +49,33 @@ AudioDecoder::get_audio (AudioStreamPtr stream, Frame frame, Frame length, bool void AudioDecoder::audio (AudioStreamPtr stream, shared_ptr data, ContentTime time) { + if (_ignore_audio) { + return; + } + + if (_streams.find (stream) == _streams.end ()) { + + /* This method can be called with an unknown stream during the following sequence: + - Add KDM to some DCP content. + - Content gets re-examined. + - SingleStreamAudioContent::take_from_audio_examiner creates a new stream. + - Some content property change signal is delivered so Player::Changed is emitted. + - Film viewer to re-gets the frame. + - Player calls DCPDecoder pass which calls this method on the new stream. + + At this point the AudioDecoder does not know about the new stream. + + Then + - Some other property change signal is delivered which marks the player's pieces invalid. + - Film viewer re-gets again. + - Everything is OK. + + In this situation it is fine for us to silently drop the audio. + */ + + return; + } + _streams[stream]->audio (data, time); } @@ -64,3 +94,10 @@ AudioDecoder::seek (ContentTime t, bool accurate) i->second->seek (t, accurate); } } + +/** Set this player never to produce any audio data */ +void +AudioDecoder::set_ignore_audio () +{ + _ignore_audio = true; +}