From 824350b6e66ce7ef8a5449b60ce1abb2e4f462a5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 21 Apr 2026 22:26:25 +0200 Subject: Fix bug causing mangled audio analyses in some cases (#3155). The duplicate ID detection was broken due to using the video stream index rather than its ID for checks. --- test/audio_analysis_test.cc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test') diff --git a/test/audio_analysis_test.cc b/test/audio_analysis_test.cc index 8e04945ac..578250b2c 100644 --- a/test/audio_analysis_test.cc +++ b/test/audio_analysis_test.cc @@ -40,6 +40,7 @@ #include "lib/playlist.h" #include "lib/ratio.h" #include "test.h" +#include #include #include @@ -315,3 +316,38 @@ BOOST_AUTO_TEST_CASE(ebur128_test) } #endif + +static bool saw_ffmpeg_error = false; + +static +void +test_log_callback(void*, int level, const char*, va_list) +{ + if (level <= AV_LOG_WARNING) { + saw_ffmpeg_error = true; + } +} + + +/* The file in this test has the audio stream as index 0, video as 1, + * with both streams having the same ID. This triggered a bug where + * on analysis (with video disabled) the video packets would be fed + * to the audio decoder, causing chaos manifesting as many audio decoder + * errors. + */ +BOOST_AUTO_TEST_CASE(analysis_stream_confusion_test) +{ + auto sound = content_factory(TestPaths::private_data() / "ge.mkv")[0]; + auto film = new_test_film("analysis_stream_confusion_test", { sound }); + + av_log_set_callback(test_log_callback); + dcp::ScopeGuard sg = []() { + capture_ffmpeg_logs(); + }; + + auto job = make_shared(film, film->playlist(), true); + JobManager::instance()->add(job); + BOOST_REQUIRE(!wait_for_jobs()); + + BOOST_CHECK(!saw_ffmpeg_error); +} -- cgit v1.2.3