Skip to content

media: Use safe GetDeviceApiLevel helper and API constants in media_codec#11546

Open
borongc wants to merge 1 commit into
youtube:mainfrom
borongc:media_codec_api
Open

media: Use safe GetDeviceApiLevel helper and API constants in media_codec#11546
borongc wants to merge 1 commit into
youtube:mainfrom
borongc:media_codec_api

Conversation

@borongc

@borongc borongc commented Jul 24, 2026

Copy link
Copy Markdown
Member

Replace direct calls to android_get_device_api_level() with a
centralized GetDeviceApiLevel() helper. This wrapper ensures
compatibility by handling potential null function pointers on older
Android versions. Additionally, replace hardcoded API level integers
with named constants to improve code maintainability and clarity.

This was caught in #11544.

Issue: 515461431

@borongc
borongc requested a review from kjyoun July 24, 2026 23:10
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Suggested Commit Message


media: Use GetDeviceApiLevel helper in MediaCodec

Replace direct calls to android_get_device_api_level() with a
centralized GetDeviceApiLevel() helper. This wrapper ensures
compatibility by handling potential null function pointers on older
Android versions. Additionally, replace hardcoded API level integers
with named constants to improve code maintainability and clarity.

Issue: 515461431

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the retrieval of the Android device API level by introducing a centralized GetDeviceApiLevel() helper function and corresponding API level constants in media_common.h, replacing direct calls to android_get_device_api_level() in media_codec.cc. The review feedback suggests explicitly including "starboard/android/shared/media_common.h" in media_codec.cc to adhere to "Include What You Use" (IWYU) guidelines, and using the global namespace qualifier :: for the C system function android_get_device_api_level to prevent potential namespace lookup issues.

Comment thread starboard/android/shared/media_codec.cc
Comment thread starboard/android/shared/media_common.h
@borongc

borongc commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

See #11544 (comment) for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant