From 730ba19bc8c097fdcbee3adb04e86d435640bb72 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Tue, 4 Jan 2011 11:58:04 -0800 Subject: [PATCH] Fix issue 3302649. The cause of the problem is that AudioTrack::start() can fail if it is called from a newly created thread that has the same ID as the AudioTrack callback thread that has just been stopped and not yet exited. This is possible as the thread ID used by the Thread class is not the TID. The fix consists in clearing the thread ID before exiting the thread loop. Change-Id: I66e679665c384403cb3ba2c31746f5de72d5836d --- libs/utils/Threads.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/utils/Threads.cpp b/libs/utils/Threads.cpp index f6c55e4d89de..ad9a94f594f5 100644 --- a/libs/utils/Threads.cpp +++ b/libs/utils/Threads.cpp @@ -774,6 +774,9 @@ int Thread::_threadLoop(void* user) self->mExitPending = true; self->mLock.lock(); self->mRunning = false; + // clear thread ID so that requestExitAndWait() does not exit if + // called by a new thread using the same thread ID as this one. + self->mThread = thread_id_t(-1); self->mThreadExitedCondition.broadcast(); self->mLock.unlock(); break; -- 2.11.0