summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-03-01 11:43:20 +0000
committerCarl Hetherington <cth@carlh.net>2017-04-19 23:04:32 +0100
commitb52491bd55097c343cd8514612d429a55d878be1 (patch)
tree8cc375d8411a0df1933580b6c96465adef4ac134 /src/lib
parentdc78a40b0c7ce4569874fd1e77a86df907937d50 (diff)
Fix crash brought on by previous.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/player.cc14
-rw-r--r--src/lib/player.h2
2 files changed, 12 insertions, 4 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 076bd61bc..035af81fe 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -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(),
diff --git a/src/lib/player.h b/src/lib/player.h
index dd7c5dfa1..6e9c9d7ee 100644
--- a/src/lib/player.h
+++ b/src/lib/player.h
@@ -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);