From 267ba2dd90a746be46c62174dfa444d2a4e13b5e Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Tue, 5 Aug 2014 10:18:31 +1200 Subject: [PATCH] Bug 1048102 - Delete GMPThreads as they're joined. r=jesup --- content/media/gmp/GMPPlatform.cpp | 11 ++++++++--- content/media/gmp/gmp-api/gmp-platform.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/content/media/gmp/GMPPlatform.cpp b/content/media/gmp/GMPPlatform.cpp index 3ba7ac5c3e0..1261db3a8a7 100644 --- a/content/media/gmp/GMPPlatform.cpp +++ b/content/media/gmp/GMPPlatform.cpp @@ -162,10 +162,12 @@ GMPThreadImpl::GMPThreadImpl() : mMutex("GMPThreadImpl"), mThread("GMPThread") { + MOZ_COUNT_CTOR(GMPThread); } GMPThreadImpl::~GMPThreadImpl() { + MOZ_COUNT_DTOR(GMPThread); } void @@ -189,10 +191,13 @@ GMPThreadImpl::Post(GMPTask* aTask) void GMPThreadImpl::Join() { - MutexAutoLock lock(mMutex); - if (mThread.IsRunning()) { - mThread.Stop(); + { + MutexAutoLock lock(mMutex); + if (mThread.IsRunning()) { + mThread.Stop(); + } } + delete this; } GMPMutexImpl::GMPMutexImpl() diff --git a/content/media/gmp/gmp-api/gmp-platform.h b/content/media/gmp/gmp-api/gmp-platform.h index ada2a449086..e84d6906f61 100644 --- a/content/media/gmp/gmp-api/gmp-platform.h +++ b/content/media/gmp/gmp-api/gmp-platform.h @@ -50,7 +50,7 @@ class GMPThread { public: virtual ~GMPThread() {} virtual void Post(GMPTask* aTask) = 0; - virtual void Join() = 0; + virtual void Join() = 0; // Deletes GMPThread! }; class GMPMutex {