Bug 1300497. Part 5 - run MDSM cycles immediately in the callback of mDelayedScheduler.
There is no point in scheduling an addition cycle to do that.
Also remove the annoying debugging message which is not helpful.
MozReview-Commit-ID: BMjeTNg6HCY
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2614,23 +2614,23 @@ MediaDecoderStateMachine::ScheduleStateM
MOZ_ASSERT(aMicroseconds > 0);
if (mDispatchedStateMachine) {
return;
}
TimeStamp now = TimeStamp::Now();
TimeStamp target = now + TimeDuration::FromMicroseconds(aMicroseconds);
- SAMPLE_LOG("Scheduling state machine for %lf ms from now", (target - now).ToMilliseconds());
-
- RefPtr<MediaDecoderStateMachine> self = this;
- mDelayedScheduler.Ensure(target, [self] () {
- self->OnDelayedSchedule();
- }, [self] () {
- self->NotReached();
+ // It is OK to capture 'this' without causing UAF because the callback
+ // always happens before shutdown.
+ mDelayedScheduler.Ensure(target, [this] () {
+ mDelayedScheduler.CompleteRequest();
+ RunStateMachine();
+ }, [] () {
+ MOZ_DIAGNOSTIC_ASSERT(false);
});
}
bool MediaDecoderStateMachine::OnTaskQueue() const
{
return OwnerThread()->IsCurrentThreadIn();
}
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -314,25 +314,16 @@ private:
// Schedules the shared state machine thread to run the state machine.
void ScheduleStateMachine();
// Invokes ScheduleStateMachine to run in |aMicroseconds| microseconds,
// unless it's already scheduled to run earlier, in which case the
// request is discarded.
void ScheduleStateMachineIn(int64_t aMicroseconds);
- void OnDelayedSchedule()
- {
- MOZ_ASSERT(OnTaskQueue());
- mDelayedScheduler.CompleteRequest();
- ScheduleStateMachine();
- }
-
- void NotReached() { MOZ_DIAGNOSTIC_ASSERT(false); }
-
// Discard audio/video data that are already played by MSG.
void DiscardStreamData();
bool HaveEnoughDecodedAudio();
bool HaveEnoughDecodedVideo();
// True if shutdown process has begun.
bool IsShutdown() const;