Bug 1029552 - Release HW resource when the MediaElement UnbindFromTree. r=cpearce
authorBenjamin Chen <bechen@mozilla.com>
Mon, 13 Oct 2014 12:07:42 +0800
changeset 233290 9ed77991d70f4b350270edad2014cd2357527f2f
parent 233289 42f385becea7de066e18d6ac744153f0c198ac34
child 233293 4ac3085a4111925af888408cb2ed34c99cc061fd
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewerscpearce
bugs1029552
milestone35.0a1
Bug 1029552 - Release HW resource when the MediaElement UnbindFromTree. r=cpearce
content/html/content/src/HTMLMediaElement.cpp
--- a/content/html/content/src/HTMLMediaElement.cpp
+++ b/content/html/content/src/HTMLMediaElement.cpp
@@ -2515,25 +2515,33 @@ nsresult HTMLMediaElement::BindToTree(ns
   if (aDocument) {
     mAutoplayEnabled =
       IsAutoplayEnabled() && (!aDocument || !aDocument->IsStaticDocument()) &&
       !IsEditable();
     // The preload action depends on the value of the autoplay attribute.
     // It's value may have changed, so update it.
     UpdatePreloadAction();
   }
+  if (mDecoder) {
+    mDecoder->SetDormantIfNecessary(false);
+  }
 
   return rv;
 }
 
 void HTMLMediaElement::UnbindFromTree(bool aDeep,
                                       bool aNullParent)
 {
   if (!mPaused && mNetworkState != nsIDOMHTMLMediaElement::NETWORK_EMPTY)
     Pause();
+
+  if (mDecoder) {
+    mDecoder->SetDormantIfNecessary(true);
+  }
+
   nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
 }
 
 /* static */
 CanPlayStatus
 HTMLMediaElement::GetCanPlay(const nsAString& aType)
 {
   nsContentTypeParser parser(aType);