Bug 1163223 - Use AwaitStartTime to invoke MediaDecoderReader::SetStartTime. r=jww

This commit is contained in:
Bobby Holley 2015-06-06 15:00:36 -07:00
parent 3d04b30371
commit b3e7a4b2a3
3 changed files with 17 additions and 5 deletions

View File

@ -148,6 +148,7 @@ void
MediaDecoderReader::SetStartTime(int64_t aStartTime)
{
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
MOZ_ASSERT(mStartTime == -1);
mStartTime = aStartTime;
}

View File

@ -328,7 +328,13 @@ protected:
// The start time of the media, in microseconds. This is the presentation
// time of the first frame decoded from the media. This is initialized to -1,
// and then set to a value >= by MediaDecoderStateMachine::SetStartTime(),
// after which point it never changes.
// after which point it never changes (though SetStartTime may be called
// multiple times with the same value).
//
// This is an ugly breach of abstractions - it's currently necessary for the
// readers to return the correct value of GetBuffered. We should refactor
// things such that all GetBuffered calls go through the MDSM, which would
// offset the range accordingly.
int64_t mStartTime;
// This is a quick-and-dirty way for DecodeAudioData implementations to

View File

@ -2177,6 +2177,15 @@ MediaDecoderStateMachine::OnMetadataRead(MetadataHolder* aMetadata)
if (!mStartTimeRendezvous) {
mStartTimeRendezvous = new StartTimeRendezvous(TaskQueue(), HasAudio(), HasVideo(),
mReader->ForceZeroStartTime() || IsRealTime());
mStartTimeRendezvous->AwaitStartTime()->Then(TaskQueue(), __func__,
[self] () -> void {
NS_ENSURE_TRUE_VOID(!self->IsShutdown());
ReentrantMonitorAutoEnter mon(self->mDecoder->GetReentrantMonitor());
self->mReader->SetStartTime(self->StartTime());
},
[] () -> void { NS_WARNING("Setting start time on reader failed"); }
);
}
if (mInfo.mMetadataDuration.isSome()) {
@ -3176,10 +3185,6 @@ void MediaDecoderStateMachine::SetStartTime(int64_t aStartTimeUsecs)
}
}
// Pass along this immutable value to the reader so that it can make
// calculations independently of the state machine.
mReader->SetStartTime(mStartTime);
// Set the audio start time to be start of media. If this lies before the
// first actual audio frame we have, we'll inject silence during playback
// to ensure the audio starts at the correct time.