Bug 1120086: Re-open SourceBuffer after call to appendBuffer if in ended state. r=cajbir
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 16 Jan 2015 23:48:25 +1100
changeset 224250 f1d37b792c4a
parent 224249 0ba9865709b5
child 224251 0bf6cb3e40dc
push id28122
push userkwierso@gmail.com
push dateSat, 17 Jan 2015 01:33:15 +0000
treeherdermozilla-central@369a8f14ccf8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscajbir
bugs1120086
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 1120086: Re-open SourceBuffer after call to appendBuffer if in ended state. r=cajbir
dom/media/mediasource/SourceBuffer.cpp
dom/media/mediasource/SourceBufferResource.cpp
dom/media/mediasource/TrackBuffer.cpp
dom/media/mediasource/TrackBuffer.h
--- a/dom/media/mediasource/SourceBuffer.cpp
+++ b/dom/media/mediasource/SourceBuffer.cpp
@@ -228,17 +228,17 @@ SourceBuffer::Detach()
 }
 
 void
 SourceBuffer::Ended()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(IsAttached());
   MSE_DEBUG("SourceBuffer(%p)::Ended", this);
-  mTrackBuffer->DiscardDecoder();
+  mTrackBuffer->EndCurrentDecoder();
 }
 
 SourceBuffer::SourceBuffer(MediaSource* aMediaSource, const nsACString& aType)
   : DOMEventTargetHelper(aMediaSource->GetParentObject())
   , mMediaSource(aMediaSource)
   , mAppendWindowStart(0)
   , mAppendWindowEnd(PositiveInfinity<double>())
   , mTimestampOffset(0)
--- a/dom/media/mediasource/SourceBufferResource.cpp
+++ b/dom/media/mediasource/SourceBufferResource.cpp
@@ -200,16 +200,17 @@ SourceBufferResource::EvictAll()
 }
 
 void
 SourceBufferResource::AppendData(const uint8_t* aData, uint32_t aLength)
 {
   SBR_DEBUG("SourceBufferResource(%p)::AppendData(aData=%p, aLength=%u)", this, aData, aLength);
   ReentrantMonitorAutoEnter mon(mMonitor);
   mInputBuffer.AppendItem(aData, aLength);
+  mEnded = false;
   mon.NotifyAll();
 }
 
 void
 SourceBufferResource::Ended()
 {
   SBR_DEBUG("SourceBufferResource(%p)::Ended()", this);
   ReentrantMonitorAutoEnter mon(mMonitor);
--- a/dom/media/mediasource/TrackBuffer.cpp
+++ b/dom/media/mediasource/TrackBuffer.cpp
@@ -544,16 +544,25 @@ TrackBuffer::DiscardDecoder()
   ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
   if (mCurrentDecoder) {
     mCurrentDecoder->GetResource()->Ended();
   }
   mCurrentDecoder = nullptr;
 }
 
 void
+TrackBuffer::EndCurrentDecoder()
+{
+  ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
+  if (mCurrentDecoder) {
+    mCurrentDecoder->GetResource()->Ended();
+  }
+}
+
+void
 TrackBuffer::Detach()
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (mCurrentDecoder) {
     DiscardDecoder();
   }
 }
 
--- a/dom/media/mediasource/TrackBuffer.h
+++ b/dom/media/mediasource/TrackBuffer.h
@@ -56,16 +56,18 @@ public:
   // Returns the highest end time of all of the buffered ranges in the
   // decoders managed by this TrackBuffer, and returns the union of the
   // decoders buffered ranges in aRanges. This may be called on any thread.
   double Buffered(dom::TimeRanges* aRanges);
 
   // Mark the current decoder's resource as ended, clear mCurrentDecoder and
   // reset mLast{Start,End}Timestamp.
   void DiscardDecoder();
+  // Mark the current decoder's resource as ended.
+  void EndCurrentDecoder();
 
   void Detach();
 
   // Returns true if an init segment has been appended.
   bool HasInitSegment();
 
   // Returns true iff mParser->HasInitData() and the decoder using that init
   // segment has successfully initialized by setting mHas{Audio,Video}..