Skip to content

media: Enable MediaCodec flush for Android 14+#11544

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

media: Enable MediaCodec flush for Android 14+#11544
borongc wants to merge 1 commit into
youtube:mainfrom
borongc:flush_atv_14

Conversation

@borongc

@borongc borongc commented Jul 24, 2026

Copy link
Copy Markdown
Member

Enable MediaCodec flushing during seeks and audio decoder resets by
default on devices running Android 14 (API level 34) or higher. This
ensures more reliable playback behavior on newer Android versions
without needing manual flag overrides.

Issue: 490100851
Issue: 532404997

@borongc
borongc requested review from a team, at-ninja and jasonzhangxx July 24, 2026 22:40

@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 updates the player components factory for Android to enable features like flushing during seek and resetting the audio decoder on devices running API level 34 (Android 14) or higher. The review feedback points out that directly calling android_get_device_api_level() can cause runtime crashes on older Android devices (API < 24) where the symbol is weak and may resolve to nullptr. To address this, the reviewer recommends introducing a safe helper function to check for null pointers and replacing the magic number 34 with a named constant, in line with the Chromium style guide.

Comment thread starboard/android/shared/player_components_factory.cc Outdated
Comment thread starboard/android/shared/player_components_factory.cc Outdated
Comment thread starboard/android/shared/player_components_factory.cc Outdated
Comment thread starboard/android/shared/player_components_factory.cc Outdated
Comment thread starboard/android/shared/player_components_factory.cc Outdated
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Suggested Commit Message


media: Enable MediaCodec flush for Android 14+

Enable MediaCodec flushing during seeks and audio decoder resets by
default on devices running Android 14 (API level 34) or higher. This
ensures more reliable playback behavior on newer Android versions
without needing manual flag overrides.

Issue: 490100851
Issue: 532404997

💡 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

@borongc borongc changed the title media: Enable Flush MeaidCodec on ATV14+ media: Enable MediaCodec flush for Android 14+ Jul 24, 2026
@borongc

borongc commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@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 introduces a helper function GetDeviceApiLevel() to retrieve the Android API level and uses it to conditionally enable features like flushing during seek and resetting the audio decoder on Android U (API level 34) or higher. The review feedback suggests improving the robustness of GetDeviceApiLevel() on older Android versions (API < 24) by using __system_property_get as a fallback instead of relying on weak linking of android_get_device_api_level, which also requires including <sys/system_properties.h> and <cstdlib>.

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

borongc commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@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 introduces a helper function GetDeviceApiLevel() in media_common.h and uses it in player_components_factory.cc to automatically enable features like enable_flush_during_seek and enable_reset_audio_decoder on devices running Android U or higher. The review feedback suggests removing the unused kAndroidApiLevelPie constant and using std::atoi instead of atoi to align with standard C++ practices.

Comment thread starboard/android/shared/media_common.h Outdated
Comment thread starboard/android/shared/media_common.h Outdated
@borongc

borongc commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@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 introduces a helper function GetDeviceApiLevel() in media_common.h to determine the Android API level of the device. It then uses this function in player_components_factory.cc to automatically enable certain media features, such as flushing during seek and resetting the audio decoder, on devices running Android U (API level 34) or higher. There are no review comments, so I have no feedback to provide.

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