Fix crash brought on by previous.
authorCarl Hetherington <cth@carlh.net>
Wed, 1 Mar 2017 11:43:20 +0000 (11:43 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 19 Apr 2017 22:04:32 +0000 (23:04 +0100)
src/lib/player.cc
src/lib/player.h

index 076bd61bcee9e597d00577dde33c6d3af6fa58a3..035af81feba6215ee61a52eac3fa453f3fa205f8 100644 (file)
@@ -679,7 +679,11 @@ Player::audio_flush (shared_ptr<Piece> piece, AudioStreamPtr stream)
        shared_ptr<AudioContent> content = piece->content->audio;
        DCPOMATIC_ASSERT (content);
 
-       shared_ptr<Resampler> r = resampler (content, stream);
+       shared_ptr<Resampler> r = resampler (content, stream, false);
+       if (!r) {
+               return;
+       }
+
        pair<shared_ptr<const AudioBuffers>, Frame> ro = r->flush ();
        ContentAudio content_audio;
        content_audio.audio = ro.first;
@@ -750,7 +754,7 @@ Player::audio (weak_ptr<Piece> wp, AudioStreamPtr stream, ContentAudio content_a
 
        /* Resample */
        if (stream->frame_rate() != content->resampled_frame_rate()) {
-               shared_ptr<Resampler> r = resampler (content, stream);
+               shared_ptr<Resampler> r = resampler (content, stream, true);
                pair<shared_ptr<const AudioBuffers>, Frame> ro = r->run (content_audio.audio, content_audio.frame);
                content_audio.audio = ro.first;
                content_audio.frame = ro.second;
@@ -876,13 +880,17 @@ Player::seek (DCPTime time, bool accurate)
 }
 
 shared_ptr<Resampler>
-Player::resampler (shared_ptr<const AudioContent> content, AudioStreamPtr stream)
+Player::resampler (shared_ptr<const AudioContent> content, AudioStreamPtr stream, bool create)
 {
        ResamplerMap::const_iterator i = _resamplers.find (make_pair (content, stream));
        if (i != _resamplers.end ()) {
                return i->second;
        }
 
+       if (!create) {
+               return shared_ptr<Resampler> ();
+       }
+
        LOG_GENERAL (
                "Creating new resampler from %1 to %2 with %3 channels",
                stream->frame_rate(),
index dd7c5dfa15584ef32568a5b3ff0f9f3aea059b9e..6e9c9d7ee32f243e46db45c5b6c48b0deab00342 100644 (file)
@@ -106,7 +106,7 @@ private:
        void audio (boost::weak_ptr<Piece>, AudioStreamPtr, ContentAudio);
        void image_subtitle (boost::weak_ptr<Piece>, ContentImageSubtitle);
        void text_subtitle (boost::weak_ptr<Piece>, ContentTextSubtitle);
-       boost::shared_ptr<Resampler> resampler (boost::shared_ptr<const AudioContent> content, AudioStreamPtr stream);
+       boost::shared_ptr<Resampler> resampler (boost::shared_ptr<const AudioContent> content, AudioStreamPtr stream, bool create);
        DCPTime one_video_frame () const;
        void fill_video (DCPTimePeriod period);
        void fill_audio (DCPTimePeriod period);