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

Commit 91423b80 authored by Vlad Popa's avatar Vlad Popa Committed by Android (Google) Code Review
Browse files

Merge "CSD: fix logic for new patches with CSD HAL path" into udc-dev

parents 5bc9c86e 69fbbee6
Loading
Loading
Loading
Loading
+4 −13
Original line number Diff line number Diff line
@@ -147,10 +147,6 @@ void AudioFlinger::MelReporter::onCreateAudioPatch(audio_patch_handle_t handle,
        ALOGV("%s csd is disabled", __func__);
        return;
    }
    if (useHalSoundDoseInterface()) {
        ALOGV("%s using HAL sound dose, ignore new patch", __func__);
        return;
    }

    ALOGV("%s: handle %d mHalHandle %d device sink %08x",
            __func__, handle, patch.mHalHandle,
@@ -199,7 +195,7 @@ NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l
        ALOGI("%s add stream %d that uses device %d for CSD, nr of streams: %d", __func__,
              patch.streamHandle, deviceHandle, mActiveDevices[deviceHandle]);

        if (outputThread != nullptr) {
        if (outputThread != nullptr && !useHalSoundDoseInterface_l()) {
            outputThread->startMelComputation_l(mSoundDoseManager->getOrCreateProcessorForDevice(
                deviceHandle,
                patch.streamHandle,
@@ -271,7 +267,7 @@ NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l
        }
    }

    if (outputThread != nullptr) {
    if (outputThread != nullptr && !useHalSoundDoseInterface_l()) {
        outputThread->stopMelComputation_l();
    }
}
@@ -287,13 +283,8 @@ std::optional<audio_patch_handle_t> AudioFlinger::MelReporter::activePatchStream
    return std::nullopt;
}

bool AudioFlinger::MelReporter::useHalSoundDoseInterface() {
    bool useHalSoundDoseInterface = !mSoundDoseManager->forceUseFrameworkMel();
    {
        std::lock_guard _l(mLock);
        useHalSoundDoseInterface &= mUseHalSoundDoseInterface;
    }
    return useHalSoundDoseInterface;
bool AudioFlinger::MelReporter::useHalSoundDoseInterface_l() {
    return !mSoundDoseManager->forceUseFrameworkMel() & mUseHalSoundDoseInterface;
}

std::string AudioFlinger::MelReporter::dump() {
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ private:
    std::optional<audio_patch_handle_t>
    activePatchStreamHandle_l(audio_io_handle_t streamHandle) REQUIRES(mLock);

    bool useHalSoundDoseInterface();
    bool useHalSoundDoseInterface_l() REQUIRES(mLock);

    AudioFlinger& mAudioFlinger;  // does not own the object

+2 −2
Original line number Diff line number Diff line
@@ -216,7 +216,7 @@ ndk::ScopedAStatus SoundDoseManager::HalSoundDoseCallback::onMomentaryExposureWa
    if (id == AUDIO_PORT_HANDLE_NONE) {
        ALOGI("%s: no mapped id for audio device with type %d and address %s",
                __func__, in_audioDevice.type.type,
                in_audioDevice.address.get<AudioDeviceAddress::id>().c_str());
                in_audioDevice.address.toString().c_str());
        return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
    }
    soundDoseManager->onMomentaryExposure(in_currentDbA, id);
@@ -243,7 +243,7 @@ ndk::ScopedAStatus SoundDoseManager::HalSoundDoseCallback::onNewMelValues(
    if (id == AUDIO_PORT_HANDLE_NONE) {
        ALOGI("%s: no mapped id for audio device with type %d and address %s",
                __func__, in_audioDevice.type.type,
                in_audioDevice.address.get<AudioDeviceAddress::id>().c_str());
                in_audioDevice.address.toString().c_str());
        return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
    }
    // TODO: introduce timestamp in onNewMelValues callback