Fix crash on adding a KDM to a DCP (hopefully #645).
authorCarl Hetherington <cth@carlh.net>
Fri, 28 Aug 2015 12:57:43 +0000 (13:57 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 28 Aug 2015 12:57:43 +0000 (13:57 +0100)
ChangeLog
src/lib/audio_decoder.cc

index cc9b6c36f9d31b35d9d3b3bee2d21cfed1fc99f7..474062cf44041e4002604640846f68968dd76b11 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-08-28  c.hetherington  <cth@carlh.net>
+
+       * Fix crash on adding a KDM to DCP content
+       (hopefully fixing #645).
+
 2015-08-27  Carl Hetherington  <cth@carlh.net>
 
        * Tidy up DCP content colour conversion
index 0d5591072b69d2c121c992c1bcb18c8cbab5171b..a65e5f7594eaf804bcd6b140293ac303e8dcead0 100644 (file)
@@ -47,6 +47,29 @@ AudioDecoder::get_audio (AudioStreamPtr stream, Frame frame, Frame length, bool
 void
 AudioDecoder::audio (AudioStreamPtr stream, shared_ptr<const AudioBuffers> 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);
 }