зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1151656 - Stop doing sync dispatch of PlaybackEnded. r=mattwoodrow
This commit is contained in:
Родитель
1748d9ab1f
Коммит
c71babaf43
|
@ -243,7 +243,8 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
|
|||
mDisabledHardwareAcceleration(false),
|
||||
mDecodingFrozenAtStateDecoding(false),
|
||||
mSentLoadedMetadataEvent(false),
|
||||
mSentFirstFrameLoadedEvent(false)
|
||||
mSentFirstFrameLoadedEvent(false),
|
||||
mSentPlaybackEndedEvent(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MediaDecoderStateMachine);
|
||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||
|
@ -1302,6 +1303,9 @@ void MediaDecoderStateMachine::SetState(State aState)
|
|||
gMachineStateStr[mState], gMachineStateStr[aState]);
|
||||
|
||||
mState = aState;
|
||||
|
||||
// Clear state-scoped state.
|
||||
mSentPlaybackEndedEvent = false;
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::SetVolume(double volume)
|
||||
|
@ -2702,21 +2706,18 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
|
|||
|
||||
StopAudioThread();
|
||||
|
||||
if (mDecoder->GetState() == MediaDecoder::PLAY_STATE_PLAYING) {
|
||||
if (mDecoder->GetState() == MediaDecoder::PLAY_STATE_PLAYING &&
|
||||
!mSentPlaybackEndedEvent)
|
||||
{
|
||||
int64_t clockTime = std::max(mAudioEndTime, mVideoFrameEndTime);
|
||||
clockTime = std::max(int64_t(0), std::max(clockTime, mEndTime));
|
||||
UpdatePlaybackPosition(clockTime);
|
||||
|
||||
{
|
||||
// Wait for the state change is completed in the main thread,
|
||||
// otherwise we might see |mDecoder->GetState() == MediaDecoder::PLAY_STATE_PLAYING|
|
||||
// in next loop and send |MediaDecoder::PlaybackEnded| again to trigger 'ended'
|
||||
// event twice in the media element.
|
||||
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
NS_NewRunnableMethod(mDecoder, &MediaDecoder::PlaybackEnded);
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_SYNC);
|
||||
}
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
NS_NewRunnableMethod(mDecoder, &MediaDecoder::PlaybackEnded);
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
|
||||
mSentPlaybackEndedEvent = true;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1237,6 +1237,8 @@ public:
|
|||
// to decode any audio/video since the MediaDecoder will trigger a seek
|
||||
// operation soon.
|
||||
bool mSentFirstFrameLoadedEvent;
|
||||
|
||||
bool mSentPlaybackEndedEvent;
|
||||
};
|
||||
|
||||
} // namespace mozilla;
|
||||
|
|
Загрузка…
Ссылка в новой задаче