APM: Create multiple MSD patches
This change modifies setMsdPatch() by first renaming to setMsdPatches()
and replaces its parameter with a pointer to DeviceVector, so that
multiple devices can be patched from MSD. If none are specified it will
establish MSD patches with all reported downstream output devices. It
tears down existing MSD patches and creates new ones for those MSD
patches that do not support new patch requests. We retain the existing
MSD patches that already support new patch requests.
In getBestMsdAudioProfileFor(), ensure output profiles considered for
evaluating the best matching audio profile is supported by the output
device under consideration.
Refactor by placing common code that tears down current MSD patches into
a new function called releaseMsdPatches().
When obtaining an output, getOutputForAttrInt() returns device ID of the
default device if its ID matches that of one of the output devices
provided by the engine.
Add testing for dual MSD patch creation by parameterizing existing MSD
tests for single and dual MSD patch cases. Add new unit test to exercise
setMsdPatches and releaseMsdPatches. Make private MSD module member
functions protected to enable testing.
Bug: 135620198
Test: audiopolicy_tests
Change-Id: I59a8976ce82dba04ca69347afc192e9143ef3629
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index 3c55b63..d3ceb1b 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -848,13 +848,6 @@
// end point.
audio_port_handle_t mCallRxSourceClientPort = AUDIO_PORT_HANDLE_NONE;
-private:
- void onNewAudioModulesAvailableInt(DeviceVector *newDevices);
-
- // Add or remove AC3 DTS encodings based on user preferences.
- void modifySurroundFormats(const sp<DeviceDescriptor>& devDesc, FormatVector *formatsPtr);
- void modifySurroundChannelMasks(ChannelMaskSet *channelMasksPtr);
-
// Support for Multi-Stream Decoder (MSD) module
sp<DeviceDescriptor> getMsdAudioInDevice() const;
DeviceVector getMsdAudioOutDevices() const;
@@ -864,7 +857,14 @@
audio_port_config *sourceConfig,
audio_port_config *sinkConfig) const;
PatchBuilder buildMsdPatch(const sp<DeviceDescriptor> &outputDevice) const;
- status_t setMsdPatch(const sp<DeviceDescriptor> &outputDevice = nullptr);
+ status_t setMsdPatches(const DeviceVector *outputDevices = nullptr);
+ void releaseMsdPatches(const DeviceVector& devices);
+private:
+ void onNewAudioModulesAvailableInt(DeviceVector *newDevices);
+
+ // Add or remove AC3 DTS encodings based on user preferences.
+ void modifySurroundFormats(const sp<DeviceDescriptor>& devDesc, FormatVector *formatsPtr);
+ void modifySurroundChannelMasks(ChannelMaskSet *channelMasksPtr);
// If any, resolve any "dynamic" fields of an Audio Profiles collection
void updateAudioProfiles(const sp<DeviceDescriptor>& devDesc, audio_io_handle_t ioHandle,