Bug 1417300 - store mDecodedAudioDuration before adjusting sample time.
mDecodedAudioDuration should only save unadjusted timestamp, or it would
cause next adjustment to be incorrect.
MozReview-Commit-ID: 7grtYs075p0
--- a/dom/media/ogg/OggDemuxer.cpp
+++ b/dom/media/ogg/OggDemuxer.cpp
@@ -1351,27 +1351,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) {