Audio routing: Fix notification routing during A11y playback
When notifications are played, the audio policy checks if media
is playing for deciding which devices will play it. In the
absence of media, the notification is duplicated on speaker
and headset. With media playing, the notification routing
is set to that of the media strategy.
The bug is observed during A11y playback on headset with a
notification playing: A11y is playing on headset, but the
device can't play the notification on speaker + headset at
the same time, resulting in the notification playing in and
out based on the A11y playback in headset.
The fix is to also consider A11y activity when routing
notification playback (under STRATEGY_SONIFICATION_RESPECTFUL).
This improves the UX the notification is not missed, and
doesn't cut in and out.
Test: play Talkback on headset, receive notification at the same time.
Bug: 62907561
Change-Id: Ib924ec41cb7e16d6f2686d8615facba08e256ade
diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
index b6fff8c..9bdb98c 100644
--- a/services/audiopolicy/enginedefault/src/Engine.cpp
+++ b/services/audiopolicy/enginedefault/src/Engine.cpp
@@ -277,8 +277,11 @@
device &= ~AUDIO_DEVICE_OUT_SPEAKER;
}
} else if (outputs.isStreamActive(
- AUDIO_STREAM_MUSIC, SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY)) {
- // while media is playing (or has recently played), use the same device
+ AUDIO_STREAM_MUSIC, SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY)
+ || outputs.isStreamActive(
+ AUDIO_STREAM_ACCESSIBILITY, SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY))
+ {
+ // while media/a11y is playing (or has recently played), use the same device
device = getDeviceForStrategyInt(
STRATEGY_MEDIA, availableOutputDevices, availableInputDevices, outputs);
} else {