audio policy: fix crash in findPreferredDevice() on duplicating outputs

Duplicating outputs do not have an associated IOProfile and
getPolicyAudioPort() returns null.

Add a method to AudioIODescriptorInterface to query if the
input or output descriptor corresponds to MMAP IO profile or not.

Bug: 153849965
Test: repro steps in the bug
Change-Id: I300356880198f1785e3a5e1359ffd393c6ae4190
gugelfrei
Eric Laurent 4 years ago
parent 141095dce0
commit 26874fed26

@ -34,6 +34,8 @@ public:
virtual audio_patch_handle_t getPatchHandle() const = 0;
virtual void setPatchHandle(audio_patch_handle_t handle) = 0;
virtual bool isMmap() = 0;
};
template <class IoDescriptor, class Filter>
@ -48,7 +50,7 @@ sp<DeviceDescriptor> findPreferredDevice(
// created when the mmap stream is opened). This client is never active.
// On non MMAP IOs, the preferred device is honored only if all active clients have
// a preferred device in which case the first client drives the selection.
if (desc->getPolicyAudioPort()->isMmap()) {
if (desc->isMmap()) {
// The client list is never empty on a MMAP IO
return devices.getDeviceFromId(
desc->clientsList(false /*activeOnly*/)[0]->preferredDeviceId());

@ -92,6 +92,12 @@ public:
audio_config_base_t getConfig() const override;
audio_patch_handle_t getPatchHandle() const override;
void setPatchHandle(audio_patch_handle_t handle) override;
bool isMmap() override {
if (getPolicyAudioPort() != nullptr) {
return getPolicyAudioPort()->isMmap();
}
return false;
}
status_t open(const audio_config_t *config,
const sp<DeviceDescriptor> &device,

@ -268,6 +268,12 @@ public:
audio_config_base_t getConfig() const override;
audio_patch_handle_t getPatchHandle() const override;
void setPatchHandle(audio_patch_handle_t handle) override;
bool isMmap() override {
if (getPolicyAudioPort() != nullptr) {
return getPolicyAudioPort()->isMmap();
}
return false;
}
TrackClientVector clientsList(bool activeOnly = false,
product_strategy_t strategy = PRODUCT_STRATEGY_NONE,

Loading…
Cancel
Save