Bug 1404441 - return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR if MediaData::AdjustForStartTime() results in an invalid mTime. r=jya
authorJW Wang <jwwang@mozilla.com>
Tue, 19 Dec 2017 14:56:08 +0800
changeset 448591 5bc55868583b2a7615800f713753eb00becc9fae
parent 448590 7eecc63dcdecd85d0babd6f9da951eca0378d632
child 448592 d32719cf7ea713ea4432982c9cd7c57ebde78eda
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1404441
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1404441 - return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR if MediaData::AdjustForStartTime() results in an invalid mTime. r=jya MozReview-Commit-ID: 44VgbrknYbi
dom/media/ReaderProxy.cpp
--- a/dom/media/ReaderProxy.cpp
+++ b/dom/media/ReaderProxy.cpp
@@ -57,18 +57,22 @@ RefPtr<ReaderProxy::AudioDataPromise>
 ReaderProxy::OnAudioDataRequestCompleted(RefPtr<AudioData> aAudio)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
 
   // Subtract the start time and add the looping-offset time.
   int64_t offset =
     StartTime().ToMicroseconds() - mLoopingOffset.ToMicroseconds();
   aAudio->AdjustForStartTime(offset);
-  mLastAudioEndTime = aAudio->mTime;
-  return AudioDataPromise::CreateAndResolve(aAudio.forget(), __func__);
+  if (aAudio->mTime.IsValid()) {
+    mLastAudioEndTime = aAudio->mTime;
+    return AudioDataPromise::CreateAndResolve(aAudio.forget(), __func__);
+  }
+  return AudioDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_OVERFLOW_ERR,
+                                           __func__);
 }
 
 RefPtr<ReaderProxy::AudioDataPromise>
 ReaderProxy::OnAudioDataRequestFailed(const MediaResult& aError)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
 
   if (mSeamlessLoopingBlocked || !mSeamlessLoopingEnabled ||
@@ -144,18 +148,21 @@ ReaderProxy::RequestVideoData(const medi
                      mReader.get(),
                      __func__,
                      &MediaFormatReader::RequestVideoData,
                      threshold)
     ->Then(mOwnerThread,
            __func__,
            [startTime](RefPtr<VideoData> aVideo) {
              aVideo->AdjustForStartTime(startTime);
-             return VideoDataPromise::CreateAndResolve(aVideo.forget(),
-                                                       __func__);
+             return aVideo->mTime.IsValid()
+                      ? VideoDataPromise::CreateAndResolve(aVideo.forget(),
+                                                           __func__)
+                      : VideoDataPromise::CreateAndReject(
+                          NS_ERROR_DOM_MEDIA_OVERFLOW_ERR, __func__);
            },
            [](const MediaResult& aError) {
              return VideoDataPromise::CreateAndReject(aError, __func__);
            });
 }
 
 RefPtr<ReaderProxy::SeekPromise>
 ReaderProxy::Seek(const SeekTarget& aTarget)