Bug 1119119: Do not abort when calling appendBuffer with no data. r=cajbir
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 16 Jan 2015 23:48:24 +1100
changeset 224158 670e667640522b53458b5824e1b77696c5c1af90
parent 224157 50b459cff4252af505d4c36bae737ad15b2a880f
child 224159 20a4dd54033876778db39691374e8263d197b61a
push id54147
push userjyavenard@mozilla.com
push dateFri, 16 Jan 2015 12:54:44 +0000
treeherdermozilla-inbound@797403411392 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscajbir
bugs1119119
milestone38.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 1119119: Do not abort when calling appendBuffer with no data. r=cajbir
dom/media/mediasource/SourceBuffer.cpp
--- a/dom/media/mediasource/SourceBuffer.cpp
+++ b/dom/media/mediasource/SourceBuffer.cpp
@@ -342,30 +342,32 @@ SourceBuffer::AppendData(const uint8_t* 
   MSE_DEBUG("SourceBuffer(%p)::AppendData(aLength=%u)", this, aLength);
   if (!PrepareAppend(aRv)) {
     return;
   }
   StartUpdating();
 
   MOZ_ASSERT(mAppendMode == SourceBufferAppendMode::Segments,
              "We don't handle timestampOffset for sequence mode yet");
-  if (!mTrackBuffer->AppendData(aData, aLength, mTimestampOffset * USECS_PER_S)) {
-    Optional<MediaSourceEndOfStreamError> decodeError(MediaSourceEndOfStreamError::Decode);
-    ErrorResult dummy;
-    mMediaSource->EndOfStream(decodeError, dummy);
-    aRv.Throw(NS_ERROR_FAILURE);
-    return;
+  if (aLength) {
+    if (!mTrackBuffer->AppendData(aData, aLength, mTimestampOffset * USECS_PER_S)) {
+      Optional<MediaSourceEndOfStreamError> decodeError(MediaSourceEndOfStreamError::Decode);
+      ErrorResult dummy;
+      mMediaSource->EndOfStream(decodeError, dummy);
+      aRv.Throw(NS_ERROR_FAILURE);
+      return;
+    }
+
+    if (mTrackBuffer->HasInitSegment()) {
+      mMediaSource->QueueInitializationEvent();
+    }
+
+    CheckEndTime();
   }
 
-  if (mTrackBuffer->HasInitSegment()) {
-    mMediaSource->QueueInitializationEvent();
-  }
-
-  CheckEndTime();
-
   // Run the final step of the buffer append algorithm asynchronously to
   // ensure the SourceBuffer's updating flag transition behaves as required
   // by the spec.
   nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &SourceBuffer::StopUpdating);
   NS_DispatchToMainThread(event);
 }
 
 bool