summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-11-03 01:12:10 +0100
committerCarl Hetherington <cth@carlh.net>2025-11-04 20:30:08 +0100
commitd7681f55c3f590e98b6c7eea4bffc5800eadd644 (patch)
treef1b11399dde03b7b3cc898287e0354472a3106a5 /src/lib
parentb3056163b9da4425aab25e3c9630a805a48d30ff (diff)
Fix failure to play any audio when one stream isn't producing anything (#3108)
Without this we consider a never-pushed stream active, but with position 0, so we think we never have any audio ready.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/player.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 985bd3a9c..0b64e5b4e 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -847,9 +847,16 @@ Player::pass()
if (latest_last_push_end != have_pushed.end()) {
LOG_DEBUG_PLAYER("Leading audio stream is in {} at {}", latest_last_push_end->second.piece->content->path(0).string(), to_string(latest_last_push_end->second.last_push_end.get()));
- /* Now make a list of those streams that are less than ignore_streams_behind behind the leader */
+ auto const ignore_threshold = dcpomatic::DCPTime::from_seconds(ignore_streams_behind);
+ auto const leader_time = latest_last_push_end->second.last_push_end.get();
+
+ /* Make a list of those streams that are less than ignore_threshold behind the leader.
+ * If the leader has not yet reached ignore_threshold ahead of a stream's content position
+ * we need to consider its not-yet-pushed streams as active, otherwise we might miss
+ * something from them.
+ */
for (auto const& i: _stream_states) {
- if (!i.second.last_push_end || (latest_last_push_end->second.last_push_end.get() - i.second.last_push_end.get()) < dcpomatic::DCPTime::from_seconds(ignore_streams_behind)) {
+ if ((i.second.last_push_end && (leader_time - i.second.last_push_end.get()) < ignore_threshold) || ((leader_time - i.second.piece->content->position()) < ignore_threshold)) {
alive_stream_states.insert(i);
} else {
LOG_DEBUG_PLAYER("Ignoring stream {} because it is too far behind", i.second.piece->content->path(0).string());