summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-05-04 22:33:30 +0200
committerCarl Hetherington <cth@carlh.net>2021-05-07 09:29:59 +0200
commita1b841185f3d03813db95dc75827d563f23d9dff (patch)
treee1d02e276bbe6ffd200188ce156b05f79f9dfc3e
parenta51b97e3d5f71be906ab92ac3c5dd0c23b84be52 (diff)
Make resampled_audio_to_dcp private.
-rw-r--r--src/lib/piece.cc6
-rw-r--r--src/lib/piece.h2
-rw-r--r--src/lib/piece_audio.h4
-rw-r--r--src/lib/player.cc25
4 files changed, 19 insertions, 18 deletions
diff --git a/src/lib/piece.cc b/src/lib/piece.cc
index 10ae02c1d..b1b4decba 100644
--- a/src/lib/piece.cc
+++ b/src/lib/piece.cc
@@ -132,7 +132,8 @@ Piece::audio (AudioStreamPtr stream, shared_ptr<const AudioBuffers> audio, Frame
_positions[stream] = frame;
}
- Audio (PieceAudio(stream, audio, _positions[stream]));
+ auto const pos = _positions[stream];
+ Audio (PieceAudio(stream, audio, pos, resampled_audio_to_dcp(pos)));
_positions[stream] += audio->frames();
}
@@ -409,7 +410,8 @@ Piece::flush ()
for (auto const& i: _resamplers) {
auto ro = i.second->flush ();
if (ro->frames() > 0) {
- Audio (PieceAudio(i.first, ro, _positions[i.first]));
+ auto const frame = _positions[i.first];
+ Audio (PieceAudio(i.first, ro, frame, resampled_audio_to_dcp(frame)));
_positions[i.first] += ro->frames();
}
}
diff --git a/src/lib/piece.h b/src/lib/piece.h
index 18306a2c9..1d50cb204 100644
--- a/src/lib/piece.h
+++ b/src/lib/piece.h
@@ -53,7 +53,6 @@ public:
void update_pull_to (dcpomatic::DCPTime& pull_to) const;
void set_last_push_end (AudioStreamPtr stream, dcpomatic::DCPTime last_push_end);
- dcpomatic::DCPTime resampled_audio_to_dcp (Frame f) const;
boost::optional<dcpomatic::DCPTime> content_time_to_dcp (std::shared_ptr<const Content> content, dcpomatic::ContentTime t) const;
void pass ();
@@ -111,6 +110,7 @@ private:
dcpomatic::DCPTime content_video_to_dcp (Frame f) const;
dcpomatic::ContentTime dcp_to_content_time (dcpomatic::DCPTime t) const;
+ dcpomatic::DCPTime resampled_audio_to_dcp (Frame f) const;
std::weak_ptr<const Film> _film;
std::shared_ptr<Content> _content;
diff --git a/src/lib/piece_audio.h b/src/lib/piece_audio.h
index a6f345f3e..876591c5b 100644
--- a/src/lib/piece_audio.h
+++ b/src/lib/piece_audio.h
@@ -45,15 +45,17 @@ public:
: audio (new AudioBuffers(0, 0))
{}
- PieceAudio (std::shared_ptr<AudioStream> s, std::shared_ptr<const AudioBuffers> a, Frame f)
+ PieceAudio (std::shared_ptr<AudioStream> s, std::shared_ptr<const AudioBuffers> a, Frame f, dcpomatic::DCPTime t)
: stream (s)
, audio (a)
, frame (f)
+ , time (t)
{}
std::shared_ptr<AudioStream> stream;
std::shared_ptr<const AudioBuffers> audio;
Frame frame = 0;
+ dcpomatic::DCPTime time;
};
diff --git a/src/lib/player.cc b/src/lib/player.cc
index ee0a07411..7a4a9c2c7 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -909,29 +909,26 @@ Player::audio (weak_ptr<Piece> wp, PieceAudio audio)
return;
}
- int const rfr = piece->resampled_audio_frame_rate ();
-
- /* Compute time in the DCP */
- auto time = piece->resampled_audio_to_dcp (audio.frame);
- LOG_DEBUG_PLAYER("Received audio frame %1 at %2", audio.frame, to_string(time));
+ LOG_DEBUG_PLAYER("Received audio frame %1 at %2", audio.frame, to_string(audio.time));
- /* And the end of this block in the DCP */
- auto end = time + DCPTime::from_frames(audio.audio->frames(), rfr);
+ /* The end of this block in the DCP */
+ int const rfr = piece->resampled_audio_frame_rate ();
+ auto end = audio.time + DCPTime::from_frames(audio.audio->frames(), rfr);
/* Remove anything that comes before the start or after the end of the content */
- if (time < piece->position()) {
- auto cut = discard_audio (audio.audio, time, piece->position());
+ if (audio.time < piece->position()) {
+ auto cut = discard_audio (audio.audio, audio.time, piece->position());
if (!cut.first) {
/* This audio is entirely discarded */
return;
}
audio.audio = cut.first;
- time = cut.second;
- } else if (time > piece->end()) {
+ audio.time = cut.second;
+ } else if (audio.time > piece->end()) {
/* Discard it all */
return;
} else if (end > piece->end()) {
- Frame const remaining_frames = DCPTime(piece->end() - time).frames_round(rfr);
+ Frame const remaining_frames = DCPTime(piece->end() - audio.time).frames_round(rfr);
if (remaining_frames == 0) {
return;
}
@@ -960,8 +957,8 @@ Player::audio (weak_ptr<Piece> wp, PieceAudio audio)
/* Push */
- _audio_merger.push (audio.audio, time);
- piece->set_last_push_end (audio.stream, time + DCPTime::from_frames(audio.audio->frames(), _film->audio_frame_rate()));
+ _audio_merger.push (audio.audio, audio.time);
+ piece->set_last_push_end (audio.stream, audio.time + DCPTime::from_frames(audio.audio->frames(), _film->audio_frame_rate()));
}