There are two callers of FlushDecoding - One is shutdown (where we already use promises to wait for the queue to go idle via BeginShutdown), and the other is dormant.
The previous setup is wacky, and can cause the notification to reach the state machine before the promise rejection, which causes us to stall intermittently. We also take the opportunity to be a bit less trigger happy when we fire it in MediaSourceReader.cpp.
MediaDecoder::DecodeError invokes MediaDecoder::Shutdown, which shuts down the state machine. Given the sync dispatch, this means that this is basically already what's happening.
This means that we can get rid of the code to recheck state after dropping the monitor. We'll remove the other monitor drop from this method in a future commit.
This has two implications:
1. We no longer need to pipe mQueuedSeekTarget through MDSM::Seek to get the appropriate clamping.
2. MDSM::Seek doesn't _need_ to be called on the main thread anymore.
The model we're moving towards is one where the MDSM can just disconnect all of its promises, send a ResetDecode down the pipe, and start doing something unrelated.
This is necessary because we're going to want to start disconnecting sample and seek requests directly from the state machine thread, and the machinery asserts that disconnection happens on the same thread as resolution.