From 694fa81296e7fc8215f15414bd773354b253e07e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 28 Aug 2015 13:57:43 +0100 Subject: Fix crash on adding a KDM to a DCP (hopefully #645). --- src/lib/audio_decoder.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/lib/audio_decoder.cc') diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index 0d5591072..a65e5f759 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -47,6 +47,29 @@ AudioDecoder::get_audio (AudioStreamPtr stream, Frame frame, Frame length, bool void AudioDecoder::audio (AudioStreamPtr stream, shared_ptr data, ContentTime time) { + 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); } -- cgit v1.2.3