AudioPolicy: remove devices while Sw bridge established
When devices are disconnected while involved in a SwBridge,
the connectAudioSource function may be called while the cache
of the engine has not yet been updated with availability of devices.
This CL forces to retrieve sinkDevices from engine without using
the cache.
It also ensures that Audio Source using Direct Output are also
re routed while sink device has been made UNAVAILABLE then AVAILABLE
again. In this case, no SwOutput will keep track of the AudioSource.
Orphans Audio Source shall be handled independantly.
So far, robustness cases added to the following test.
In some case, fallback on speaker is allowed, in other,
device none is selected while given sink has been made unavailable:
Test: So far: adb shell /data/nativetest64/AudioPolicyEmulatorTests/AudioPolicyEmulatorTests --gtest_filter=AudioPatchTest/AudioModeBridgingTest.
adb shell /data/nativetest64/AudioPolicyEmulatorTests/AudioPolicyEmulatorTests --gtest_filter=AudioSourceTest/AudioSourceBridgingTest.UsingAudioSourceAPI/
Signed-off-by: Francois Gaffie <francois.gaffie@renault.com>
Change-Id: I2663d10f08de3191de4d95bc81749ede9b8a360f
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index eca8781..6ea77f5 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -571,6 +571,16 @@
*/
void checkOutputForAttributes(const audio_attributes_t &attr);
+ /**
+ * @brief checkAudioSourceForAttributes checks if any AudioSource following the same routing
+ * as the given audio attributes is not routed and try to connect it.
+ * It must be called once checkOutputForAttributes has been called for orphans AudioSource,
+ * aka AudioSource not attached to any Audio Output (e.g. AudioSource connected to direct
+ * Output which has been disconnected (and output closed) due to sink device unavailable).
+ * @param attr to be considered
+ */
+ void checkAudioSourceForAttributes(const audio_attributes_t &attr);
+
bool followsSameRouting(const audio_attributes_t &lAttr,
const audio_attributes_t &rAttr) const;
@@ -740,6 +750,7 @@
sp<SourceClientDescriptor> getSourceForAttributesOnOutput(audio_io_handle_t output,
const audio_attributes_t &attr);
+ void clearAudioSourcesForOutput(audio_io_handle_t output);
void cleanUpForDevice(const sp<DeviceDescriptor>& deviceDesc);