Loading media/audioserver/Android.mk +3 −0 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,9 @@ LOCAL_SHARED_LIBRARIES := \ libsoundtriggerservice \ libsoundtriggerservice \ libutils libutils LOCAL_STATIC_LIBRARIES := \ libjsoncpp # TODO oboeservice is the old folder name for aaudioservice. It will be changed. # TODO oboeservice is the old folder name for aaudioservice. It will be changed. LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES := \ frameworks/av/services/audioflinger \ frameworks/av/services/audioflinger \ Loading services/audioflinger/Android.mk +1 −0 Original line number Original line Diff line number Diff line Loading @@ -42,6 +42,7 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_STATIC_LIBRARIES := \ LOCAL_STATIC_LIBRARIES := \ libcpustats \ libcpustats \ libjsoncpp \ libsndfile \ libsndfile \ LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB) LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB) Loading services/audioflinger/AudioFlinger.cpp +14 −13 Original line number Original line Diff line number Diff line Loading @@ -58,6 +58,8 @@ #include <audio_utils/primitives.h> #include <audio_utils/primitives.h> #include <json/json.h> #include <powermanager/PowerManager.h> #include <powermanager/PowerManager.h> #include <media/IMediaLogService.h> #include <media/IMediaLogService.h> Loading Loading @@ -440,8 +442,11 @@ status_t AudioFlinger::dump(int fd, const Vector<String16>& args) const bool formatJson = std::any_of(args.begin(), args.end(), const bool formatJson = std::any_of(args.begin(), args.end(), [](const String16 &arg) { return arg == String16("--json"); }); [](const String16 &arg) { return arg == String16("--json"); }); if (formatJson) { 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. // XXX consider buffering if the string happens to be too long. dprintf(fd, "%s", getJsonString().c_str()); dprintf(fd, "%s", rootStr.c_str()); return NO_ERROR; return NO_ERROR; } } Loading Loading @@ -556,34 +561,30 @@ status_t AudioFlinger::dump(int fd, const Vector<String16>& args) return NO_ERROR; return NO_ERROR; } } std::string AudioFlinger::getJsonString() Json::Value AudioFlinger::getJsonDump() { { std::string jsonStr = "{\n"; Json::Value root(Json::objectValue); const bool locked = dumpTryLock(mLock); const bool locked = dumpTryLock(mLock); // failed to lock - AudioFlinger is probably deadlocked // failed to lock - AudioFlinger is probably deadlocked if (!locked) { if (!locked) { jsonStr += " \"deadlock_message\": "; root["deadlock_message"] = kDeadlockedString; jsonStr += kDeadlockedString; jsonStr += ",\n"; } } // FIXME risky to access data structures without a lock held? // FIXME risky to access data structures without a lock held? jsonStr += " \"Playback_Threads\": [\n"; Json::Value playbackThreads = Json::arrayValue; // dump playback threads // dump playback threads for (size_t i = 0; i < mPlaybackThreads.size(); i++) { for (size_t i = 0; i < mPlaybackThreads.size(); i++) { if (i != 0) { playbackThreads.append(mPlaybackThreads.valueAt(i)->getJsonDump()); jsonStr += ",\n"; } jsonStr += mPlaybackThreads.valueAt(i)->getJsonString(); } } jsonStr += "\n ]\n}\n"; if (locked) { if (locked) { mLock.unlock(); mLock.unlock(); } } return jsonStr; root["playback_threads"] = playbackThreads; return root; } } sp<AudioFlinger::Client> AudioFlinger::registerPid(pid_t pid) sp<AudioFlinger::Client> AudioFlinger::registerPid(pid_t pid) Loading services/audioflinger/AudioFlinger.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -79,6 +79,7 @@ #include <powermanager/IPowerManager.h> #include <powermanager/IPowerManager.h> #include <json/json.h> #include <media/nblog/NBLog.h> #include <media/nblog/NBLog.h> #include <private/media/AudioEffectShared.h> #include <private/media/AudioEffectShared.h> #include <private/media/AudioTrackShared.h> #include <private/media/AudioTrackShared.h> Loading Loading @@ -114,7 +115,7 @@ public: static const char* getServiceName() ANDROID_API { return "media.audio_flinger"; } static const char* getServiceName() ANDROID_API { return "media.audio_flinger"; } virtual status_t dump(int fd, const Vector<String16>& args); virtual status_t dump(int fd, const Vector<String16>& args); std::string getJsonString(); Json::Value getJsonDump(); // IAudioFlinger interface, in binder opcode order // IAudioFlinger interface, in binder opcode order virtual sp<IAudioTrack> createTrack(const CreateTrackInput& input, virtual sp<IAudioTrack> createTrack(const CreateTrackInput& input, Loading services/audioflinger/FastMixerDumpState.cpp +14 −20 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <cpustats/ThreadCpuUsage.h> #include <cpustats/ThreadCpuUsage.h> #endif #endif #endif #endif #include <json/json.h> #include <string> #include <string> #include <utils/Debug.h> #include <utils/Debug.h> #include <utils/Log.h> #include <utils/Log.h> Loading Loading @@ -205,14 +206,13 @@ void FastMixerDumpState::dump(int fd) const } } } } // TODO get rid of extraneous lines and use better key names. Json::Value FastMixerDumpState::getJsonDump() const // TODO may go back to using a library to do the json formatting. std::string FastMixerDumpState::getJsonString() const { { Json::Value root(Json::objectValue); if (mCommand == FastMixerState::INITIAL) { if (mCommand == FastMixerState::INITIAL) { return " {\n \"status\": \"uninitialized\"\n }"; root["status"] = "uninitialized"; return root; } } std::string jsonStr = " {\n"; #ifdef FAST_THREAD_STATISTICS #ifdef FAST_THREAD_STATISTICS // find the interval of valid samples // find the interval of valid samples const uint32_t bounds = mBounds; const uint32_t bounds = mBounds; Loading @@ -230,31 +230,25 @@ std::string FastMixerDumpState::getJsonString() const } } // statistics for monotonic (wall clock) time, thread raw CPU load in time, CPU clock frequency, // 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 // and adjusted CPU load in MHz normalized for CPU clock frequency std::string jsonWallStr = " \"wall_clock_time\":["; Json::Value jsonWall(Json::arrayValue); std::string jsonLoadNsStr = " \"raw_cpu_load\":["; Json::Value jsonLoadNs(Json::arrayValue); // loop over all the samples // loop over all the samples for (uint32_t j = 0; j < n; ++j) { for (uint32_t j = 0; j < n; ++j) { size_t i = oldestClosed++ & (mSamplingN - 1); size_t i = oldestClosed++ & (mSamplingN - 1); uint32_t wallNs = mMonotonicNs[i]; uint32_t wallNs = mMonotonicNs[i]; if (j != 0) { jsonWall.append(wallNs); jsonWallStr += ','; jsonLoadNsStr += ','; } /* jsonObject["wall"].append(wallNs); */ jsonWallStr += std::to_string(wallNs); uint32_t sampleLoadNs = mLoadNs[i]; uint32_t sampleLoadNs = mLoadNs[i]; jsonLoadNsStr += std::to_string(sampleLoadNs); jsonLoadNs.append(sampleLoadNs); } } jsonWallStr += ']'; jsonLoadNsStr += ']'; if (n) { if (n) { jsonStr += jsonWallStr + ",\n" + jsonLoadNsStr + "\n"; root["wall_clock_time_ns"] = jsonWall; root["raw_cpu_load_ns"] = jsonLoadNs; root["status"] = "ok"; } else { } else { //dprintf(fd, " No FastMixer statistics available currently\n"); root["status"] = "unavailable"; } } #endif #endif jsonStr += " }"; return root; return jsonStr; } } } // android } // android Loading
media/audioserver/Android.mk +3 −0 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,9 @@ LOCAL_SHARED_LIBRARIES := \ libsoundtriggerservice \ libsoundtriggerservice \ libutils libutils LOCAL_STATIC_LIBRARIES := \ libjsoncpp # TODO oboeservice is the old folder name for aaudioservice. It will be changed. # TODO oboeservice is the old folder name for aaudioservice. It will be changed. LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES := \ frameworks/av/services/audioflinger \ frameworks/av/services/audioflinger \ Loading
services/audioflinger/Android.mk +1 −0 Original line number Original line Diff line number Diff line Loading @@ -42,6 +42,7 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_STATIC_LIBRARIES := \ LOCAL_STATIC_LIBRARIES := \ libcpustats \ libcpustats \ libjsoncpp \ libsndfile \ libsndfile \ LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB) LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB) Loading
services/audioflinger/AudioFlinger.cpp +14 −13 Original line number Original line Diff line number Diff line Loading @@ -58,6 +58,8 @@ #include <audio_utils/primitives.h> #include <audio_utils/primitives.h> #include <json/json.h> #include <powermanager/PowerManager.h> #include <powermanager/PowerManager.h> #include <media/IMediaLogService.h> #include <media/IMediaLogService.h> Loading Loading @@ -440,8 +442,11 @@ status_t AudioFlinger::dump(int fd, const Vector<String16>& args) const bool formatJson = std::any_of(args.begin(), args.end(), const bool formatJson = std::any_of(args.begin(), args.end(), [](const String16 &arg) { return arg == String16("--json"); }); [](const String16 &arg) { return arg == String16("--json"); }); if (formatJson) { 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. // XXX consider buffering if the string happens to be too long. dprintf(fd, "%s", getJsonString().c_str()); dprintf(fd, "%s", rootStr.c_str()); return NO_ERROR; return NO_ERROR; } } Loading Loading @@ -556,34 +561,30 @@ status_t AudioFlinger::dump(int fd, const Vector<String16>& args) return NO_ERROR; return NO_ERROR; } } std::string AudioFlinger::getJsonString() Json::Value AudioFlinger::getJsonDump() { { std::string jsonStr = "{\n"; Json::Value root(Json::objectValue); const bool locked = dumpTryLock(mLock); const bool locked = dumpTryLock(mLock); // failed to lock - AudioFlinger is probably deadlocked // failed to lock - AudioFlinger is probably deadlocked if (!locked) { if (!locked) { jsonStr += " \"deadlock_message\": "; root["deadlock_message"] = kDeadlockedString; jsonStr += kDeadlockedString; jsonStr += ",\n"; } } // FIXME risky to access data structures without a lock held? // FIXME risky to access data structures without a lock held? jsonStr += " \"Playback_Threads\": [\n"; Json::Value playbackThreads = Json::arrayValue; // dump playback threads // dump playback threads for (size_t i = 0; i < mPlaybackThreads.size(); i++) { for (size_t i = 0; i < mPlaybackThreads.size(); i++) { if (i != 0) { playbackThreads.append(mPlaybackThreads.valueAt(i)->getJsonDump()); jsonStr += ",\n"; } jsonStr += mPlaybackThreads.valueAt(i)->getJsonString(); } } jsonStr += "\n ]\n}\n"; if (locked) { if (locked) { mLock.unlock(); mLock.unlock(); } } return jsonStr; root["playback_threads"] = playbackThreads; return root; } } sp<AudioFlinger::Client> AudioFlinger::registerPid(pid_t pid) sp<AudioFlinger::Client> AudioFlinger::registerPid(pid_t pid) Loading
services/audioflinger/AudioFlinger.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -79,6 +79,7 @@ #include <powermanager/IPowerManager.h> #include <powermanager/IPowerManager.h> #include <json/json.h> #include <media/nblog/NBLog.h> #include <media/nblog/NBLog.h> #include <private/media/AudioEffectShared.h> #include <private/media/AudioEffectShared.h> #include <private/media/AudioTrackShared.h> #include <private/media/AudioTrackShared.h> Loading Loading @@ -114,7 +115,7 @@ public: static const char* getServiceName() ANDROID_API { return "media.audio_flinger"; } static const char* getServiceName() ANDROID_API { return "media.audio_flinger"; } virtual status_t dump(int fd, const Vector<String16>& args); virtual status_t dump(int fd, const Vector<String16>& args); std::string getJsonString(); Json::Value getJsonDump(); // IAudioFlinger interface, in binder opcode order // IAudioFlinger interface, in binder opcode order virtual sp<IAudioTrack> createTrack(const CreateTrackInput& input, virtual sp<IAudioTrack> createTrack(const CreateTrackInput& input, Loading
services/audioflinger/FastMixerDumpState.cpp +14 −20 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <cpustats/ThreadCpuUsage.h> #include <cpustats/ThreadCpuUsage.h> #endif #endif #endif #endif #include <json/json.h> #include <string> #include <string> #include <utils/Debug.h> #include <utils/Debug.h> #include <utils/Log.h> #include <utils/Log.h> Loading Loading @@ -205,14 +206,13 @@ void FastMixerDumpState::dump(int fd) const } } } } // TODO get rid of extraneous lines and use better key names. Json::Value FastMixerDumpState::getJsonDump() const // TODO may go back to using a library to do the json formatting. std::string FastMixerDumpState::getJsonString() const { { Json::Value root(Json::objectValue); if (mCommand == FastMixerState::INITIAL) { if (mCommand == FastMixerState::INITIAL) { return " {\n \"status\": \"uninitialized\"\n }"; root["status"] = "uninitialized"; return root; } } std::string jsonStr = " {\n"; #ifdef FAST_THREAD_STATISTICS #ifdef FAST_THREAD_STATISTICS // find the interval of valid samples // find the interval of valid samples const uint32_t bounds = mBounds; const uint32_t bounds = mBounds; Loading @@ -230,31 +230,25 @@ std::string FastMixerDumpState::getJsonString() const } } // statistics for monotonic (wall clock) time, thread raw CPU load in time, CPU clock frequency, // 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 // and adjusted CPU load in MHz normalized for CPU clock frequency std::string jsonWallStr = " \"wall_clock_time\":["; Json::Value jsonWall(Json::arrayValue); std::string jsonLoadNsStr = " \"raw_cpu_load\":["; Json::Value jsonLoadNs(Json::arrayValue); // loop over all the samples // loop over all the samples for (uint32_t j = 0; j < n; ++j) { for (uint32_t j = 0; j < n; ++j) { size_t i = oldestClosed++ & (mSamplingN - 1); size_t i = oldestClosed++ & (mSamplingN - 1); uint32_t wallNs = mMonotonicNs[i]; uint32_t wallNs = mMonotonicNs[i]; if (j != 0) { jsonWall.append(wallNs); jsonWallStr += ','; jsonLoadNsStr += ','; } /* jsonObject["wall"].append(wallNs); */ jsonWallStr += std::to_string(wallNs); uint32_t sampleLoadNs = mLoadNs[i]; uint32_t sampleLoadNs = mLoadNs[i]; jsonLoadNsStr += std::to_string(sampleLoadNs); jsonLoadNs.append(sampleLoadNs); } } jsonWallStr += ']'; jsonLoadNsStr += ']'; if (n) { if (n) { jsonStr += jsonWallStr + ",\n" + jsonLoadNsStr + "\n"; root["wall_clock_time_ns"] = jsonWall; root["raw_cpu_load_ns"] = jsonLoadNs; root["status"] = "ok"; } else { } else { //dprintf(fd, " No FastMixer statistics available currently\n"); root["status"] = "unavailable"; } } #endif #endif jsonStr += " }"; return root; return jsonStr; } } } // android } // android