Potential fix for #1568; we calculate the remaining DCPTime but
authorCarl Hetherington <cth@carlh.net>
Sun, 26 May 2019 01:58:17 +0000 (02:58 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 26 May 2019 01:58:17 +0000 (02:58 +0100)
then convert it back to resampled content frames using the DCP
rate rather than the resampled content rate, which seems wrong.

If we want to go from metric time to frames we surely have to use
the frame rate of the thing we are working with (not the frame rate
which that thing will be played back at).

src/lib/player.cc

index f79e379d245d9c8aa3c904c0a2ece29b71993352..6f0cfd1af7e9490f216b2d243742b86d081badb5 100644 (file)
@@ -855,10 +855,12 @@ Player::audio (weak_ptr<Piece> wp, AudioStreamPtr stream, ContentAudio content_a
        shared_ptr<AudioContent> content = piece->content->audio;
        DCPOMATIC_ASSERT (content);
 
        shared_ptr<AudioContent> content = piece->content->audio;
        DCPOMATIC_ASSERT (content);
 
+       int const rfr = content->resampled_frame_rate (_film);
+
        /* Compute time in the DCP */
        DCPTime time = resampled_audio_to_dcp (piece, content_audio.frame);
        /* And the end of this block in the DCP */
        /* Compute time in the DCP */
        DCPTime time = resampled_audio_to_dcp (piece, content_audio.frame);
        /* And the end of this block in the DCP */
-       DCPTime end = time + DCPTime::from_frames(content_audio.audio->frames(), content->resampled_frame_rate(_film));
+       DCPTime end = time + DCPTime::from_frames(content_audio.audio->frames(), rfr);
 
        /* Remove anything that comes before the start or after the end of the content */
        if (time < piece->content->position()) {
 
        /* Remove anything that comes before the start or after the end of the content */
        if (time < piece->content->position()) {
@@ -873,7 +875,7 @@ Player::audio (weak_ptr<Piece> wp, AudioStreamPtr stream, ContentAudio content_a
                /* Discard it all */
                return;
        } else if (end > piece->content->end(_film)) {
                /* Discard it all */
                return;
        } else if (end > piece->content->end(_film)) {
-               Frame const remaining_frames = DCPTime(piece->content->end(_film) - time).frames_round(_film->audio_frame_rate());
+               Frame const remaining_frames = DCPTime(piece->content->end(_film) - time).frames_round(rfr);
                if (remaining_frames == 0) {
                        return;
                }
                if (remaining_frames == 0) {
                        return;
                }