Remove --json option from dumpsys media.audio_flinger

The more recent work that this was supposed to become is reflected in
dumpsys media.log, so this commit removes some code clutter that is not
used anymore.

Other Changes:
- Use std::make_unique for creating unique_ptr objects

Test: build, dumpsys media.audio_flinger
Bug: 68148948
Change-Id: I4841e118c2cdee4ada4c6cdc0fff1ec2e12b38c4
gugelfrei
Eric Tan 6 years ago
parent ea055e6dab
commit 2942a4e2d9

@ -22,9 +22,6 @@ LOCAL_SHARED_LIBRARIES := \
libsoundtriggerservice \
libutils
LOCAL_STATIC_LIBRARIES := \
libjsoncpp
# TODO oboeservice is the old folder name for aaudioservice. It will be changed.
LOCAL_C_INCLUDES := \
frameworks/av/services/audioflinger \

@ -42,7 +42,6 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_STATIC_LIBRARIES := \
libcpustats \
libjsoncpp \
libsndfile \
LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)

@ -20,7 +20,6 @@
//#define LOG_NDEBUG 0
#include "Configuration.h"
#include <algorithm> // std::any_of
#include <dirent.h>
#include <math.h>
#include <signal.h>
@ -58,8 +57,6 @@
#include <audio_utils/primitives.h>
#include <json/json.h>
#include <powermanager/PowerManager.h>
#include <media/IMediaLogService.h>
@ -437,18 +434,6 @@ status_t AudioFlinger::dump(int fd, const Vector<String16>& args)
if (!dumpAllowed()) {
dumpPermissionDenial(fd, args);
} else {
// XXX This is sort of hacky for now.
const bool formatJson = std::any_of(args.begin(), args.end(),
[](const String16 &arg) { return arg == String16("--json"); });
if (formatJson) {
Json::Value root = getJsonDump();
Json::FastWriter writer;
std::string rootStr = writer.write(root);
// XXX consider buffering if the string happens to be too long.
dprintf(fd, "%s", rootStr.c_str());
return NO_ERROR;
}
// get state of hardware lock
bool hardwareLocked = dumpTryLock(mHardwareLock);
if (!hardwareLocked) {
@ -575,32 +560,6 @@ status_t AudioFlinger::dump(int fd, const Vector<String16>& args)
return NO_ERROR;
}
Json::Value AudioFlinger::getJsonDump()
{
Json::Value root(Json::objectValue);
const bool locked = dumpTryLock(mLock);
// failed to lock - AudioFlinger is probably deadlocked
if (!locked) {
root["deadlock_message"] = kDeadlockedString;
}
// FIXME risky to access data structures without a lock held?
Json::Value playbackThreads = Json::arrayValue;
// dump playback threads
for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
playbackThreads.append(mPlaybackThreads.valueAt(i)->getJsonDump());
}
if (locked) {
mLock.unlock();
}
root["playback_threads"] = playbackThreads;
return root;
}
sp<AudioFlinger::Client> AudioFlinger::registerPid(pid_t pid)
{
Mutex::Autolock _cl(mClientLock);

@ -23,7 +23,6 @@
#include <mutex>
#include <deque>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>
@ -81,7 +80,6 @@
#include <powermanager/IPowerManager.h>
#include <json/json.h>
#include <media/nblog/NBLog.h>
#include <private/media/AudioEffectShared.h>
#include <private/media/AudioTrackShared.h>
@ -117,7 +115,6 @@ public:
static const char* getServiceName() ANDROID_API { return "media.audio_flinger"; }
virtual status_t dump(int fd, const Vector<String16>& args);
Json::Value getJsonDump();
// IAudioFlinger interface, in binder opcode order
virtual sp<IAudioTrack> createTrack(const CreateTrackInput& input,

@ -27,7 +27,7 @@
//#define AUDIO_WATCHDOG
// uncomment to display CPU load adjusted for CPU frequency
//define CPU_FREQUENCY_STATISTICS
//#define CPU_FREQUENCY_STATISTICS
// uncomment to enable fast threads to take performance samples for later statistical analysis
#define FAST_THREAD_STATISTICS

@ -24,8 +24,6 @@
#include <cpustats/ThreadCpuUsage.h>
#endif
#endif
#include <json/json.h>
#include <string>
#include <utils/Debug.h>
#include <utils/Log.h>
#include "FastMixerDumpState.h"
@ -206,49 +204,4 @@ void FastMixerDumpState::dump(int fd) const
}
}
Json::Value FastMixerDumpState::getJsonDump() const
{
Json::Value root(Json::objectValue);
if (mCommand == FastMixerState::INITIAL) {
root["status"] = "uninitialized";
return root;
}
#ifdef FAST_THREAD_STATISTICS
// find the interval of valid samples
const uint32_t bounds = mBounds;
const uint32_t newestOpen = bounds & 0xFFFF;
uint32_t oldestClosed = bounds >> 16;
//uint32_t n = (newestOpen - oldestClosed) & 0xFFFF;
uint32_t n;
__builtin_sub_overflow(newestOpen, oldestClosed, &n);
n &= 0xFFFF;
if (n > mSamplingN) {
ALOGE("too many samples %u", n);
n = mSamplingN;
}
// statistics for monotonic (wall clock) time, thread raw CPU load in time, CPU clock frequency,
// and adjusted CPU load in MHz normalized for CPU clock frequency
Json::Value jsonWall(Json::arrayValue);
Json::Value jsonLoadNs(Json::arrayValue);
// loop over all the samples
for (uint32_t j = 0; j < n; ++j) {
size_t i = oldestClosed++ & (mSamplingN - 1);
uint32_t wallNs = mMonotonicNs[i];
jsonWall.append(wallNs);
uint32_t sampleLoadNs = mLoadNs[i];
jsonLoadNs.append(sampleLoadNs);
}
if (n) {
root["wall_clock_time_ns"] = jsonWall;
root["raw_cpu_load_ns"] = jsonLoadNs;
root["status"] = "ok";
} else {
root["status"] = "unavailable";
}
#endif
return root;
}
} // android

@ -18,9 +18,7 @@
#define ANDROID_AUDIO_FAST_MIXER_DUMP_STATE_H
#include <stdint.h>
#include <string>
#include <audio_utils/TimestampVerifier.h>
#include <json/json.h>
#include "Configuration.h"
#include "FastThreadDumpState.h"
#include "FastMixerState.h"
@ -67,8 +65,7 @@ struct FastMixerDumpState : FastThreadDumpState {
FastMixerDumpState();
/*virtual*/ ~FastMixerDumpState();
void dump(int fd) const; // should only be called on a stable copy, not the original
Json::Value getJsonDump() const; // should only be called on a stable copy, not the original
void dump(int fd) const; // should only be called on a stable copy, not the original
double mLatencyMs = 0.; // measured latency, default of 0 if no valid timestamp read.
uint32_t mWriteSequence; // incremented before and after each write()

@ -42,7 +42,6 @@
#include <audio_utils/primitives.h>
#include <audio_utils/format.h>
#include <audio_utils/minifloat.h>
#include <json/json.h>
#include <system/audio_effects/effect_ns.h>
#include <system/audio_effects/effect_aec.h>
#include <system/audio.h>
@ -1776,11 +1775,6 @@ void AudioFlinger::PlaybackThread::dump(int fd, const Vector<String16>& args)
mLocalLog.dump(fd, " " /* prefix */, 40 /* lines */);
}
Json::Value AudioFlinger::PlaybackThread::getJsonDump() const
{
return Json::Value(Json::objectValue);
}
void AudioFlinger::PlaybackThread::dumpTracks(int fd, const Vector<String16>& args __unused)
{
String8 result;
@ -5182,7 +5176,8 @@ void AudioFlinger::MixerThread::dumpInternals(int fd, const Vector<String16>& ar
// while we are dumping it. It may be inconsistent, but it won't mutate!
// This is a large object so we place it on the heap.
// FIXME 25972958: Need an intelligent copy constructor that does not touch unused pages.
const std::unique_ptr<FastMixerDumpState> copy(new FastMixerDumpState(mFastMixerDumpState));
const std::unique_ptr<FastMixerDumpState> copy =
std::make_unique<FastMixerDumpState>(mFastMixerDumpState);
copy->dump(fd);
#ifdef STATE_QUEUE_DUMP
@ -5206,22 +5201,6 @@ void AudioFlinger::MixerThread::dumpInternals(int fd, const Vector<String16>& ar
}
}
Json::Value AudioFlinger::MixerThread::getJsonDump() const
{
Json::Value root;
if (hasFastMixer()) {
// Make a non-atomic copy of fast mixer dump state so it won't change underneath us
// while we are dumping it. It may be inconsistent, but it won't mutate!
// This is a large object so we place it on the heap.
// FIXME 25972958: Need an intelligent copy constructor that does not touch unused pages.
const std::unique_ptr<FastMixerDumpState> copy(new FastMixerDumpState(mFastMixerDumpState));
root["fastmixer_stats"] = copy->getJsonDump();
} else {
root["fastmixer_stats"] = "no_fastmixer";
}
return root;
}
uint32_t AudioFlinger::MixerThread::idleSleepTimeUs() const
{
return (uint32_t)(((mNormalFrameCount * 1000) / mSampleRate) * 1000) / 2;
@ -7570,7 +7549,8 @@ void AudioFlinger::RecordThread::dumpInternals(int fd, const Vector<String16>& a
// while we are dumping it. It may be inconsistent, but it won't mutate!
// This is a large object so we place it on the heap.
// FIXME 25972958: Need an intelligent copy constructor that does not touch unused pages.
std::unique_ptr<FastCaptureDumpState> copy(new FastCaptureDumpState(mFastCaptureDumpState));
const std::unique_ptr<FastCaptureDumpState> copy =
std::make_unique<FastCaptureDumpState>(mFastCaptureDumpState);
copy->dump(fd);
}

@ -668,8 +668,6 @@ public:
virtual ~PlaybackThread();
void dump(int fd, const Vector<String16>& args) override;
// returns a string of audio performance related data in JSON format.
virtual Json::Value getJsonDump() const;
// Thread virtuals
virtual bool threadLoop();
@ -1116,7 +1114,6 @@ public:
virtual bool checkForNewParameter_l(const String8& keyValuePair,
status_t& status);
virtual void dumpInternals(int fd, const Vector<String16>& args);
Json::Value getJsonDump() const override;
virtual bool isTrackAllowed_l(
audio_channel_mask_t channelMask, audio_format_t format,

Loading…
Cancel
Save