aaudio: improved dumpsys
Add more information about various streams and endpoints.
Bug: 38396780
Test: adb shell dumpsys media.aaudio
Change-Id: I5cc116574bfc3aa93703c182d933dbdfcbefad7a
diff --git a/services/oboeservice/AAudioServiceEndpoint.cpp b/services/oboeservice/AAudioServiceEndpoint.cpp
index 1df2365..b519829 100644
--- a/services/oboeservice/AAudioServiceEndpoint.cpp
+++ b/services/oboeservice/AAudioServiceEndpoint.cpp
@@ -18,16 +18,17 @@
//#define LOG_NDEBUG 0
#include <utils/Log.h>
+#include <algorithm>
#include <assert.h>
#include <map>
#include <mutex>
+#include <sstream>
+#include <vector>
+
#include <utils/Singleton.h>
#include "AAudioEndpointManager.h"
#include "AAudioServiceEndpoint.h"
-#include <algorithm>
-#include <mutex>
-#include <vector>
#include "core/AudioStreamBuilder.h"
#include "AAudioServiceEndpoint.h"
@@ -44,6 +45,35 @@
// This is the maximum size in frames. The effective size can be tuned smaller at runtime.
#define DEFAULT_BUFFER_CAPACITY (48 * 8)
+std::string AAudioServiceEndpoint::dump() const {
+ std::stringstream result;
+
+ const bool isLocked = AAudio_tryUntilTrue(
+ [this]()->bool { return mLockStreams.try_lock(); } /* f */,
+ 50 /* times */,
+ 20 /* sleepMs */);
+ if (!isLocked) {
+ result << "EndpointManager may be deadlocked\n";
+ }
+
+ AudioStreamInternal *stream = mStreamInternal;
+ if (stream == nullptr) {
+ result << "null stream!" << "\n";
+ } else {
+ result << "mmap stream: rate = " << stream->getSampleRate() << "\n";
+ }
+
+ result << " Registered Streams:" << "\n";
+ for (sp<AAudioServiceStreamShared> sharedStream : mRegisteredStreams) {
+ result << sharedStream->dump();
+ }
+
+ if (isLocked) {
+ mLockStreams.unlock();
+ }
+ return result.str();
+}
+
// Set up an EXCLUSIVE MMAP stream that will be shared.
aaudio_result_t AAudioServiceEndpoint::open(const AAudioStreamConfiguration& configuration) {
mRequestedDeviceId = configuration.getDeviceId();