From bac5768c4f5db109e5c32279380530698388de9d Mon Sep 17 00:00:00 2001 From: Bo-Rong Chen Date: Mon, 11 Nov 2024 12:21:57 -0800 Subject: [PATCH] [media] Fix build failures for DecoderBufferAllocator (#4408) Fix failing to build Cobalt.apk when `use_starboard_media=false`. b/374822966 --- media/starboard/BUILD.gn | 29 +++++++++++++++++++---------- media/starboard/starboard_utils.cc | 5 +++++ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/media/starboard/BUILD.gn b/media/starboard/BUILD.gn index c4be5d83006a7..a85aadd9c72da 100644 --- a/media/starboard/BUILD.gn +++ b/media/starboard/BUILD.gn @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +if (is_cobalt) { + import("//starboard/build/buildflags.gni") +} + source_set("starboard") { visibility = [ "//media" ] @@ -54,24 +58,29 @@ source_set("starboard") { ] sources = [ - "bidirectional_fit_reuse_allocator.cc", - "bidirectional_fit_reuse_allocator.h", - "decoder_buffer_allocator.cc", - "decoder_buffer_allocator.h", - "decoder_buffer_memory_info.h", "sbplayer_bridge.cc", "sbplayer_bridge.h", "sbplayer_interface.cc", "sbplayer_interface.h", "sbplayer_set_bounds_helper.cc", "sbplayer_set_bounds_helper.h", - "starboard_memory_allocator.h", "starboard_renderer.cc", "starboard_renderer.h", "starboard_utils.cc", "starboard_utils.h", ] + if (is_cobalt && use_starboard_media) { + sources += [ + "bidirectional_fit_reuse_allocator.cc", + "bidirectional_fit_reuse_allocator.h", + "decoder_buffer_allocator.cc", + "decoder_buffer_allocator.h", + "decoder_buffer_memory_info.h", + "starboard_memory_allocator.h", + ] + } + deps = [ "//base", "//media:media_buildflags", @@ -85,10 +94,10 @@ source_set("starboard") { source_set("unit_tests") { testonly = true - sources = [ - "bidirectional_fit_reuse_allocator_test.cc", - "starboard_utils_test.cc", - ] + sources = [ "starboard_utils_test.cc" ] + if (is_cobalt && use_starboard_media) { + sources += [ "bidirectional_fit_reuse_allocator_test.cc" ] + } configs += [ "//media:media_config" ] deps = [ "//base", diff --git a/media/starboard/starboard_utils.cc b/media/starboard/starboard_utils.cc index f287fbdf16866..56495224d212c 100644 --- a/media/starboard/starboard_utils.cc +++ b/media/starboard/starboard_utils.cc @@ -363,6 +363,7 @@ SbMediaColorMetadata MediaToSbMediaColorMetadata( } int GetSbMediaVideoBufferBudget(const VideoDecoderConfig* video_config, const std::string& mime_type) { +#if BUILDFLAG(USE_STARBOARD_MEDIA) if (!video_config) { return DecoderBuffer::Allocator::GetInstance()->GetVideoBufferBudget( kSbMediaVideoCodecH264, 1920, 1080, 8); @@ -374,6 +375,10 @@ int GetSbMediaVideoBufferBudget(const VideoDecoderConfig* video_config, auto codec = MediaVideoCodecToSbMediaVideoCodec(video_config->codec()); return DecoderBuffer::Allocator::GetInstance()->GetVideoBufferBudget( codec, width, height, bits_per_pixel); +#else // BUILDFLAG(USE_STARBOARD_MEDIA) + NOTREACHED(); + return 0; +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) } std::string ExtractCodecs(const std::string& mime_type) {