From afd18ea6b14373b2078b6d6dbc74c836e6843757 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 17 May 2024 15:02:57 +0200 Subject: Make sure we don't say some content has audio if none will be emitted. In the FFmpeg (and shortly DCP) case we don't emit any audio if none is mapped, so we must take this into account in the player. --- src/lib/player.cc | 2 +- test/player_test.cc | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/lib/player.cc b/src/lib/player.cc index 91a51c67f..27c89a2fa 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -251,7 +251,7 @@ have_video (shared_ptr content) bool have_audio (shared_ptr content) { - return static_cast(content->audio) && content->can_be_played(); + return static_cast(content->audio) && !content->audio->mapping().mapped_output_channels().empty() && content->can_be_played(); } diff --git a/test/player_test.cc b/test/player_test.cc index 5120c0180..a13b50352 100644 --- a/test/player_test.cc +++ b/test/player_test.cc @@ -30,6 +30,7 @@ #include "lib/butler.h" #include "lib/compose.hpp" #include "lib/config.h" +#include "lib/constants.h" #include "lib/content_factory.h" #include "lib/cross.h" #include "lib/dcp_content.h" @@ -710,3 +711,21 @@ BOOST_AUTO_TEST_CASE(three_d_in_two_d_chooses_left) while (!player->pass()) {} } + +BOOST_AUTO_TEST_CASE(unmapped_audio_does_not_raise_buffer_error) +{ + auto content = content_factory(TestPaths::private_data() / "arrietty_JP-EN.mkv")[0]; + auto film = new_test_film2("unmapped_audio_does_not_raise_buffer_error", { content }); + + content->audio->set_mapping(AudioMapping(6 * 2, MAX_DCP_AUDIO_CHANNELS)); + + Player player(film, Image::Alignment::COMPACT); + Butler butler(film, player, AudioMapping(), 2, bind(PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::PADDED, true, false, Butler::Audio::ENABLED); + + /* Wait for the butler thread to run for a while; in the case under test it will throw an exception because + * the video buffers are filled but no audio comes. + */ + dcpomatic_sleep_seconds(10); + butler.rethrow(); +} + -- cgit v1.2.3