From 6282cc142f1a8ad1202085b7f900b1db382e4a46 Mon Sep 17 00:00:00 2001 From: cobalt-github-releaser-bot <95661244+cobalt-github-releaser-bot@users.noreply.github.com> Date: Sat, 4 May 2024 00:07:03 -0700 Subject: [PATCH] Cherry pick PR #3090: [android] Filter SbPlayerWriteSampleTest.PartialAudio on audio passthrough (#3165) Refer to the original PR: https://github.com/youtube/cobalt/pull/3090 Filter ac3/eac3 audio files as audio passthrough doesn't support partial audio. b/336339832 Co-authored-by: Bo-Rong Chen --- starboard/nplb/player_test_util.cc | 12 ++++++++++++ starboard/nplb/player_test_util.h | 2 ++ starboard/nplb/player_write_sample_test.cc | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/starboard/nplb/player_test_util.cc b/starboard/nplb/player_test_util.cc index 175d05782134..8b63655f71d7 100644 --- a/starboard/nplb/player_test_util.cc +++ b/starboard/nplb/player_test_util.cc @@ -408,5 +408,17 @@ bool IsPartialAudioSupported() { #endif // SB_API_VERSION >= 15 } +bool IsAudioPassthroughUsed(const SbPlayerTestConfig& config) { + const char* audio_dmp_filename = config.audio_filename; + SbMediaAudioCodec audio_codec = kSbMediaAudioCodecNone; + if (audio_dmp_filename && strlen(audio_dmp_filename) > 0) { + VideoDmpReader audio_dmp_reader(audio_dmp_filename, + VideoDmpReader::kEnableReadOnDemand); + audio_codec = audio_dmp_reader.audio_codec(); + } + return audio_codec == kSbMediaAudioCodecAc3 || + audio_codec == kSbMediaAudioCodecEac3; +} + } // namespace nplb } // namespace starboard diff --git a/starboard/nplb/player_test_util.h b/starboard/nplb/player_test_util.h index 518d43d18709..37ef5b1faabd 100644 --- a/starboard/nplb/player_test_util.h +++ b/starboard/nplb/player_test_util.h @@ -118,6 +118,8 @@ bool IsOutputModeSupported(SbPlayerOutputMode output_mode, bool IsPartialAudioSupported(); +bool IsAudioPassthroughUsed(const SbPlayerTestConfig& config); + } // namespace nplb } // namespace starboard diff --git a/starboard/nplb/player_write_sample_test.cc b/starboard/nplb/player_write_sample_test.cc index b8f1eab83074..f9ac21a8d9b0 100644 --- a/starboard/nplb/player_write_sample_test.cc +++ b/starboard/nplb/player_write_sample_test.cc @@ -161,6 +161,11 @@ TEST_P(SbPlayerWriteSampleTest, PartialAudio) { << "The platform doesn't support partial audio. Skip the tests."; return; } + if (IsAudioPassthroughUsed(GetParam())) { + SB_LOG(INFO) << "The audio passthrough doesn't support partial audio. Skip " + "the tests."; + return; + } SbPlayerTestFixture player_fixture(GetParam(), &fake_graphics_context_provider_); @@ -237,6 +242,11 @@ TEST_P(SbPlayerWriteSampleTest, DiscardAllAudio) { << "The platform doesn't support partial audio. Skip the tests."; return; } + if (IsAudioPassthroughUsed(GetParam())) { + SB_LOG(INFO) << "The audio passthrough doesn't support partial audio. Skip " + "the tests."; + return; + } SbPlayerTestFixture player_fixture(GetParam(), &fake_graphics_context_provider_);