VolumeShaper: improve logging and dumpsys
Test: CTS and dumpsys
Bug: 37536598
Change-Id: I9a838a8605defde3aaf42a872e48f01425df0f0e
diff --git a/include/media/Interpolator.h b/include/media/Interpolator.h
index 1b26b87..120a074 100644
--- a/include/media/Interpolator.h
+++ b/include/media/Interpolator.h
@@ -295,6 +295,8 @@
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;
}
diff --git a/include/media/VolumeShaper.h b/include/media/VolumeShaper.h
index f5a74d8..4f6cbdc 100644
--- a/include/media/VolumeShaper.h
+++ b/include/media/VolumeShaper.h
@@ -628,7 +628,8 @@
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 @@
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 @@
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 @@
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
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 5e07e3b..5480513 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -489,7 +489,7 @@
/*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,8 +555,11 @@
nowInUnderrun = '?';
break;
}
- snprintf(&buffer[8], size-8, " %6s %6u %4u %08X %08X %7u %6zu %1c %1d %5u %5.2g %5.2g "
- "%08X %08zX %08zX 0x%03X %9u%c %7u\n",
+
+ 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(),
mStreamType,
@@ -569,6 +572,8 @@
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