summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2015-02-18 23:05:27 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-02-18 23:05:27 +0000
commit1fb8290c1f99e1db96b681e6eaae0193ea81674e (patch)
tree8325cc8242245d4c5c29e8ac13d84fea29b20694
parent8d48bed0f29cf008ddc9e56bb0661f34b8e7c724 (diff)
parenta7c1df10d39a8056ca755ccd77b06816c6de3225 (diff)
downloadframeworks_av-1fb8290c1f99e1db96b681e6eaae0193ea81674e.zip
frameworks_av-1fb8290c1f99e1db96b681e6eaae0193ea81674e.tar.gz
frameworks_av-1fb8290c1f99e1db96b681e6eaae0193ea81674e.tar.bz2
am a7c1df10: am a963dacc: am 64753517: Merge "Add dumpsys info"
* commit 'a7c1df10d39a8056ca755ccd77b06816c6de3225': Add dumpsys info
-rw-r--r--include/media/stagefright/foundation/AHandler.h7
-rw-r--r--include/media/stagefright/foundation/ALooperRoster.h3
-rw-r--r--media/libmediaplayerservice/MediaPlayerService.cpp16
-rw-r--r--media/libstagefright/foundation/ALooperRoster.cpp82
4 files changed, 104 insertions, 4 deletions
diff --git a/include/media/stagefright/foundation/AHandler.h b/include/media/stagefright/foundation/AHandler.h
index b008b54..41ade77 100644
--- a/include/media/stagefright/foundation/AHandler.h
+++ b/include/media/stagefright/foundation/AHandler.h
@@ -19,6 +19,7 @@
#define A_HANDLER_H_
#include <media/stagefright/foundation/ALooper.h>
+#include <utils/KeyedVector.h>
#include <utils/RefBase.h>
namespace android {
@@ -27,7 +28,8 @@ struct AMessage;
struct AHandler : public RefBase {
AHandler()
- : mID(0) {
+ : mID(0),
+ mMessageCounter(0) {
}
ALooper::handler_id id() const {
@@ -48,6 +50,9 @@ private:
mID = id;
}
+ uint32_t mMessageCounter;
+ KeyedVector<uint32_t, uint32_t> mMessages;
+
DISALLOW_EVIL_CONSTRUCTORS(AHandler);
};
diff --git a/include/media/stagefright/foundation/ALooperRoster.h b/include/media/stagefright/foundation/ALooperRoster.h
index 4d76b64..a0be8eb 100644
--- a/include/media/stagefright/foundation/ALooperRoster.h
+++ b/include/media/stagefright/foundation/ALooperRoster.h
@@ -20,6 +20,7 @@
#include <media/stagefright/foundation/ALooper.h>
#include <utils/KeyedVector.h>
+#include <utils/String16.h>
namespace android {
@@ -42,6 +43,8 @@ struct ALooperRoster {
sp<ALooper> findLooper(ALooper::handler_id handlerID);
+ void dump(int fd, const Vector<String16>& args);
+
private:
struct HandlerInfo {
wp<ALooper> mLooper;
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index 1936218..694f1a4 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -59,6 +59,7 @@
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/AudioPlayer.h>
#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/ALooperRoster.h>
#include <system/audio.h>
@@ -247,6 +248,9 @@ void unmarshallAudioAttributes(const Parcel& parcel, audio_attributes_t *attribu
namespace android {
+extern ALooperRoster gLooperRoster;
+
+
static bool checkPermission(const char* permissionString) {
#ifndef HAVE_ANDROID_OS
return true;
@@ -428,6 +432,10 @@ status_t MediaPlayerService::Client::dump(int fd, const Vector<String16>& args)
return NO_ERROR;
}
+/**
+ * The only arguments this understands right now are -c, -von and -voff,
+ * which are parsed by ALooperRoster::dump()
+ */
status_t MediaPlayerService::dump(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
@@ -461,7 +469,7 @@ status_t MediaPlayerService::dump(int fd, const Vector<String16>& args)
}
result.append(" Files opened and/or mapped:\n");
- snprintf(buffer, SIZE, "/proc/%d/maps", gettid());
+ snprintf(buffer, SIZE, "/proc/%d/maps", getpid());
FILE *f = fopen(buffer, "r");
if (f) {
while (!feof(f)) {
@@ -481,13 +489,13 @@ status_t MediaPlayerService::dump(int fd, const Vector<String16>& args)
result.append("\n");
}
- snprintf(buffer, SIZE, "/proc/%d/fd", gettid());
+ snprintf(buffer, SIZE, "/proc/%d/fd", getpid());
DIR *d = opendir(buffer);
if (d) {
struct dirent *ent;
while((ent = readdir(d)) != NULL) {
if (strcmp(ent->d_name,".") && strcmp(ent->d_name,"..")) {
- snprintf(buffer, SIZE, "/proc/%d/fd/%s", gettid(), ent->d_name);
+ snprintf(buffer, SIZE, "/proc/%d/fd/%s", getpid(), ent->d_name);
struct stat s;
if (lstat(buffer, &s) == 0) {
if ((s.st_mode & S_IFMT) == S_IFLNK) {
@@ -528,6 +536,8 @@ status_t MediaPlayerService::dump(int fd, const Vector<String16>& args)
result.append("\n");
}
+ gLooperRoster.dump(fd, args);
+
bool dumpMem = false;
for (size_t i = 0; i < args.size(); i++) {
if (args[i] == String16("-m")) {
diff --git a/media/libstagefright/foundation/ALooperRoster.cpp b/media/libstagefright/foundation/ALooperRoster.cpp
index e0dc768..2d57aee 100644
--- a/media/libstagefright/foundation/ALooperRoster.cpp
+++ b/media/libstagefright/foundation/ALooperRoster.cpp
@@ -17,6 +17,7 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "ALooperRoster"
#include <utils/Log.h>
+#include <utils/String8.h>
#include "ALooperRoster.h"
@@ -26,6 +27,8 @@
namespace android {
+static bool verboseStats = false;
+
ALooperRoster::ALooperRoster()
: mNextHandlerID(1),
mNextReplyID(1) {
@@ -136,6 +139,17 @@ void ALooperRoster::deliverMessage(const sp<AMessage> &msg) {
}
handler->onMessageReceived(msg);
+ handler->mMessageCounter++;
+
+ if (verboseStats) {
+ uint32_t what = msg->what();
+ ssize_t idx = handler->mMessages.indexOfKey(what);
+ if (idx < 0) {
+ handler->mMessages.add(what, 1);
+ } else {
+ handler->mMessages.editValueAt(idx)++;
+ }
+ }
}
sp<ALooper> ALooperRoster::findLooper(ALooper::handler_id handlerID) {
@@ -196,4 +210,72 @@ void ALooperRoster::postReply(uint32_t replyID, const sp<AMessage> &reply) {
mRepliesCondition.broadcast();
}
+static void makeFourCC(uint32_t fourcc, char *s) {
+ s[0] = (fourcc >> 24) & 0xff;
+ if (s[0]) {
+ s[1] = (fourcc >> 16) & 0xff;
+ s[2] = (fourcc >> 8) & 0xff;
+ s[3] = fourcc & 0xff;
+ s[4] = 0;
+ } else {
+ sprintf(s, "%u", fourcc);
+ }
+}
+
+void ALooperRoster::dump(int fd, const Vector<String16>& args) {
+ bool clear = false;
+ bool oldVerbose = verboseStats;
+ for (size_t i = 0;i < args.size(); i++) {
+ if (args[i] == String16("-c")) {
+ clear = true;
+ } else if (args[i] == String16("-von")) {
+ verboseStats = true;
+ } else if (args[i] == String16("-voff")) {
+ verboseStats = false;
+ }
+ }
+ String8 s;
+ if (verboseStats && !oldVerbose) {
+ s.append("(verbose stats collection enabled, stats will be cleared)\n");
+ }
+
+ Mutex::Autolock autoLock(mLock);
+ size_t n = mHandlers.size();
+ s.appendFormat(" %zd registered handlers:\n", n);
+
+ for (size_t i = 0; i < n; i++) {
+ s.appendFormat(" %zd: ", i);
+ HandlerInfo &info = mHandlers.editValueAt(i);
+ sp<ALooper> looper = info.mLooper.promote();
+ if (looper != NULL) {
+ s.append(looper->mName.c_str());
+ sp<AHandler> handler = info.mHandler.promote();
+ if (handler != NULL) {
+ s.appendFormat(": %u messages processed", handler->mMessageCounter);
+ if (verboseStats) {
+ for (size_t j = 0; j < handler->mMessages.size(); j++) {
+ char fourcc[15];
+ makeFourCC(handler->mMessages.keyAt(j), fourcc);
+ s.appendFormat("\n %s: %d",
+ fourcc,
+ handler->mMessages.valueAt(j));
+ }
+ } else {
+ handler->mMessages.clear();
+ }
+ if (clear || (verboseStats && !oldVerbose)) {
+ handler->mMessageCounter = 0;
+ handler->mMessages.clear();
+ }
+ } else {
+ s.append(": <stale handler>");
+ }
+ } else {
+ s.append("<stale>");
+ }
+ s.append("\n");
+ }
+ write(fd, s.string(), s.size());
+}
+
} // namespace android