audiopolicy: Remove raw pointer references to AudioMix
AudioInputDescriptor and AudioOutputDescriptor used to reference
AudioMix instances using a raw pointer. This isn't safe as AudioMix
was owned by AudioPolicyMix, which is not referenced by descriptors.
Change AudioMix* pointers in Audio{Input|Output}Descriptor to
wp<AudioPolicyMix> which reflects their relationship correctly.
To ensure that code does not operate on AudioMix instances
independently from AudioPolicyMix, and to avoid introducing
a lot of getter / setter methods into AudioPolicyMix, make
the latter to inherit AudioMix. This makes sense because
AudioPolicyMix is essentially a ref-counted version of AudioMix.
Bug: 124899895
Test: build and sanity check on crosshatch,
build crosshatch with USE_CONFIGURABLE_AUDIO_POLICY := 1
Change-Id: Ic508caedefe721ed7e7ba6ee3e9175ba9e8dc23a
diff --git a/services/audiopolicy/engine/interface/AudioPolicyManagerInterface.h b/services/audiopolicy/engine/interface/AudioPolicyManagerInterface.h
index 38f3401..4315061 100644
--- a/services/audiopolicy/engine/interface/AudioPolicyManagerInterface.h
+++ b/services/audiopolicy/engine/interface/AudioPolicyManagerInterface.h
@@ -169,7 +169,7 @@
* @return selected input device for the audio attributes, may be null if error.
*/
virtual sp<DeviceDescriptor> getInputDeviceForAttributes(
- const audio_attributes_t &attr, AudioMix **mix = nullptr) const = 0;
+ const audio_attributes_t &attr, sp<AudioPolicyMix> *mix = nullptr) const = 0;
/**
* Get the legacy stream type for a given audio attributes.