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

Commit 9706527f authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge "VolumeShaper: improve logging and dumpsys" into oc-dev

parents 79a89ef4 da540db0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -295,6 +295,8 @@ public:
    std::string toString() const {
        std::stringstream ss;
        ss << "mInterpolatorType: " << mInterpolatorType << std::endl;
        ss << "mFirstSlope: " << mFirstSlope << std::endl;
        ss << "mLastSlope: " << mLastSlope << std::endl;
        for (const auto &pt : *this) {
            ss << pt.first << " " << pt.second << std::endl;
        }
+11 −2
Original line number Diff line number Diff line
@@ -628,7 +628,8 @@ public:
    explicit VolumeHandler(uint32_t sampleRate)
        : mSampleRate((double)sampleRate)
        , mLastFrame(0)
        , mVolumeShaperIdCounter(VolumeShaper::kSystemIdMax) {
        , mVolumeShaperIdCounter(VolumeShaper::kSystemIdMax)
        , mLastVolume(1.f, false) {
    }

    VolumeShaper::Status applyVolumeShaper(
@@ -758,7 +759,13 @@ public:
            activeCount += shaperVolume.second;
            ++it;
        }
        return std::make_pair(volume, activeCount != 0);
        mLastVolume = std::make_pair(volume, activeCount != 0);
        return mLastVolume;
    }

    std::pair<T /* volume */, bool /* active */> getLastVolume() const {
        AutoMutex _l(mLock);
        return mLastVolume;
    }

    std::string toString() const {
@@ -776,6 +783,7 @@ public:
            const sp<VolumeShaper::Configuration> &configuration,
            const sp<VolumeShaper::Operation> &operation)> &lambda) {
        AutoMutex _l(mLock);
        VS_LOG("forall: mVolumeShapers.size() %zu", mVolumeShapers.size());
        for (const auto &shaper : mVolumeShapers) {
            VS_LOG("forall applying lambda");
            (void)lambda(shaper.mConfiguration, shaper.mOperation);
@@ -829,6 +837,7 @@ private:
    double mSampleRate; // in samples (frames) per second
    int64_t mLastFrame; // logging purpose only
    int32_t mVolumeShaperIdCounter; // a counter to return a unique volume shaper id.
    std::pair<T /* volume */, bool /* active */> mLastVolume;
    std::list<VolumeShaper> mVolumeShapers; // list provides stable iterators on erase
}; // VolumeHandler

+8 −3
Original line number Diff line number Diff line
@@ -489,7 +489,7 @@ void AudioFlinger::PlaybackThread::Track::destroy()
/*static*/ void AudioFlinger::PlaybackThread::Track::appendDumpHeader(String8& result)
{
    result.append("    Name Active Client Type      Fmt Chn mask Session fCount S F SRate  "
                  "L dB  R dB    Server Main buf  Aux buf Flags UndFrmCnt  Flushed\n");
                  "L dB  R dB  VS dB    Server Main buf  Aux buf Flags UndFrmCnt  Flushed\n");
}

void AudioFlinger::PlaybackThread::Track::dump(char* buffer, size_t size, bool active)
@@ -555,7 +555,10 @@ void AudioFlinger::PlaybackThread::Track::dump(char* buffer, size_t size, bool a
        nowInUnderrun = '?';
        break;
    }
    snprintf(&buffer[8], size-8, " %6s %6u %4u %08X %08X %7u %6zu %1c %1d %5u %5.2g %5.2g  "

    std::pair<float /* volume */, bool /* active */> vsVolume = mVolumeHandler->getLastVolume();
    snprintf(&buffer[8], size - 8, " %6s %6u %4u %08X %08X %7u %6zu %1c %1d %5u "
                                   "%5.2g %5.2g %5.2g%c  "
                                   "%08X %08zX %08zX 0x%03X %9u%c %7u\n",
            active ? "yes" : "no",
            (mClient == 0) ? getpid_cached : mClient->pid(),
@@ -569,6 +572,8 @@ void AudioFlinger::PlaybackThread::Track::dump(char* buffer, size_t size, bool a
            mAudioTrackServerProxy->getSampleRate(),
            20.0 * log10(float_from_gain(gain_minifloat_unpack_left(vlr))),
            20.0 * log10(float_from_gain(gain_minifloat_unpack_right(vlr))),
            20.0 * log10(vsVolume.first), // VolumeShaper(s) total volume
            vsVolume.second ? 'A' : ' ',  // if any VolumeShapers active
            mCblk->mServer,
            (size_t)mMainBuffer, // use %zX as %p appends 0x
            (size_t)mAuxBuffer,  // use %zX as %p appends 0x