Bug 1163223 - Adjust incoming samples for start time. r=jww
☠☠ backed out by db848e0a090d ☠ ☠
authorBobby Holley <bobbyholley@gmail.com>
Sat, 06 Jun 2015 15:01:23 -0700
changeset 266735 cd763e4327f31e11837840e2aa709cf327877942
parent 266734 3bd4024e0a709eb5f5d49e2b15aa18bd8b368f6b
child 266736 a8f7e2ad95431b063adc1807d154e1e606390979
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjww
bugs1163223
milestone41.0a1
Bug 1163223 - Adjust incoming samples for start time. r=jww
dom/media/MediaData.h
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaData.h
+++ b/dom/media/MediaData.h
@@ -69,16 +69,21 @@ public:
   bool mKeyframe;
 
   // True if this is the first sample after a gap or discontinuity in
   // the stream. This is true for the first sample in a stream after a seek.
   bool mDiscontinuity;
 
   int64_t GetEndTime() const { return mTime + mDuration; }
 
+  bool AdjustForStartTime(int64_t aStartTime)
+  {
+    mTime = mTime - aStartTime;
+    return mTime >= 0;
+  }
 protected:
   explicit MediaData(Type aType)
     : mType(aType)
     , mOffset(0)
     , mTime(0)
     , mTimecode(0)
     , mDuration(0)
     , mKeyframe(false)
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -758,16 +758,17 @@ MediaDecoderStateMachine::IsVideoSeekCom
 void
 MediaDecoderStateMachine::OnAudioDecoded(AudioData* aAudioSample)
 {
   MOZ_ASSERT(OnTaskQueue());
   ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
   nsRefPtr<AudioData> audio(aAudioSample);
   MOZ_ASSERT(audio);
   mAudioDataRequest.Complete();
+  aAudioSample->AdjustForStartTime(StartTime());
   mDecodedAudioEndTime = audio->GetEndTime();
 
   SAMPLE_LOG("OnAudioDecoded [%lld,%lld] disc=%d",
              (audio ? audio->mTime : -1),
              (audio ? audio->GetEndTime() : -1),
              (audio ? audio->mDiscontinuity : 0));
 
   switch (mState) {
@@ -1038,17 +1039,19 @@ MediaDecoderStateMachine::MaybeFinishDec
 }
 
 void
 MediaDecoderStateMachine::OnVideoDecoded(VideoData* aVideoSample)
 {
   MOZ_ASSERT(OnTaskQueue());
   ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
   nsRefPtr<VideoData> video(aVideoSample);
+  MOZ_ASSERT(video);
   mVideoDataRequest.Complete();
+  aVideoSample->AdjustForStartTime(StartTime());
   mDecodedVideoEndTime = video ? video->GetEndTime() : mDecodedVideoEndTime;
 
   SAMPLE_LOG("OnVideoDecoded [%lld,%lld] disc=%d",
              (video ? video->mTime : -1),
              (video ? video->GetEndTime() : -1),
              (video ? video->mDiscontinuity : 0));
 
   switch (mState) {