Loading media/libaaudio/src/core/AudioStream.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,17 @@ aaudio_result_t AudioStream::createThread(int64_t periodNanoseconds, if (err != 0) { return AAudioConvert_androidToAAudioResult(-errno); } else { // Name the thread with an increasing index, "AAudio_#", for debugging. static std::atomic<uint32_t> nextThreadIndex{1}; char name[16]; // max length for a pthread_name uint32_t index = nextThreadIndex++; // Wrap the index so that we do not hit the 16 char limit // and to avoid hard-to-read large numbers. index = index % 100000; // arbitrary snprintf(name, sizeof(name), "AAudio_%u", index); err = pthread_setname_np(mThread, name); ALOGW_IF((err != 0), "Could not set name of AAudio thread. err = %d", err); mHasThread = true; return AAUDIO_OK; } Loading services/oboeservice/AAudioServiceStreamBase.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ using namespace aaudio; // TODO just import names needed AAudioServiceStreamBase::AAudioServiceStreamBase(AAudioService &audioService) : mUpMessageQueue(nullptr) , mTimestampThread() , mTimestampThread("AATime") , mAtomicTimestamp() , mAudioService(audioService) { mMmapClient.clientUid = -1; Loading services/oboeservice/AAudioThread.cpp +19 −3 Original line number Diff line number Diff line Loading @@ -27,12 +27,26 @@ using namespace aaudio; std::atomic<uint32_t> AAudioThread::mNextThreadIndex{1}; AAudioThread::AAudioThread() : mRunnable(nullptr) , mHasThread(false) { AAudioThread::AAudioThread(const char *prefix) { setup(prefix); } AAudioThread::AAudioThread() { setup("AAudio"); } void AAudioThread::setup(const char *prefix) { // mThread is a pthread_t of unknown size so we need memset(). memset(&mThread, 0, sizeof(mThread)); // Name the thread with an increasing index, "prefix_#", for debugging. uint32_t index = mNextThreadIndex++; // Wrap the index so that we do not hit the 16 char limit // and to avoid hard-to-read large numbers. index = index % 100000; // arbitrary snprintf(mName, sizeof(mName), "%s_%u", prefix, index); } void AAudioThread::dispatch() { Loading Loading @@ -64,6 +78,8 @@ aaudio_result_t AAudioThread::start(Runnable *runnable) { ALOGE("start() - pthread_create() returned %d %s", err, strerror(err)); return AAudioConvert_androidToAAudioResult(-err); } else { int err = pthread_setname_np(mThread, mName); ALOGW_IF((err != 0), "Could not set name of AAudioThread. err = %d", err); mHasThread = true; return AAUDIO_OK; } Loading services/oboeservice/AAudioThread.h +10 −3 Original line number Diff line number Diff line Loading @@ -43,7 +43,9 @@ class AAudioThread { public: AAudioThread(); AAudioThread(Runnable *runnable); AAudioThread(const char *prefix); virtual ~AAudioThread() = default; /** Loading @@ -66,10 +68,15 @@ public: 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 */ Loading Loading
media/libaaudio/src/core/AudioStream.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,17 @@ aaudio_result_t AudioStream::createThread(int64_t periodNanoseconds, if (err != 0) { return AAudioConvert_androidToAAudioResult(-errno); } else { // Name the thread with an increasing index, "AAudio_#", for debugging. static std::atomic<uint32_t> nextThreadIndex{1}; char name[16]; // max length for a pthread_name uint32_t index = nextThreadIndex++; // Wrap the index so that we do not hit the 16 char limit // and to avoid hard-to-read large numbers. index = index % 100000; // arbitrary snprintf(name, sizeof(name), "AAudio_%u", index); err = pthread_setname_np(mThread, name); ALOGW_IF((err != 0), "Could not set name of AAudio thread. err = %d", err); mHasThread = true; return AAUDIO_OK; } Loading
services/oboeservice/AAudioServiceStreamBase.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ using namespace aaudio; // TODO just import names needed AAudioServiceStreamBase::AAudioServiceStreamBase(AAudioService &audioService) : mUpMessageQueue(nullptr) , mTimestampThread() , mTimestampThread("AATime") , mAtomicTimestamp() , mAudioService(audioService) { mMmapClient.clientUid = -1; Loading
services/oboeservice/AAudioThread.cpp +19 −3 Original line number Diff line number Diff line Loading @@ -27,12 +27,26 @@ using namespace aaudio; std::atomic<uint32_t> AAudioThread::mNextThreadIndex{1}; AAudioThread::AAudioThread() : mRunnable(nullptr) , mHasThread(false) { AAudioThread::AAudioThread(const char *prefix) { setup(prefix); } AAudioThread::AAudioThread() { setup("AAudio"); } void AAudioThread::setup(const char *prefix) { // mThread is a pthread_t of unknown size so we need memset(). memset(&mThread, 0, sizeof(mThread)); // Name the thread with an increasing index, "prefix_#", for debugging. uint32_t index = mNextThreadIndex++; // Wrap the index so that we do not hit the 16 char limit // and to avoid hard-to-read large numbers. index = index % 100000; // arbitrary snprintf(mName, sizeof(mName), "%s_%u", prefix, index); } void AAudioThread::dispatch() { Loading Loading @@ -64,6 +78,8 @@ aaudio_result_t AAudioThread::start(Runnable *runnable) { ALOGE("start() - pthread_create() returned %d %s", err, strerror(err)); return AAudioConvert_androidToAAudioResult(-err); } else { int err = pthread_setname_np(mThread, mName); ALOGW_IF((err != 0), "Could not set name of AAudioThread. err = %d", err); mHasThread = true; return AAUDIO_OK; } Loading
services/oboeservice/AAudioThread.h +10 −3 Original line number Diff line number Diff line Loading @@ -43,7 +43,9 @@ class AAudioThread { public: AAudioThread(); AAudioThread(Runnable *runnable); AAudioThread(const char *prefix); virtual ~AAudioThread() = default; /** Loading @@ -66,10 +68,15 @@ public: 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 */ Loading