Bug 1417300 - store mDecodedAudioDuration before adjusting sample time. r=jya a=gchang
authorAlastor Wu <alwu@mozilla.com>
Mon, 11 Dec 2017 00:03:51 +0800
changeset 445373 2c6da9d74cdaea33f7f4d9d1b5574f4bb687e191
parent 445372 d16cbfcbb8993d8831b6a0c0c1a7d55db1720e34
child 445374 3d30fcbdd4073089ccd365b3d3e613f23ef9e33a
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya, gchang
bugs1417300
milestone58.0
Bug 1417300 - store mDecodedAudioDuration before adjusting sample time. r=jya a=gchang mDecodedAudioDuration should only save unadjusted timestamp, or it would cause next adjustment to be incorrect. MozReview-Commit-ID: 7grtYs075p0
dom/media/ogg/OggDemuxer.cpp
--- a/dom/media/ogg/OggDemuxer.cpp
+++ b/dom/media/ogg/OggDemuxer.cpp
@@ -1343,27 +1343,26 @@ OggTrackDemuxer::NextSample()
   OggCodecState* state = mParent->GetTrackCodecState(mType);
   RefPtr<MediaRawData> data = state->PacketOutAsMediaRawData();
   if (!data) {
     return nullptr;
   }
   if (mType == TrackInfo::kAudioTrack) {
     data->mTrackInfo = mParent->mSharedAudioTrackInfo;
   }
-  // We do not want to perform the adjustment of the timestamp after reading
-  // the ogg chain but before. Otherwise the parent's mDecodedAudioDuration
-  // would be adjusted causing the sample's time to be twice the value it
-  // should be.
-  data->mTime += mParent->mDecodedAudioDuration;
+  // mDecodedAudioDuration gets adjusted during ReadOggChain().
+  TimeUnit totalDuration = mParent->mDecodedAudioDuration;
   if (eos) {
     // We've encountered an end of bitstream packet; check for a chained
     // bitstream following this one.
     // This will also update mSharedAudioTrackInfo.
     mParent->ReadOggChain(data->GetEndTime());
   }
+  // We adjust the start time of the sample to account for the potential ogg chaining.
+  data->mTime += totalDuration;
   return data;
 }
 
 RefPtr<OggTrackDemuxer::SamplesPromise>
 OggTrackDemuxer::GetSamples(int32_t aNumSamples)
 {
   RefPtr<SamplesHolder> samples = new SamplesHolder;
   if (!aNumSamples) {