Bug 1384495 - p2: resolve drain promise with empty decoded data only when draining complete. r?jya draft
authorJohn Lin <jolin@mozilla.com>
Wed, 26 Jul 2017 15:25:28 +0800
changeset 616559 01378861d0c69373e79b2e23d96267a04258729b
parent 616558 31c0ef4a44caf2c84c7df55822880d451d5cf6fd
child 616604 308942e8411789cec87c9ea23f1d04b7e75ccd29
push id70719
push userbmo:jolin@mozilla.com
push dateThu, 27 Jul 2017 05:33:33 +0000
reviewersjya
bugs1384495
milestone56.0a1
Bug 1384495 - p2: resolve drain promise with empty decoded data only when draining complete. r?jya MozReview-Commit-ID: 7livLq1K6Ro
dom/media/platforms/android/RemoteDataDecoder.cpp
--- a/dom/media/platforms/android/RemoteDataDecoder.cpp
+++ b/dom/media/platforms/android/RemoteDataDecoder.cpp
@@ -603,17 +603,18 @@ RemoteDataDecoder::ReturnDecodedData()
 {
   AssertOnTaskQueue();
   MOZ_ASSERT(!mShutdown);
 
   // We only want to clear mDecodedData when we have resolved the promises.
   if (!mDecodePromise.IsEmpty()) {
     mDecodePromise.Resolve(mDecodedData, __func__);
     mDecodedData.Clear();
-  } else if (!mDrainPromise.IsEmpty()) {
+  } else if (!mDrainPromise.IsEmpty() &&
+             (!mDecodedData.IsEmpty() || mDrainStatus == DrainStatus::DRAINED)) {
     mDrainPromise.Resolve(mDecodedData, __func__);
     mDecodedData.Clear();
   }
 }
 
 void
 RemoteDataDecoder::DrainComplete()
 {