Bug 1163223 - Be more explicit about when we notify metadata. r=jww

This commit is contained in:
Bobby Holley 2015-06-08 10:56:00 -07:00
Родитель a5b9b2b399
Коммит ad9440ac9d
2 изменённых файлов: 23 добавлений и 18 удалений

Просмотреть файл

@ -224,7 +224,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
mAudioCaptured(false),
mPositionChangeQueued(false),
mAudioCompleted(false, "MediaDecoderStateMachine::mAudioCompleted"),
mGotDurationFromMetaData(false),
mNotifyMetadataBeforeFirstFrame(false),
mDispatchedEventToDecode(false),
mQuickBuffering(false),
mMinimizePreroll(false),
@ -1447,11 +1447,10 @@ void MediaDecoderStateMachine::SetDuration(TimeUnit aDuration)
MOZ_ASSERT(OnTaskQueue());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
MOZ_ASSERT(aDuration.ToMicroseconds() >= 0);
mDurationSet = true;
if (mStartTime == -1) {
SetStartTime(0);
}
mDurationSet = true;
if (aDuration.IsInfinite()) {
mEndTime = -1;
@ -2210,10 +2209,15 @@ MediaDecoderStateMachine::OnMetadataRead(MetadataHolder* aMetadata)
}
mDecoder->StartProgressUpdates();
mGotDurationFromMetaData = (GetDuration() != -1) || mDurationSet;
if (mGotDurationFromMetaData) {
// We have all the information required: duration and size
// Inform the element that we've loaded the metadata.
// In general, we wait until we know the duration before notifying the decoder.
// However, we notify unconditionally in this case without waiting for the start
// time, since the caller might be waiting on metadataloaded to be fired before
// feeding in the CDM, which we need to decode the first frame (and
// thus get the metadata). We could fix this if we could compute the start
// time by demuxing without necessaring decoding.
mNotifyMetadataBeforeFirstFrame = mDurationSet || mReader->IsWaitingOnCDMResource();
if (mNotifyMetadataBeforeFirstFrame) {
EnqueueLoadedMetadataEvent();
}
@ -2388,15 +2392,11 @@ MediaDecoderStateMachine::FinishDecodeFirstFrame()
nsAutoPtr<MediaInfo> info(new MediaInfo());
*info = mInfo;
if (!mGotDurationFromMetaData) {
// We now have a duration, we can fire the LoadedMetadata and
// FirstFrame event.
if (!mNotifyMetadataBeforeFirstFrame) {
// If we didn't have duration and/or start time before, we should now.
EnqueueLoadedMetadataEvent();
EnqueueFirstFrameLoadedEvent();
} else {
// Inform the element that we've loaded the first frame.
EnqueueFirstFrameLoadedEvent();
}
EnqueueFirstFrameLoadedEvent();
if (mState == DECODER_STATE_DECODING_FIRSTFRAME) {
StartDecoding();
@ -3175,7 +3175,8 @@ void MediaDecoderStateMachine::SetStartTime(int64_t aStartTimeUsecs)
mStartTime = 0;
if (aStartTimeUsecs != 0) {
mStartTime = aStartTimeUsecs;
if (mGotDurationFromMetaData && GetEndTime() != INT64_MAX) {
// XXXbholley - this whole method goes away in the upcoming patches.
if (mDurationSet && GetEndTime() != INT64_MAX) {
NS_ASSERTION(mEndTime != -1,
"We should have mEndTime as supplied duration here");
// We were specified a duration from a Content-Duration HTTP header.

Просмотреть файл

@ -1283,9 +1283,13 @@ protected:
// been written to the MediaStream.
Watchable<bool> mAudioCompleted;
// True if mDuration has a value obtained from an HTTP header, or from
// the media index/metadata. Accessed on the state machine thread.
bool mGotDurationFromMetaData;
// Flag whether we notify metadata before decoding the first frame or after.
//
// Note that the odd semantics here are designed to replicate the current
// behavior where we notify the decoder each time we come out of dormant, but
// send suppressed event visibility for those cases. This code can probably be
// simplified.
bool mNotifyMetadataBeforeFirstFrame;
// True if we've dispatched an event to the decode task queue to call
// DecodeThreadRun(). We use this flag to prevent us from dispatching