Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d8add2be authored by Eric Laurent's avatar Eric Laurent
Browse files

audio policy: fix input preferred device logic

In AudioPolicyManager::getNewInputDevice(), the intention is to allow
and app to specify a preferred device only if no other app is capturing.
The implemented rule was actually preventing an app from specifying a
preferred device if that same app was also capturing.

Bug: 379233370
Test: repro steps in bug
Flag: EXEMPT bug fix.
Change-Id: I6d4b8a461e49088fa2bfb1ec25af8c96caa5d979
parent ca2abe33
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -64,6 +64,21 @@ sp<DeviceDescriptor> findPreferredDevice(
            if (activeClients.size() == activeClientsWithRoute.size()) {
                return devices.getDeviceFromId(activeClientsWithRoute[0]->preferredDeviceId());
            }
            if (activeClientsWithRoute.size() == 0) {
                return nullptr;
            }
            uid_t uniqueUid = activeClients[0]->uid();
            for (const auto &client : activeClients) {
                if (uniqueUid != client->uid()) {
                   return nullptr;
                }
            }
            for (const auto &client : activeClientsWithRoute) {
                if (uniqueUid != client->uid()) {
                   return nullptr;
                }
            }
            return devices.getDeviceFromId(activeClientsWithRoute[0]->preferredDeviceId());
        }
    }
    return nullptr;
+2 −1
Original line number Diff line number Diff line
@@ -7829,7 +7829,8 @@ sp<DeviceDescriptor> AudioPolicyManager::getNewInputDevice(
    }

    // Honor explicit routing requests only if no client using default routing is active on this
    // input: a specific app can not force routing for other apps by setting a preferred device.
    // input or if all active clients are from the same app: a specific app can not force routing
    // for other apps by setting a preferred device.
    bool active;
    device = findPreferredDevice(inputDesc, AUDIO_SOURCE_DEFAULT, active, mAvailableInputDevices);
    if (device != nullptr) {