aaudio: name threads for easier debugging
Name them "AAudio_#" where # is an increasing index.
For example AAudio_1, AAudio_2, etc.
Also name threads that are used for sending timestamps.
Test: run write_sine_callback then dump the threads for that process.
Change-Id: Ibd8c7be1109f6c15a4601ef154038cdce2e65e11
diff --git a/services/oboeservice/AAudioThread.h b/services/oboeservice/AAudioThread.h
index 02f1459..ffc9b7b 100644
--- a/services/oboeservice/AAudioThread.h
+++ b/services/oboeservice/AAudioThread.h
@@ -43,7 +43,9 @@
{
public:
AAudioThread();
- AAudioThread(Runnable *runnable);
+
+ AAudioThread(const char *prefix);
+
virtual ~AAudioThread() = default;
/**
@@ -66,10 +68,15 @@
void dispatch(); // called internally from 'C' thread wrapper
private:
- Runnable *mRunnable;
- bool mHasThread;
+
+ void setup(const char *prefix);
+
+ Runnable *mRunnable = nullptr;
+ bool mHasThread = false;
pthread_t mThread; // initialized in constructor
+ static std::atomic<uint32_t> mNextThreadIndex;
+ char mName[16]; // max length for a pthread_name
};
} /* namespace aaudio */