|
|
|
@ -269,7 +269,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
|
|
|
|
|
|
|
|
|
|
#ifdef XP_WIN
|
|
|
|
|
// Ensure high precision timers are enabled on Windows, otherwise the state
|
|
|
|
|
// machine thread isn't woken up at reliable intervals to set the next frame,
|
|
|
|
|
// machine isn't woken up at reliable intervals to set the next frame,
|
|
|
|
|
// and we drop frames while painting. Note that multiple calls to this
|
|
|
|
|
// function per-process is OK, provided each call is matched by a corresponding
|
|
|
|
|
// timeEndPeriod() call.
|
|
|
|
@ -312,7 +312,7 @@ bool MediaDecoderStateMachine::HaveNextFrameData() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64_t MediaDecoderStateMachine::GetDecodedAudioDuration() {
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
int64_t audioDecoded = AudioQueue().Duration();
|
|
|
|
|
if (mAudioEndTime != -1) {
|
|
|
|
@ -325,7 +325,7 @@ void MediaDecoderStateMachine::SendStreamAudio(AudioData* aAudio,
|
|
|
|
|
DecodedStreamData* aStream,
|
|
|
|
|
AudioSegment* aOutput)
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
|
|
|
|
|
// This logic has to mimic AudioSink closely to make sure we write
|
|
|
|
@ -390,7 +390,7 @@ static void WriteVideoToMediaStream(MediaStream* aStream,
|
|
|
|
|
|
|
|
|
|
void MediaDecoderStateMachine::SendStreamData()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread(), "Should be on state machine thread");
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
MOZ_ASSERT(!mAudioSink, "Should've been stopped in RunStateMachine()");
|
|
|
|
|
|
|
|
|
@ -710,7 +710,7 @@ MediaDecoderStateMachine::IsVideoSeekComplete()
|
|
|
|
|
void
|
|
|
|
|
MediaDecoderStateMachine::OnAudioDecoded(AudioData* aAudioSample)
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
nsRefPtr<AudioData> audio(aAudioSample);
|
|
|
|
|
MOZ_ASSERT(audio);
|
|
|
|
@ -831,7 +831,7 @@ void
|
|
|
|
|
MediaDecoderStateMachine::OnNotDecoded(MediaData::Type aType,
|
|
|
|
|
MediaDecoderReader::NotDecodedReason aReason)
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
SAMPLE_LOG("OnNotDecoded (aType=%u, aReason=%u)", aType, aReason);
|
|
|
|
|
bool isAudio = aType == MediaData::AUDIO_DATA;
|
|
|
|
@ -933,7 +933,7 @@ MediaDecoderStateMachine::OnNotDecoded(MediaData::Type aType,
|
|
|
|
|
void
|
|
|
|
|
MediaDecoderStateMachine::MaybeFinishDecodeFirstFrame()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
if ((IsAudioDecoding() && AudioQueue().GetSize() == 0) ||
|
|
|
|
|
(IsVideoDecoding() && VideoQueue().GetSize() == 0)) {
|
|
|
|
@ -947,7 +947,7 @@ MediaDecoderStateMachine::MaybeFinishDecodeFirstFrame()
|
|
|
|
|
void
|
|
|
|
|
MediaDecoderStateMachine::OnVideoDecoded(VideoData* aVideoSample)
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
nsRefPtr<VideoData> video(aVideoSample);
|
|
|
|
|
mVideoDataRequest.Complete();
|
|
|
|
@ -1054,7 +1054,7 @@ MediaDecoderStateMachine::OnVideoDecoded(VideoData* aVideoSample)
|
|
|
|
|
void
|
|
|
|
|
MediaDecoderStateMachine::CheckIfSeekComplete()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
|
|
|
|
|
const bool videoSeekComplete = IsVideoSeekComplete();
|
|
|
|
@ -1152,7 +1152,7 @@ nsresult MediaDecoderStateMachine::Init(MediaDecoderStateMachine* aCloneDonor)
|
|
|
|
|
|
|
|
|
|
void MediaDecoderStateMachine::StopPlayback()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
DECODER_LOG("StopPlayback()");
|
|
|
|
|
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
@ -1210,7 +1210,7 @@ void MediaDecoderStateMachine::MaybeStartPlayback()
|
|
|
|
|
|
|
|
|
|
void MediaDecoderStateMachine::UpdatePlaybackPositionInternal(int64_t aTime)
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
SAMPLE_LOG("UpdatePlaybackPositionInternal(%lld) (mStartTime=%lld)", aTime, mStartTime);
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
|
|
|
|
@ -1321,21 +1321,11 @@ void MediaDecoderStateMachine::SetAudioCaptured()
|
|
|
|
|
|
|
|
|
|
double MediaDecoderStateMachine::GetCurrentTime() const
|
|
|
|
|
{
|
|
|
|
|
NS_ASSERTION(NS_IsMainThread() ||
|
|
|
|
|
OnStateMachineThread() ||
|
|
|
|
|
OnDecodeThread(),
|
|
|
|
|
"Should be on main, decode, or state machine thread.");
|
|
|
|
|
|
|
|
|
|
return static_cast<double>(mCurrentFrameTime) / static_cast<double>(USECS_PER_S);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64_t MediaDecoderStateMachine::GetCurrentTimeUs() const
|
|
|
|
|
{
|
|
|
|
|
NS_ASSERTION(NS_IsMainThread() ||
|
|
|
|
|
OnStateMachineThread() ||
|
|
|
|
|
OnDecodeThread(),
|
|
|
|
|
"Should be on main, decode, or state machine thread.");
|
|
|
|
|
|
|
|
|
|
return mCurrentFrameTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1450,7 +1440,7 @@ bool MediaDecoderStateMachine::IsDormantNeeded()
|
|
|
|
|
|
|
|
|
|
void MediaDecoderStateMachine::SetDormant(bool aDormant)
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread(), "Should be on state machine thread.");
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
|
|
|
|
|
if (IsShutdown()) {
|
|
|
|
@ -1536,7 +1526,7 @@ void MediaDecoderStateMachine::Shutdown()
|
|
|
|
|
|
|
|
|
|
void MediaDecoderStateMachine::StartDecoding()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
if (mState == DECODER_STATE_DECODING) {
|
|
|
|
|
return;
|
|
|
|
@ -1562,7 +1552,7 @@ void MediaDecoderStateMachine::StartDecoding()
|
|
|
|
|
|
|
|
|
|
void MediaDecoderStateMachine::NotifyWaitingForResourcesStatusChanged()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
DECODER_LOG("NotifyWaitingForResourcesStatusChanged");
|
|
|
|
|
|
|
|
|
@ -1579,7 +1569,7 @@ void MediaDecoderStateMachine::NotifyWaitingForResourcesStatusChanged()
|
|
|
|
|
|
|
|
|
|
void MediaDecoderStateMachine::PlayInternal()
|
|
|
|
|
{
|
|
|
|
|
NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
|
|
|
|
|
// Once we start playing, we don't want to minimize our prerolling, as we
|
|
|
|
@ -1599,7 +1589,7 @@ void MediaDecoderStateMachine::PlayInternal()
|
|
|
|
|
// if the main thread invokes Play() and then Seek(), the seek will initiate
|
|
|
|
|
// synchronously on the main thread, and the asynchronous PlayInternal task
|
|
|
|
|
// will arrive when it's no longer valid. The proper thing to do is to move
|
|
|
|
|
// all state transitions to the state machine thread, but for now we just
|
|
|
|
|
// all state transitions to the state machine task queue, but for now we just
|
|
|
|
|
// make sure that none of the possible main-thread state transitions (Seek(),
|
|
|
|
|
// SetDormant(), and Shutdown()) have not occurred.
|
|
|
|
|
if (mState != DECODER_STATE_DECODING && mState != DECODER_STATE_BUFFERING &&
|
|
|
|
@ -1652,7 +1642,7 @@ void MediaDecoderStateMachine::NotifyDataArrived(const char* aBuffer,
|
|
|
|
|
nsRefPtr<MediaDecoder::SeekPromise>
|
|
|
|
|
MediaDecoderStateMachine::Seek(SeekTarget aTarget)
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
|
|
|
|
|
mDecodingFrozenAtStateDecoding = false;
|
|
|
|
@ -1690,7 +1680,7 @@ MediaDecoderStateMachine::Seek(SeekTarget aTarget)
|
|
|
|
|
|
|
|
|
|
void MediaDecoderStateMachine::StopAudioThread()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
|
|
|
|
|
if (mStopAudioThread) {
|
|
|
|
@ -1809,7 +1799,7 @@ MediaDecoderStateMachine::DispatchDecodeTasksIfNeeded()
|
|
|
|
|
void
|
|
|
|
|
MediaDecoderStateMachine::InitiateSeek()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
|
|
|
|
|
mCurrentSeek.RejectIfExists(__func__);
|
|
|
|
@ -1874,7 +1864,7 @@ MediaDecoderStateMachine::InitiateSeek()
|
|
|
|
|
nsresult
|
|
|
|
|
MediaDecoderStateMachine::DispatchAudioDecodeTaskIfNeeded()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
|
|
|
|
|
if (IsShutdown()) {
|
|
|
|
@ -1891,7 +1881,7 @@ MediaDecoderStateMachine::DispatchAudioDecodeTaskIfNeeded()
|
|
|
|
|
nsresult
|
|
|
|
|
MediaDecoderStateMachine::EnsureAudioDecodeTaskQueued()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
|
|
|
|
|
SAMPLE_LOG("EnsureAudioDecodeTaskQueued isDecoding=%d status=%s",
|
|
|
|
@ -1924,7 +1914,7 @@ MediaDecoderStateMachine::EnsureAudioDecodeTaskQueued()
|
|
|
|
|
nsresult
|
|
|
|
|
MediaDecoderStateMachine::DispatchVideoDecodeTaskIfNeeded()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
|
|
|
|
|
if (IsShutdown()) {
|
|
|
|
@ -1941,7 +1931,7 @@ MediaDecoderStateMachine::DispatchVideoDecodeTaskIfNeeded()
|
|
|
|
|
nsresult
|
|
|
|
|
MediaDecoderStateMachine::EnsureVideoDecodeTaskQueued()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
|
|
|
|
|
SAMPLE_LOG("EnsureVideoDecodeTaskQueued isDecoding=%d status=%s",
|
|
|
|
@ -1983,7 +1973,7 @@ MediaDecoderStateMachine::EnsureVideoDecodeTaskQueued()
|
|
|
|
|
nsresult
|
|
|
|
|
MediaDecoderStateMachine::StartAudioThread()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
if (mAudioCaptured) {
|
|
|
|
|
NS_ASSERTION(mStopAudioThread, "mStopAudioThread must always be true if audio is captured");
|
|
|
|
@ -2090,7 +2080,7 @@ bool MediaDecoderStateMachine::HasLowUndecodedData(int64_t aUsecs)
|
|
|
|
|
void
|
|
|
|
|
MediaDecoderStateMachine::DecodeError()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
if (IsShutdown()) {
|
|
|
|
|
// Already shutdown.
|
|
|
|
@ -2118,7 +2108,7 @@ void
|
|
|
|
|
MediaDecoderStateMachine::OnMetadataRead(MetadataHolder* aMetadata)
|
|
|
|
|
{
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
MOZ_ASSERT(mState == DECODER_STATE_DECODING_METADATA);
|
|
|
|
|
mMetadataRequest.Complete();
|
|
|
|
|
|
|
|
|
@ -2158,7 +2148,7 @@ void
|
|
|
|
|
MediaDecoderStateMachine::OnMetadataNotRead(ReadMetadataFailureReason aReason)
|
|
|
|
|
{
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
MOZ_ASSERT(mState == DECODER_STATE_DECODING_METADATA);
|
|
|
|
|
mMetadataRequest.Complete();
|
|
|
|
|
|
|
|
|
@ -2202,7 +2192,7 @@ MediaDecoderStateMachine::EnqueueFirstFrameLoadedEvent()
|
|
|
|
|
void
|
|
|
|
|
MediaDecoderStateMachine::CallDecodeFirstFrame()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
if (mState != DECODER_STATE_DECODING_FIRSTFRAME) {
|
|
|
|
|
return;
|
|
|
|
@ -2216,7 +2206,7 @@ MediaDecoderStateMachine::CallDecodeFirstFrame()
|
|
|
|
|
nsresult
|
|
|
|
|
MediaDecoderStateMachine::DecodeFirstFrame()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
MOZ_ASSERT(mState == DECODER_STATE_DECODING_FIRSTFRAME);
|
|
|
|
|
DECODER_LOG("DecodeFirstFrame started");
|
|
|
|
@ -2268,7 +2258,7 @@ nsresult
|
|
|
|
|
MediaDecoderStateMachine::FinishDecodeFirstFrame()
|
|
|
|
|
{
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
DECODER_LOG("FinishDecodeFirstFrame");
|
|
|
|
|
|
|
|
|
|
if (IsShutdown()) {
|
|
|
|
@ -2344,7 +2334,7 @@ void
|
|
|
|
|
MediaDecoderStateMachine::OnSeekCompleted(int64_t aTime)
|
|
|
|
|
{
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
mSeekRequest.Complete();
|
|
|
|
|
|
|
|
|
|
// We must decode the first samples of active streams, so we can determine
|
|
|
|
@ -2358,7 +2348,7 @@ void
|
|
|
|
|
MediaDecoderStateMachine::OnSeekFailed(nsresult aResult)
|
|
|
|
|
{
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
mSeekRequest.Complete();
|
|
|
|
|
MOZ_ASSERT(NS_FAILED(aResult), "Cancels should also disconnect mSeekRequest");
|
|
|
|
|
DecodeError();
|
|
|
|
@ -2367,7 +2357,7 @@ MediaDecoderStateMachine::OnSeekFailed(nsresult aResult)
|
|
|
|
|
void
|
|
|
|
|
MediaDecoderStateMachine::SeekCompleted()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
|
|
|
|
|
if (mState != DECODER_STATE_SEEKING) {
|
|
|
|
@ -2488,7 +2478,7 @@ MediaDecoderStateMachine::ShutdownReader()
|
|
|
|
|
void
|
|
|
|
|
MediaDecoderStateMachine::FinishShutdown()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
|
|
|
|
|
// The reader's listeners hold references to the state machine,
|
|
|
|
@ -2527,10 +2517,10 @@ MediaDecoderStateMachine::FinishShutdown()
|
|
|
|
|
|
|
|
|
|
nsresult MediaDecoderStateMachine::RunStateMachine()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
|
|
|
|
|
mDelayedScheduler.Reset(); // Must happen on state machine thread.
|
|
|
|
|
mDelayedScheduler.Reset(); // Must happen on state machine task queue.
|
|
|
|
|
mDispatchedStateMachine = false;
|
|
|
|
|
|
|
|
|
|
// If audio is being captured, stop the audio sink if it's running
|
|
|
|
@ -2730,7 +2720,7 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
|
|
|
|
|
void
|
|
|
|
|
MediaDecoderStateMachine::Reset()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
DECODER_LOG("MediaDecoderStateMachine::Reset");
|
|
|
|
|
|
|
|
|
@ -2776,7 +2766,7 @@ MediaDecoderStateMachine::Reset()
|
|
|
|
|
void MediaDecoderStateMachine::RenderVideoFrame(VideoData* aData,
|
|
|
|
|
TimeStamp aTarget)
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
mDecoder->GetReentrantMonitor().AssertNotCurrentThreadIn();
|
|
|
|
|
|
|
|
|
|
if (aData->mDuplicate) {
|
|
|
|
@ -2881,7 +2871,7 @@ int64_t MediaDecoderStateMachine::GetClock() const
|
|
|
|
|
|
|
|
|
|
void MediaDecoderStateMachine::AdvanceFrame()
|
|
|
|
|
{
|
|
|
|
|
NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
NS_ASSERTION(!HasAudio() || mAudioStartTime != -1,
|
|
|
|
|
"Should know audio start time if we have audio.");
|
|
|
|
@ -3305,9 +3295,9 @@ void
|
|
|
|
|
MediaDecoderStateMachine::ScheduleStateMachineIn(int64_t aMicroseconds)
|
|
|
|
|
{
|
|
|
|
|
AssertCurrentThreadInMonitor();
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread()); // mDelayedScheduler.Ensure() may Disconnect()
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue()); // mDelayedScheduler.Ensure() may Disconnect()
|
|
|
|
|
// the promise, which must happen on the state
|
|
|
|
|
// machine thread.
|
|
|
|
|
// machine task queue.
|
|
|
|
|
MOZ_ASSERT(aMicroseconds > 0);
|
|
|
|
|
if (mState == DECODER_STATE_SHUTDOWN) {
|
|
|
|
|
NS_WARNING("Refusing to schedule shutdown state machine");
|
|
|
|
@ -3335,7 +3325,7 @@ bool MediaDecoderStateMachine::OnDecodeThread() const
|
|
|
|
|
return !DecodeTaskQueue() || DecodeTaskQueue()->IsCurrentThreadIn();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MediaDecoderStateMachine::OnStateMachineThread() const
|
|
|
|
|
bool MediaDecoderStateMachine::OnTaskQueue() const
|
|
|
|
|
{
|
|
|
|
|
return TaskQueue()->IsCurrentThreadIn();
|
|
|
|
|
}
|
|
|
|
@ -3438,7 +3428,7 @@ void MediaDecoderStateMachine::OnAudioSinkComplete()
|
|
|
|
|
|
|
|
|
|
void MediaDecoderStateMachine::OnAudioSinkError()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(OnStateMachineThread());
|
|
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
|
|
|
|
// AudioSink not used with captured streams, so ignore errors in this case.
|
|
|
|
|
if (mAudioCaptured) {
|
|
|
|
|