Audio Policy: Parametrize encoded formats supported by device

For various reasons, we need to store the list of audio
formats supported by devices. Here we add support for this
into DeviceDescriptor. We don't read them yet from
the APM config file, but we will eventually.

Also in this change, use the formats list for parametrizing
the behavior of surround sound configuration. The special
logic for AC3 and IEC69137 formats used to be hardcoded
into 'filterSurroundFormats' function, now it is
parametrized by the device descriptor information.

Fix behavior of 'filterSurroundFormats' in 'manual'
mode, where it was removing PCM formats from the list.

Rename 'filterSurround...' functions to 'modifySurround...'
since they can both add and remove items from the provided
list.

Bug: 67479735
Bug: 117602867
Test: compare A/B APM dumps while modifying Surround Sound
      settings; tested with a HDMI sink that doesn't support
      any surround, and with an AV receiver
Change-Id: Ie46480d5e9519366b1f3553645c9ca20f64bdc80
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index 22bfab0..8f0e922 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -608,8 +608,8 @@
         std::unordered_set<audio_format_t> mSurroundFormats;
 private:
         // Add or remove AC3 DTS encodings based on user preferences.
-        void filterSurroundFormats(FormatVector *formatsPtr);
-        void filterSurroundChannelMasks(ChannelsVector *channelMasksPtr);
+        void modifySurroundFormats(const sp<DeviceDescriptor>& devDesc, FormatVector *formatsPtr);
+        void modifySurroundChannelMasks(ChannelsVector *channelMasksPtr);
 
         // Support for Multi-Stream Decoder (MSD) module
         sp<DeviceDescriptor> getMsdAudioInDevice() const;
@@ -623,7 +623,7 @@
         status_t setMsdPatch(audio_devices_t outputDevice = AUDIO_DEVICE_NONE);
 
         // If any, resolve any "dynamic" fields of an Audio Profiles collection
-        void updateAudioProfiles(audio_devices_t device, audio_io_handle_t ioHandle,
+        void updateAudioProfiles(const sp<DeviceDescriptor>& devDesc, audio_io_handle_t ioHandle,
                 AudioProfileVector &profiles);
 
         // Notify the policy client of any change of device state with AUDIO_IO_HANDLE_NONE,