Bug 1188870: Properly release decoder before destruction. r=snorp
authorJean-Yves Avenard <jyavenard@mozilla.com>
Sat, 08 Aug 2015 20:22:50 +1000
changeset 256984 8c8b24ff97b6fa8d25c24ca2b8c1e7d4f1e74946
parent 256983 b40bed41a51125762dace4bee8ae0f69b8aff1bc
child 256985 3254dd5330795ea6b610d5a41cfa48bf419d7c4d
push idunknown
push userunknown
push dateunknown
reviewerssnorp
bugs1188870
milestone42.0a1
Bug 1188870: Properly release decoder before destruction. r=snorp The comment in android's source code is rather explicit: // Client MUST call release before releasing final reference to this // object.
dom/media/platforms/android/AndroidDecoderModule.cpp
--- a/dom/media/platforms/android/AndroidDecoderModule.cpp
+++ b/dom/media/platforms/android/AndroidDecoderModule.cpp
@@ -253,21 +253,28 @@ public:
 };
 
 
 bool AndroidDecoderModule::SupportsMimeType(const nsACString& aMimeType)
 {
   if (!AndroidBridge::Bridge() || (AndroidBridge::Bridge()->GetAPIVersion() < 16)) {
     return false;
   }
+
   if (aMimeType.EqualsLiteral("video/mp4") ||
       aMimeType.EqualsLiteral("video/avc")) {
     return true;
   }
-  return static_cast<bool>(mozilla::CreateDecoder(aMimeType));
+
+  MediaCodec::LocalRef ref = mozilla::CreateDecoder(aMimeType);
+  if (!ref) {
+    return false;
+  }
+  ref->Release();
+  return true;
 }
 
 already_AddRefed<MediaDataDecoder>
 AndroidDecoderModule::CreateVideoDecoder(
                                 const VideoInfo& aConfig,
                                 layers::LayersBackend aLayersBackend,
                                 layers::ImageContainer* aImageContainer,
                                 FlushableTaskQueue* aVideoTaskQueue,