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

Commit c6ba2022 authored by Andy Hung's avatar Andy Hung Committed by Gerrit Code Review
Browse files

Merge "VolumeShaper: Update Direct/Offload to use media time"

parents 45137cc7 ee86ceee
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -180,6 +180,7 @@ cc_library_shared {
        "av-types-aidl-cpp",
        "av-types-aidl-cpp",
        "effect-aidl-cpp",
        "effect-aidl-cpp",
        "libaudioclient_aidl_conversion",
        "libaudioclient_aidl_conversion",
        "libaudioflinger_timing",
        "libaudiofoundation",
        "libaudiofoundation",
        "libaudiohal",
        "libaudiohal",
        "libaudioprocessing",
        "libaudioprocessing",
+2 −0
Original line number Original line Diff line number Diff line
@@ -84,6 +84,8 @@
#include <audio_utils/SimpleLog.h>
#include <audio_utils/SimpleLog.h>
#include <audio_utils/TimestampVerifier.h>
#include <audio_utils/TimestampVerifier.h>


#include <timing/MonotonicFrameCounter.h>

#include "FastCapture.h"
#include "FastCapture.h"
#include "FastMixer.h"
#include "FastMixer.h"
#include <media/nbaio/NBAIO.h>
#include <media/nbaio/NBAIO.h>
+13 −2
Original line number Original line Diff line number Diff line
@@ -6190,8 +6190,18 @@ void AudioFlinger::DirectOutputThread::processVolume_l(Track *track, bool lastTr


    // Ensure volumeshaper state always advances even when muted.
    // Ensure volumeshaper state always advances even when muted.
    const sp<AudioTrackServerProxy> proxy = track->mAudioTrackServerProxy;
    const sp<AudioTrackServerProxy> proxy = track->mAudioTrackServerProxy;
    const auto [shaperVolume, shaperActive] = track->getVolumeHandler()->getVolume(

            proxy->framesReleased());
    const size_t framesReleased = proxy->framesReleased();
    const int64_t frames = mTimestamp.mPosition[ExtendedTimestamp::LOCATION_KERNEL];
    const int64_t time = mTimestamp.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL];

    ALOGV("%s: Direct/Offload bufferConsumed:%zu  timestamp frames:%lld  time:%lld",
            __func__, framesReleased, (long long)frames, (long long)time);

    const int64_t volumeShaperFrames =
            mMonotonicFrameCounter.updateAndGetMonotonicFrameCount(frames, time);
    const auto [shaperVolume, shaperActive] =
            track->getVolumeHandler()->getVolume(volumeShaperFrames);
    mVolumeShaperActive = shaperActive;
    mVolumeShaperActive = shaperActive;


    if (mMasterMute || mStreamTypes[track->streamType()].mute || track->isPlaybackRestricted()) {
    if (mMasterMute || mStreamTypes[track->streamType()].mute || track->isPlaybackRestricted()) {
@@ -6667,6 +6677,7 @@ void AudioFlinger::DirectOutputThread::flushHw_l()
    mFlushPending = false;
    mFlushPending = false;
    mTimestampVerifier.discontinuity(discontinuityForStandbyOrFlush());
    mTimestampVerifier.discontinuity(discontinuityForStandbyOrFlush());
    mTimestamp.clear();
    mTimestamp.clear();
    mMonotonicFrameCounter.onFlush();
}
}


int64_t AudioFlinger::DirectOutputThread::computeWaitTimeNs_l() const {
int64_t AudioFlinger::DirectOutputThread::computeWaitTimeNs_l() const {
+2 −0
Original line number Original line Diff line number Diff line
@@ -1581,6 +1581,8 @@ protected:
    virtual     void        onAddNewTrack_l();
    virtual     void        onAddNewTrack_l();


    const       audio_offload_info_t mOffloadInfo;
    const       audio_offload_info_t mOffloadInfo;

    audioflinger::MonotonicFrameCounter mMonotonicFrameCounter;  // for VolumeShaper
    bool mVolumeShaperActive = false;
    bool mVolumeShaperActive = false;


    DirectOutputThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
    DirectOutputThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
+1 −19
Original line number Original line Diff line number Diff line
@@ -1366,25 +1366,7 @@ VolumeShaper::Status AudioFlinger::PlaybackThread::Track::applyVolumeShaper(
        const sp<VolumeShaper::Configuration>& configuration,
        const sp<VolumeShaper::Configuration>& configuration,
        const sp<VolumeShaper::Operation>& operation)
        const sp<VolumeShaper::Operation>& operation)
{
{
    sp<VolumeShaper::Configuration> newConfiguration;
    VolumeShaper::Status status = mVolumeHandler->applyVolumeShaper(configuration, operation);

    if (isOffloadedOrDirect()) {
        const VolumeShaper::Configuration::OptionFlag optionFlag
            = configuration->getOptionFlags();
        if ((optionFlag & VolumeShaper::Configuration::OPTION_FLAG_CLOCK_TIME) == 0) {
            ALOGW("%s(%d): %s tracks do not support frame counted VolumeShaper,"
                    " using clock time instead",
                    __func__, mId,
                    isOffloaded() ? "Offload" : "Direct");
            newConfiguration = new VolumeShaper::Configuration(*configuration);
            newConfiguration->setOptionFlags(
                VolumeShaper::Configuration::OptionFlag(optionFlag
                        | VolumeShaper::Configuration::OPTION_FLAG_CLOCK_TIME));
        }
    }

    VolumeShaper::Status status = mVolumeHandler->applyVolumeShaper(
            (newConfiguration.get() != nullptr ? newConfiguration : configuration), operation);


    if (isOffloadedOrDirect()) {
    if (isOffloadedOrDirect()) {
        // Signal thread to fetch new volume.
        // Signal thread to fetch new volume.
Loading