APM: Improve surround formats management, include MSD
This is what this change does:
1) Renames APM::mSurroundFormats into mManualSurroundFormats
and avoids modifying it in modifySurroundFormats, because
multiple surround-capable devices are possible.
modifySurroundFormats logic is also a bit simplified.
2) Changes the way APM::getSurroundFormats reports enabled
formats, after the change 1).
3) Includes MSD module into consideration as a surround-capable
device.
4) Changes APM::dump to only show mManualSurroundFormats
when surround sound is enforced into manual management.
5) Adds Dolby AC-4 to the list of surround formats.
6) Declares surround formats on the devicePort of MSD.
Bug: 117602867
Test: Surround Sound settings with MSD module
Change-Id: I5cdd3c012a3febcf7170cc5fa7378224b3ef9e4f
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index 2b89380..8618e0c 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -186,7 +186,9 @@
virtual bool isSourceActive(audio_source_t source) const;
- void dump(String8 *dst) const; // helper for dump(int fd)
+ // helpers for dump(int fd)
+ void dumpManualSurroundFormats(String8 *dst) const;
+ void dump(String8 *dst) const;
status_t dump(int fd) override;
@@ -516,6 +518,9 @@
sp<AudioPatch> createTelephonyPatch(bool isRx, audio_devices_t device, uint32_t delayMs);
sp<DeviceDescriptor> findDevice(
const DeviceVector& devices, audio_devices_t device) const;
+ audio_devices_t getModuleDeviceTypes(
+ const DeviceVector& devices, const char *moduleId) const;
+ bool isDeviceOfModule(const sp<DeviceDescriptor>& devDesc, const char *moduleId) const;
status_t startSource(const sp<SwAudioOutputDescriptor>& outputDesc,
const sp<TrackClientDescriptor>& client,
@@ -608,8 +613,9 @@
// Audio Policy Engine Interface.
AudioPolicyManagerInterface *mEngine;
- // Surround formats that are enabled.
- std::unordered_set<audio_format_t> mSurroundFormats;
+ // Surround formats that are enabled manually. Taken into account when
+ // "encoded surround" is forced into "manual" mode.
+ std::unordered_set<audio_format_t> mManualSurroundFormats;
private:
// Add or remove AC3 DTS encodings based on user preferences.
void modifySurroundFormats(const sp<DeviceDescriptor>& devDesc, FormatVector *formatsPtr);
@@ -617,7 +623,6 @@
// Support for Multi-Stream Decoder (MSD) module
sp<DeviceDescriptor> getMsdAudioInDevice() const;
- audio_devices_t getMsdAudioOutDeviceTypes() const;
const AudioPatchCollection getMsdPatches() const;
status_t getBestMsdAudioProfileFor(audio_devices_t outputDevice,
bool hwAvSync,