summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-01-31 22:50:56 +0000
committerCarl Hetherington <cth@carlh.net>2015-01-31 22:50:56 +0000
commit78dd04db5ee5d1aa5fc915f04dc71cb53d33d059 (patch)
treebd09890c512f4516458d3ad56bab13ab25359ded /src/lib
parente520faf63aa7c4446e6e6477553824645d2b1f47 (diff)
If we are requesting audio from before the start of a piece of content we need to adjust both the request position AND the amount, not just the position.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/player.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 5c29efc46..de513ea17 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -436,19 +436,24 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate)
/* The time that we should request from the content */
DCPTime request = time - DCPTime::from_seconds (content->audio_delay() / 1000.0);
+ AudioFrame request_frames = length_frames;
DCPTime offset;
if (request < DCPTime ()) {
/* We went off the start of the content, so we will need to offset
the stuff we get back.
*/
offset = -request;
+ request_frames += request.frames (_film->audio_frame_rate ());
+ if (request_frames < 0) {
+ request_frames = 0;
+ }
request = DCPTime ();
}
AudioFrame const content_frame = dcp_to_content_audio (*i, request);
/* Audio from this piece's decoder (which might be more or less than what we asked for) */
- shared_ptr<ContentAudio> all = decoder->get_audio (content_frame, length_frames, accurate);
+ shared_ptr<ContentAudio> all = decoder->get_audio (content_frame, request_frames, accurate);
/* Gain */
if (content->audio_gain() != 0) {
@@ -480,7 +485,7 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate)
all->audio.get(),
content_frame - all->frame,
offset.frames (_film->audio_frame_rate()),
- min (AudioFrame (all->audio->frames()), length_frames) - offset.frames (_film->audio_frame_rate ())
+ min (AudioFrame (all->audio->frames()), request_frames)
);
}