Skip to content

Commit

Permalink
[media] Fix build failures for DecoderBufferAllocator (#4408)
Browse files Browse the repository at this point in the history
Fix failing to build Cobalt.apk when `use_starboard_media=false`.

b/374822966
  • Loading branch information
borongc authored Nov 11, 2024
1 parent 819f56c commit bac5768
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
29 changes: 19 additions & 10 deletions media/starboard/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]

Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions media/starboard/starboard_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit bac5768

Please sign in to comment.