Bug 1244292 - [1.2] Release decoder on init failure. r=snorp
authorEugen Sawin <esawin@mozilla.com>
Tue, 09 Feb 2016 19:50:30 +0100
changeset 330098 9b3787b43a59fbad503822548736b8de75df78e4
parent 330097 66b3222f623ffeb63aa20f30a89d25cc4bc8fbdb
child 330099 d42cc18ad1bd0f4ba94599698cebd8a55f900071
push id10675
push userbmo:james@hoppipolla.co.uk
push dateWed, 10 Feb 2016 15:13:04 +0000
reviewerssnorp
bugs1244292
milestone47.0a1
Bug 1244292 - [1.2] Release decoder on init failure. r=snorp
dom/media/platforms/android/AndroidDecoderModule.cpp
--- a/dom/media/platforms/android/AndroidDecoderModule.cpp
+++ b/dom/media/platforms/android/AndroidDecoderModule.cpp
@@ -735,30 +735,35 @@ MediaCodecDataDecoder::Drain()
 }
 
 
 nsresult
 MediaCodecDataDecoder::Shutdown()
 {
   MonitorAutoLock lock(mMonitor);
 
-  if (!mThread || State() == kStopping) {
+  if (State() == kStopping) {
     // Already shutdown or in the process of doing so
     return NS_OK;
   }
 
   State(kStopping);
   lock.Notify();
 
-  while (State() == kStopping) {
+  while (mThread && State() == kStopping) {
     lock.Wait();
   }
 
-  mThread->Shutdown();
-  mThread = nullptr;
+  if (mThread) {
+    mThread->Shutdown();
+    mThread = nullptr;
+  }
 
-  mDecoder->Stop();
-  mDecoder->Release();
+  if (mDecoder) {
+    mDecoder->Stop();
+    mDecoder->Release();
+    mDecoder = nullptr;
+  }
 
   return NS_OK;
 }
 
 } // mozilla