Does Oboe rely on manual setVolume() or system configuration for Audio Ducking when integrated with AudioManager/AudioFocusRequest? #2408
Replies: 1 comment
|
Neither, strictly — the part that's missing from the question is that Oboe has no volume control to call. There is no So the options aren't "call setVolume vs. let the system do it". They're:
Oboe has no audio-focus integration either. It doesn't observe Worth looking at how Google's own Oboe sample handles exactly this. From AudioManager.AUDIOFOCUS_LOSS,
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT,
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> {
if (::player.isInitialized) {
player.stopPlaying(player.currentSongIndex)
}
}It groups That's a reasonable model to copy if pausing is acceptable for your use case, and it's the least code. If you actually need to duck rather than pause, the shape is: // audio thread
float gain = mGain.load(std::memory_order_relaxed);
for (int i = 0; i < numFrames * channelCount; i++) {
buffer[i] *= gain;
}with the Kotlin side setting that atomic to something like 0.2f on One design note since you're evaluating: if you'd rather not implement ducking at all, |
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
We are currently evaluating how Android's audio ducking behaves when using the Oboe library for low-latency audio playback, especially regarding its interoperability with Java/Kotlin AudioManager and AudioFocusRequest.
We would like to clarify a key question: If we successfully coordinate Oboe with Android's Audio Focus, do we still need to manually adjust setVolume() in our code when ducking occurs, or does the system configuration handle it automatically?
All reactions