diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-11-03 01:12:10 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-11-04 20:30:08 +0100 |
| commit | d7681f55c3f590e98b6c7eea4bffc5800eadd644 (patch) | |
| tree | f1b11399dde03b7b3cc898287e0354472a3106a5 | |
| parent | b3056163b9da4425aab25e3c9630a805a48d30ff (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.
| -rw-r--r-- | src/lib/player.cc | 11 | ||||
| -rw-r--r-- | test/player_test.cc | 15 |
2 files changed, 24 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()); diff --git a/test/player_test.cc b/test/player_test.cc index 7fc21ac36..d20a91020 100644 --- a/test/player_test.cc +++ b/test/player_test.cc @@ -25,6 +25,7 @@ */ +#include "lib/analyse_audio_job.h" #include "lib/audio_buffers.h" #include "lib/audio_content.h" #include "lib/butler.h" @@ -39,6 +40,7 @@ #include "lib/film.h" #include "lib/image_content.h" #include "lib/image_png.h" +#include "lib/job_manager.h" #include "lib/player.h" #include "lib/ratio.h" #include "lib/string_text_file_content.h" @@ -756,3 +758,16 @@ BOOST_AUTO_TEST_CASE(frames_are_copied_correctly_for_low_frame_rates) } } } + + +BOOST_AUTO_TEST_CASE(test_with_audio_stream_that_never_emits_anything) +{ + auto content = content_factory(TestPaths::private_data() / "hunter.mkv"); + auto film = new_test_film("test_with_audio_stream_that_never_emits_anything", content); + + /* Check that the analysis of this file does not fail */ + auto job = make_shared<AnalyseAudioJob>(film, film->playlist(), true); + JobManager::instance()->add(job); + BOOST_REQUIRE(!wait_for_jobs()); +} + |
