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

Commit 993f390f authored by Francois Gaffie's avatar Francois Gaffie Committed by Eric Laurent
Browse files

audiopolicy: remove double call to attach / getModuleForDeviceType



For a2dp hybrid mode, device retrieval is done through type / code pair.
When the device is connected, getDeviceDescriptor is called with allowToCreate
boolean. As a result, HwModuleCollection::createDevice will be called, invoking
getModuleForDeviceTypes as done laterly in setDeviceConnectionState.

This CL removes double call to these function.

Bug: 130284799
Test: make

Change-Id: I188f11e9325cfc6af2ae872e00485e00ccd9096b
Signed-off-by: default avatarFrancois Gaffie <francois.gaffie@renault.com>
parent 9e1533cd
Loading
Loading
Loading
Loading
+1 −19
Original line number Diff line number Diff line
@@ -142,18 +142,7 @@ status_t AudioPolicyManager::setDeviceConnectionStateInt(audio_devices_t deviceT
                    __func__, device->toString().c_str(), encodedFormat);

            // register new device as available
            index = mAvailableOutputDevices.add(device);
            if (index >= 0) {
                sp<HwModule> module = mHwModules.getModuleForDevice(device, encodedFormat);
                if (module == 0) {
                    ALOGD("setDeviceConnectionState() could not find HW module for device %s",
                          device->toString().c_str());
                    mAvailableOutputDevices.remove(device);
                    return INVALID_OPERATION;
                }
                ALOGV("setDeviceConnectionState() module name=%s", module->getName());
                mAvailableOutputDevices[index]->attach(module);
            } else {
            if (mAvailableOutputDevices.add(device) < 0) {
                return NO_MEMORY;
            }

@@ -295,13 +284,6 @@ status_t AudioPolicyManager::setDeviceConnectionStateInt(audio_devices_t deviceT
                ALOGW("%s() device already connected: %s", __func__, device->toString().c_str());
                return INVALID_OPERATION;
            }
            sp<HwModule> module = mHwModules.getModuleForDevice(device, AUDIO_FORMAT_DEFAULT);
            if (module == NULL) {
                ALOGW("setDeviceConnectionState(): could not find HW module for device %s",
                      device->toString().c_str());
                return INVALID_OPERATION;
            }

            // Before checking intputs, broadcast connect event to allow HAL to retrieve dynamic
            // parameters on newly connected devices (instead of opening the inputs...)
            broadcastDeviceConnectionState(device, state);