WebmFrameThread: clear mThread after join.
Bug: 36260305
Test: cts-tradefed run cts-dev --module CtsMediaTestCases --test android.media.cts.NativeDecoderTest
Change-Id: Ifd0ce7d6df71e514b26a4cc2b1c4fe99eacf0f7e
diff --git a/media/libstagefright/webm/WebmFrameThread.cpp b/media/libstagefright/webm/WebmFrameThread.cpp
index 7eb4745..77de3c8 100644
--- a/media/libstagefright/webm/WebmFrameThread.cpp
+++ b/media/libstagefright/webm/WebmFrameThread.cpp
@@ -37,17 +37,23 @@
}
status_t WebmFrameThread::start() {
+ status_t err = OK;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
- pthread_create(&mThread, &attr, WebmFrameThread::wrap, this);
+ if ((err = pthread_create(&mThread, &attr, WebmFrameThread::wrap, this))) {
+ mThread = 0;
+ }
pthread_attr_destroy(&attr);
- return OK;
+ return err;
}
status_t WebmFrameThread::stop() {
- void *status;
- pthread_join(mThread, &status);
+ void *status = nullptr;
+ if (mThread) {
+ pthread_join(mThread, &status);
+ mThread = 0;
+ }
return (status_t)(intptr_t)status;
}