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

Commit 2035bc0e authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "audio policy: fix capture indication to sound trigger service." into nyc-mr1-dev

parents 10da5ab2 271a93e9
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -93,7 +93,9 @@ public:

    sp<AudioInputDescriptor> getInputFromId(audio_port_handle_t id) const;

    uint32_t activeInputsCount() const;
    // count active capture sessions using one of the specified devices.
    // ignore devices if AUDIO_DEVICE_IN_DEFAULT is passed
    uint32_t activeInputsCountOnDevices(audio_devices_t devices = AUDIO_DEVICE_IN_DEFAULT) const;

    /**
     * return io handle of active input or 0 if no input is active
+4 −2
Original line number Diff line number Diff line
@@ -222,12 +222,14 @@ sp<AudioInputDescriptor> AudioInputCollection::getInputFromId(audio_port_handle_
    return inputDesc;
}

uint32_t AudioInputCollection::activeInputsCount() const
uint32_t AudioInputCollection::activeInputsCountOnDevices(audio_devices_t devices) const
{
    uint32_t count = 0;
    for (size_t i = 0; i < size(); i++) {
        const sp<AudioInputDescriptor>  inputDescriptor = valueAt(i);
        if (inputDescriptor->isActive()) {
        if (inputDescriptor->isActive() &&
                ((devices == AUDIO_DEVICE_IN_DEFAULT) ||
                 ((inputDescriptor->mDevice & devices & ~AUDIO_DEVICE_BIT_IN) != 0))) {
            count++;
        }
    }
+13 −3
Original line number Diff line number Diff line
@@ -1688,10 +1688,15 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input,
                    MIX_STATE_MIXING);
        }

        if (mInputs.activeInputsCount() == 0) {
        // indicate active capture to sound trigger service if starting capture from a mic on
        // primary HW module
        audio_devices_t device = getNewInputDevice(input);
        audio_devices_t primaryInputDevices = availablePrimaryInputDevices();
        if (((device & primaryInputDevices & ~AUDIO_DEVICE_BIT_IN) != 0) &&
                mInputs.activeInputsCountOnDevices(primaryInputDevices) == 0) {
            SoundTrigger::setCaptureState(true);
        }
        setInputDevice(input, getNewInputDevice(input), true /* force */);
        setInputDevice(input, device, true /* force */);

        // automatically enable the remote submix output when input is started if not
        // used by a policy mix of type MIX_TYPE_RECORDERS
@@ -1768,9 +1773,14 @@ status_t AudioPolicyManager::stopInput(audio_io_handle_t input,
            }
        }

        audio_devices_t device = inputDesc->mDevice;
        resetInputDevice(input);

        if (mInputs.activeInputsCount() == 0) {
        // indicate inactive capture to sound trigger service if stopping capture from a mic on
        // primary HW module
        audio_devices_t primaryInputDevices = availablePrimaryInputDevices();
        if (((device & primaryInputDevices & ~AUDIO_DEVICE_BIT_IN) != 0) &&
                mInputs.activeInputsCountOnDevices(primaryInputDevices) == 0) {
            SoundTrigger::setCaptureState(false);
        }
        inputDesc->clearPreemptedSessions();