Skip to content

feat(android): add a 'game' output profile - #1556

Open
HuntedCode wants to merge 1 commit into
software-mansion:mainfrom
HuntedCode:feat/android-game-output-profile
Open

HuntedCode wants to merge 1 commit into
software-mansion:mainfrom
HuntedCode:feat/android-game-output-profile

Conversation

@HuntedCode

@HuntedCode HuntedCode commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1554

⚠️ Breaking changes ⚠️

  • None. 'media' stays the default and is unchanged.

Introduced changes

  • androidOutputProfile accepts 'game', which opens the output stream with Oboe's Usage::Game. The content type stays Oboe's default, as for 'media'.
  • The profile check in AndroidAudioPlayer::openAudioStreamLocked becomes a switch, so the compiler points out a profile added later without a case.
  • The stream still follows the media volume. Below Android 9 nothing changes, because AAudio takes a usage only from API 28 and OpenSL ES maps a game's audio to media. The docs say so.
  • The example app's list of output profiles gains game.

Testing

  • The existing Jest test for forwarding the option now covers both 'game' and 'voiceCommunication'.
  • Typecheck of the library, oxfmt and clang-format pass. Both changed .cpp files compile with NDK 27 (arm64, syntax only). I could not build the example app on Windows, so this relies on CI for the full native build.
  • On an Android phone I ran the same setUsage(Usage::Game) call as a patch on 0.13.6, not this branch: dumpsys audio reports the stream as USAGE_GAME instead of USAGE_MEDIA, and the media volume still controls it.

Checklist

  • Linked relevant issue
  • Targets the right branch (release/X.Y only for fixes to the released version)
  • Updated relevant documentation
  • Added/Conducted relevant tests
  • Performed self-review of the code
  • Updated Web Audio API coverage (not applicable)
  • Added support for web (not applicable, Android only)
  • Updated old arch android spec file (not applicable)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added the game option for Android audio output profiles, allowing audio to be identified as game audio while retaining media volume behavior.
    • On Android versions below 9, the game profile behaves like media.
    • Improved handling of the voiceCommunication profile to classify output as speech.

Closes software-mansion#1554

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Android output profile options now include game. The native parser maps it to AndroidOutputProfile::Game, and Android stream configuration sets Usage::Game. The documentation and tests cover the added option.

Changes: Android game output profile

Layer / File(s) Summary
Expose and parse the game profile
packages/react-native-audio-api/common/cpp/audioapi/core/types/AudioContextOptions.h, packages/react-native-audio-api/src/types.ts, packages/react-native-audio-api/common/cpp/audioapi/HostObjects/utils/JsEnumParser.cpp, apps/common-app/src/utils/systemOptions.ts, packages/react-native-audio-api/tests/audio-context-options.test.ts
The public profile types and app option list include game. The parser maps it to AndroidOutputProfile::Game, and the test checks forwarding for game and voiceCommunication.
Configure Android stream usage
packages/react-native-audio-api/android/src/main/cpp/audioapi/android/core/AndroidAudioPlayer.cpp, packages/audiodocs/docs/core/audio-context.mdx
The stream builder sets Usage::Game for the game profile. The docs describe its Android classification and state that it is equivalent to media below Android 9.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant AudioContext
  participant EnumParser
  participant AndroidAudioPlayer
  participant AudioStreamBuilder
  AudioContext->>EnumParser: Pass androidOutputProfile string
  EnumParser->>AndroidAudioPlayer: Map "game" to AndroidOutputProfile::Game
  AndroidAudioPlayer->>AudioStreamBuilder: Set Usage::Game
Loading

Suggested labels: feature

Suggested reviewers: mdydek, closetcaiman

Merge Risk: Minimal · up to 46a21

This adds an optional Android 'game' output profile and leaves the default 'media' behavior unchanged. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(android): add a 'game' output profile" names the main change: a new 'game' value for the Android androidOutputProfile option. The changeset adds 'game' to the TypeScript type, the C++ …
Description check Passed The description follows the repository template. It includes the linked issue (Closes #1554), a breaking changes section that states none and that the default is unchanged, an introduced changes secti…
Linked Issues check Passed [#1554] requests a 'game' value for androidOutputProfile that opens the stream with Usage::Game, keeps 'media' as the default, and documents the API 28 limit. The reviewed head implements each coding …
Out of Scope Changes check Passed Every changed area supports the objective in [#1554]:
- AndroidAudioPlayer.cpp: the if or default-to-media path becomes a switch over AndroidOutputProfile. The new Game case is required. The switch le…
Full details: Title check

Explanation

The title "feat(android): add a 'game' output profile" names the main change: a new 'game' value for the Android androidOutputProfile option. The changeset adds 'game' to the TypeScript type, the C++ enum, the string parser, the stream usage setup in AndroidAudioPlayer, the docs, the example app list, and the test. The title is specific, concise, and follows a conventional commit style.

Full details: Description check

Explanation

The description follows the repository template. It includes the linked issue (Closes #1554), a breaking changes section that states none and that the default is unchanged, an introduced changes section, a testing section, and a checklist. The author marks the applicable checklist items and marks the three non-applicable items as not applicable. The description explains the API 28 limitation and the device verification, which matches the linked issue's requests.

Full details: Linked Issues check

Explanation

[#1554] requests a 'game' value for androidOutputProfile that opens the stream with Usage::Game, keeps 'media' as the default, and documents the API 28 limit. The reviewed head implements each coding requirement:

  • TypeScript union: packages/react-native-audio-api/src/types.ts adds 'game' to AndroidOutputProfile.
  • Parsing: JsEnumParser.cpp maps "game" to AndroidOutputProfile::Game. The fallback to Media is unchanged.
  • Native enum: AudioContextOptions.h adds the Game enumerator.
  • Stream builder: AndroidAudioPlayer.cpp (verified at head) contains a switch. Case Game calls builder.setUsage(Usage::Game). Case Media leaves the builder unchanged, so the default is unchanged.
  • Docs: audio-context.mdx adds 'game' and states that it keeps media volume and that below Android 9 it behaves as 'media'.
  • Tests: audio-context-options.test.ts forwards both 'game' and 'voiceCommunication'.
    The issue requirements are met by source and summary evidence. Device behavior is reported by the author on a patched 0.13.6 build, not on this branch. That report is not used as proof of the head behavior.
Full details: Out of Scope Changes check

Explanation

Every changed area supports the objective in [#1554]:

  • AndroidAudioPlayer.cpp: the if or default-to-media path becomes a switch over AndroidOutputProfile. The new Game case is required. The switch lets the compiler flag future profiles without a case. This is a direct part of adding the profile.
  • Enum, parser, and TypeScript type: required to expose the new value.
  • systemOptions.ts (example app): adds 'game' to ANDROID_OUTPUT_PROFILE_KEYS. This only exposes the new option in the example app.
  • audio-context.mdx: documentation of the new value and the API 28 limit, which the issue requests.
  • audio-context-options.test.ts: a supporting test for the forwarding of the new value. It also keeps coverage for 'voiceCommunication'.
    No change lacks a connection to the issue.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Clang (23.1.4)

packages/react-native-audio-api/android/src/main/cpp/audioapi/android/core/AndroidAudioPlayer.cpp

Clang-Tidy produced no recognizable diagnostics; analysis is incomplete

packages/react-native-audio-api/common/cpp/audioapi/HostObjects/utils/JsEnumParser.cpp

Clang-Tidy produced no recognizable diagnostics; analysis is incomplete

packages/react-native-audio-api/common/cpp/audioapi/core/types/AudioContextOptions.h

Clang-Tidy produced no recognizable diagnostics; analysis is incomplete

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 80932912-1ad0-4f95-803a-40932583e273
Commits

Reviewing files that changed from the base of the PR and between 01e9d9b and 46a2161.

Files selected for processing: 7

  • apps/common-app/src/utils/systemOptions.ts
  • packages/audiodocs/docs/core/audio-context.mdx
  • packages/react-native-audio-api/android/src/main/cpp/audioapi/android/core/AndroidAudioPlayer.cpp
  • packages/react-native-audio-api/common/cpp/audioapi/HostObjects/utils/JsEnumParser.cpp
  • packages/react-native-audio-api/common/cpp/audioapi/core/types/AudioContextOptions.h
  • packages/react-native-audio-api/src/types.ts
  • packages/react-native-audio-api/tests/audio-context-options.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

C++ coverage

Smoke suites, Clang source-based coverage.

Covered Total %
Lines 8756 11369 77.02%
Functions 1200 1460 82.19%
Regions 4554 5817 78.29%

Lines changed in this pull request

No changed lines with coverage information.

Workflow run · this comment is updated on every push.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

WPT non-regression comparison

PASS — no regressions · 0 improved section(s) · overall 3497 → 3497 (0)

Unchanged sections (28)
Spec section Base pass Head pass Delta
Processing model 2 2 0
Other 56 56 0
AnalyserNode 138 138 0
AudioBuffer 142 142 0
AudioBufferSourceNode 227 227 0
AudioContext 64 64 0
AudioNode 261 261 0
AudioParam 683 683 0
BiquadFilterNode 275 275 0
ChannelMergerNode 30 30 0
ChannelSplitterNode 7 7 0
ConstantSourceNode 64 64 0
ConvolverNode 226 226 0
DelayNode 130 130 0
DestinationNode 0 0 0
DynamicsCompressorNode 4 4 0
GainNode 15 15 0
IIRFilterNode 87 87 0
MediaElementAudioSourceNode 0 0 0
MediaStreamAudioDestinationNode 1 1 0
MediaStreamAudioSourceNode 0 0 0
OfflineAudioContext 35 35 0
OscillatorNode 104 104 0
PannerNode 727 727 0
PeriodicWave 33 33 0
ScriptProcessorNode 0 0 0
StereoPannerNode 104 104 0
WaveShaperNode 82 82 0

Baseline: 01e9d9bed1e54b7132df168b8182cf590d73b192 · Candidate: 46a21614252c758d7f3f16e7851462be665d74d6

Workflow run · this comment is updated on every push.

This branch has not been deployed

No deployments
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.

[Android] Add a 'game' androidOutputProfile (Usage::Game)

1 participant