Bug 1331331. Part 1 - add ErrorState.
MozReview-Commit-ID: D7jiBRC9SC7
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1806,16 +1806,52 @@ public:
}
}
private:
bool mSentPlaybackEndedEvent = false;
};
/**
+ * Purpose: we enter this state when unrecoverable errors are encountered.
+ * Decoders will be released and all playback requests (e.g. seek
+ * or play/pause) will rejected in this state.
+ *
+ * Transition to:
+ * SHUTDOWN if BeginShutdown() is called on MDSM.
+ */
+class MediaDecoderStateMachine::ErrorState
+ : public MediaDecoderStateMachine::StateObject
+{
+public:
+ explicit ErrorState(Master* aPtr) : StateObject(aPtr) {}
+
+ void Enter()
+ {
+ mMaster->StopPlayback();
+ mMaster->ResetDecode();
+ mMaster->StopMediaSink();
+ Reader()->ReleaseResources();
+ }
+
+ State GetState() const override
+ {
+ return DECODER_STATE_ERROR;
+ }
+
+ RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override
+ {
+ return MediaDecoder::SeekPromise::CreateAndReject(true, __func__);
+ }
+
+ void HandleVideoSuspendTimeout() override {}
+ void HandleResumeVideoDecoding() override {}
+};
+
+/**
* Purpose: release all resources allocated by MDSM.
*
* Transition to:
* None since this is the final state.
*
* Transition from:
* Any states other than SHUTDOWN.
*/
@@ -2818,16 +2854,17 @@ MediaDecoderStateMachine::ToStateStr(Sta
case DECODER_STATE_DECODING_METADATA: return "DECODING_METADATA";
case DECODER_STATE_WAIT_FOR_CDM: return "WAIT_FOR_CDM";
case DECODER_STATE_DORMANT: return "DORMANT";
case DECODER_STATE_DECODING_FIRSTFRAME: return "DECODING_FIRSTFRAME";
case DECODER_STATE_DECODING: return "DECODING";
case DECODER_STATE_SEEKING: return "SEEKING";
case DECODER_STATE_BUFFERING: return "BUFFERING";
case DECODER_STATE_COMPLETED: return "COMPLETED";
+ case DECODER_STATE_ERROR: return "ERROR";
case DECODER_STATE_SHUTDOWN: return "SHUTDOWN";
default: MOZ_ASSERT_UNREACHABLE("Invalid state.");
}
return "UNKNOWN";
}
const char*
MediaDecoderStateMachine::ToStateStr()
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -153,16 +153,17 @@ public:
DECODER_STATE_DECODING_METADATA,
DECODER_STATE_WAIT_FOR_CDM,
DECODER_STATE_DORMANT,
DECODER_STATE_DECODING_FIRSTFRAME,
DECODER_STATE_DECODING,
DECODER_STATE_SEEKING,
DECODER_STATE_BUFFERING,
DECODER_STATE_COMPLETED,
+ DECODER_STATE_ERROR,
DECODER_STATE_SHUTDOWN
};
void DumpDebugInfo();
void AddOutputStream(ProcessedMediaStream* aStream, bool aFinishWhenEnded);
// Remove an output stream added with AddOutputStream.
void RemoveOutputStream(MediaStream* aStream);
@@ -228,16 +229,17 @@ private:
class DormantState;
class DecodingFirstFrameState;
class DecodingState;
class SeekingState;
class AccurateSeekingState;
class NextFrameSeekingState;
class BufferingState;
class CompletedState;
+ class ErrorState;
class ShutdownState;
static const char* ToStateStr(State aState);
static const char* ToStr(NextFrameStatus aStatus);
const char* ToStateStr();
// Functions used by assertions to ensure we're calling things
// on the appropriate threads.