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

Commit 480ffee4 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

AudioPolicyManager: Handle error from setInputDevice in startInput

The error must not be ignored as otherwise the Java layer
thinks that recording has started successfully.

Bug: 136279123
Test: reproduce AudioRecordingConfigurationTest failure on cuttlefish,
      check test failure output, the failure must be
      "junit.framework.AssertionFailedError: expected:<3> but was:<1>"

Change-Id: I82bc3a43bf679cfb03d4246d07615d3fd4dac409
parent 18fa5eca
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -2243,9 +2243,15 @@ status_t AudioPolicyManager::startInput(audio_port_handle_t portId)
    // indicate active capture to sound trigger service if starting capture from a mic on
    // primary HW module
    sp<DeviceDescriptor> device = getNewInputDevice(inputDesc);
    setInputDevice(input, device, true /* force */);
    if (device != nullptr) {
        status = setInputDevice(input, device, true /* force */);
    } else {
        ALOGW("%s no new input device can be found for descriptor %d",
                __FUNCTION__, inputDesc->getId());
        status = BAD_VALUE;
    }

    if (inputDesc->activeCount()  == 1) {
    if (status == NO_ERROR && inputDesc->activeCount() == 1) {
        sp<AudioPolicyMix> policyMix = inputDesc->mPolicyMix.promote();
        // if input maps to a dynamic policy with an activity listener, notify of state change
        if ((policyMix != NULL)
@@ -2276,11 +2282,16 @@ status_t AudioPolicyManager::startInput(audio_port_handle_t portId)
                        address, "remote-submix", AUDIO_FORMAT_DEFAULT);
            }
        }
    } else if (status != NO_ERROR) {
        // Restore client activity state.
        inputDesc->setClientActive(client, false);
        inputDesc->stop();
    }

    ALOGV("%s input %d source = %d exit", __FUNCTION__, input, client->source());
    ALOGV("%s input %d source = %d status = %d exit",
            __FUNCTION__, input, client->source(), status);

    return NO_ERROR;
    return status;
}

status_t AudioPolicyManager::stopInput(audio_port_handle_t portId)