Bug 882027. Make MediaDecoder::UpdateReadyStateForData always be responsible for calling GetNextFrameStatus when that value is passed to HTMLMediaElement::UpdateReadyStateForData, but keep calling GetNextFrameStatus on the state machine thread to suppress dispatching of redundant runnables when nothing has changed. r=cpearce

This commit is contained in:
Robert O'Callahan 2013-06-17 17:15:32 +12:00
Родитель 9a0744c2a3
Коммит c6c84ac1ea
3 изменённых файлов: 9 добавлений и 46 удалений

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

@ -1046,32 +1046,6 @@ void MediaDecoder::NotifyBytesConsumed(int64_t aBytes)
}
}
void MediaDecoder::NextFrameUnavailableBuffering()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mOwner || mShuttingDown || !mDecoderStateMachine)
return;
mOwner->UpdateReadyStateForData(MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_BUFFERING);
}
void MediaDecoder::NextFrameAvailable()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mOwner || mShuttingDown || !mDecoderStateMachine)
return;
mOwner->UpdateReadyStateForData(MediaDecoderOwner::NEXT_FRAME_AVAILABLE);
}
void MediaDecoder::NextFrameUnavailable()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mOwner || mShuttingDown || !mDecoderStateMachine)
return;
mOwner->UpdateReadyStateForData(MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE);
}
void MediaDecoder::UpdateReadyStateForData()
{
MOZ_ASSERT(NS_IsMainThread());

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

@ -710,12 +710,6 @@ public:
// This must be called on the main thread only.
void PlaybackPositionChanged();
// Calls mElement->UpdateReadyStateForData, telling it which state we have
// entered. Main thread only.
void NextFrameUnavailableBuffering();
void NextFrameAvailable();
void NextFrameUnavailable();
// Calls mElement->UpdateReadyStateForData, telling it whether we have
// data for the next frame and if we're buffering. Main thread only.
void UpdateReadyStateForData();

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

@ -2620,21 +2620,16 @@ void MediaDecoderStateMachine::UpdateReadyState() {
}
mLastFrameStatus = nextFrameStatus;
/* This is a bit tricky. MediaDecoder::UpdateReadyStateForData will run on
* the main thread and re-evaluate GetNextFrameStatus there, passing it to
* HTMLMediaElement::UpdateReadyStateForData. It doesn't use the value of
* GetNextFrameStatus we computed here, because what we're computing here
* could be stale by the time MediaDecoder::UpdateReadyStateForData runs.
* We only compute GetNextFrameStatus here to avoid posting runnables to the main
* thread unnecessarily.
*/
nsCOMPtr<nsIRunnable> event;
switch (nextFrameStatus) {
case MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_BUFFERING:
event = NS_NewRunnableMethod(mDecoder, &MediaDecoder::NextFrameUnavailableBuffering);
break;
case MediaDecoderOwner::NEXT_FRAME_AVAILABLE:
event = NS_NewRunnableMethod(mDecoder, &MediaDecoder::NextFrameAvailable);
break;
case MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE:
event = NS_NewRunnableMethod(mDecoder, &MediaDecoder::NextFrameUnavailable);
break;
default:
PR_NOT_REACHED("unhandled frame state");
}
event = NS_NewRunnableMethod(mDecoder, &MediaDecoder::UpdateReadyStateForData);
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
}