зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1159974 - Assert that we're on the state machine thread for most remaining MDSM methods. r=jww
There are a handful of methods where we can't yet assert this. This bug will tackle several of them.
This commit is contained in:
Родитель
ac4815e13b
Коммит
a56c0c760e
|
@ -314,6 +314,7 @@ MediaDecoderStateMachine::InitializationTask()
|
|||
}
|
||||
|
||||
bool MediaDecoderStateMachine::HasFutureAudio() {
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
NS_ASSERTION(HasAudio(), "Should only call HasFutureAudio() when we have audio");
|
||||
// We've got audio ready to play if:
|
||||
|
@ -328,6 +329,7 @@ bool MediaDecoderStateMachine::HasFutureAudio() {
|
|||
}
|
||||
|
||||
bool MediaDecoderStateMachine::HaveNextFrameData() {
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
return (!HasAudio() || HasFutureAudio()) &&
|
||||
(!HasVideo() || VideoQueue().GetSize() > 0);
|
||||
|
@ -567,6 +569,7 @@ void MediaDecoderStateMachine::SendStreamData()
|
|||
MediaDecoderStateMachine::WakeDecoderRunnable*
|
||||
MediaDecoderStateMachine::GetWakeDecoderRunnable()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
|
||||
if (!mPendingWakeDecoder.get()) {
|
||||
|
@ -577,6 +580,7 @@ MediaDecoderStateMachine::GetWakeDecoderRunnable()
|
|||
|
||||
bool MediaDecoderStateMachine::HaveEnoughDecodedAudio(int64_t aAmpleAudioUSecs)
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
|
||||
if (AudioQueue().GetSize() == 0 ||
|
||||
|
@ -604,6 +608,7 @@ bool MediaDecoderStateMachine::HaveEnoughDecodedAudio(int64_t aAmpleAudioUSecs)
|
|||
|
||||
bool MediaDecoderStateMachine::HaveEnoughDecodedVideo()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
|
||||
if (static_cast<uint32_t>(VideoQueue().GetSize()) < GetAmpleVideoFrames() * mPlaybackRate) {
|
||||
|
@ -628,6 +633,7 @@ bool MediaDecoderStateMachine::HaveEnoughDecodedVideo()
|
|||
bool
|
||||
MediaDecoderStateMachine::NeedToDecodeVideo()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
return IsVideoDecoding() &&
|
||||
((mState == DECODER_STATE_SEEKING && mDecodeToSeekTarget) ||
|
||||
|
@ -639,6 +645,7 @@ MediaDecoderStateMachine::NeedToDecodeVideo()
|
|||
bool
|
||||
MediaDecoderStateMachine::NeedToSkipToNextKeyframe()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
if (mState == DECODER_STATE_DECODING_FIRSTFRAME) {
|
||||
return false;
|
||||
|
@ -688,6 +695,7 @@ MediaDecoderStateMachine::NeedToSkipToNextKeyframe()
|
|||
bool
|
||||
MediaDecoderStateMachine::NeedToDecodeAudio()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
SAMPLE_LOG("NeedToDecodeAudio() isDec=%d decToTar=%d minPrl=%d seek=%d enufAud=%d",
|
||||
IsAudioDecoding(), mDecodeToSeekTarget, mMinimizePreroll,
|
||||
|
@ -706,6 +714,7 @@ MediaDecoderStateMachine::NeedToDecodeAudio()
|
|||
bool
|
||||
MediaDecoderStateMachine::IsAudioSeekComplete()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
SAMPLE_LOG("IsAudioSeekComplete() curTarVal=%d mAudDis=%d aqFin=%d aqSz=%d",
|
||||
mCurrentSeek.Exists(), mDropAudioUntilNextDiscontinuity, AudioQueue().IsFinished(), AudioQueue().GetSize());
|
||||
|
@ -719,6 +728,7 @@ MediaDecoderStateMachine::IsAudioSeekComplete()
|
|||
bool
|
||||
MediaDecoderStateMachine::IsVideoSeekComplete()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
SAMPLE_LOG("IsVideoSeekComplete() curTarVal=%d mVidDis=%d vqFin=%d vqSz=%d",
|
||||
mCurrentSeek.Exists(), mDropVideoUntilNextDiscontinuity, VideoQueue().IsFinished(), VideoQueue().GetSize());
|
||||
|
@ -1143,6 +1153,7 @@ MediaDecoderStateMachine::CheckIfSeekComplete()
|
|||
bool
|
||||
MediaDecoderStateMachine::IsAudioDecoding()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
return HasAudio() && !AudioQueue().IsFinished();
|
||||
}
|
||||
|
@ -1150,6 +1161,7 @@ MediaDecoderStateMachine::IsAudioDecoding()
|
|||
bool
|
||||
MediaDecoderStateMachine::IsVideoDecoding()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
return HasVideo() && !VideoQueue().IsFinished();
|
||||
}
|
||||
|
@ -1753,6 +1765,7 @@ void MediaDecoderStateMachine::StopAudioThread()
|
|||
nsresult
|
||||
MediaDecoderStateMachine::EnqueueDecodeFirstFrameTask()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
MOZ_ASSERT(mState == DECODER_STATE_DECODING_FIRSTFRAME);
|
||||
|
||||
|
@ -2041,6 +2054,7 @@ MediaDecoderStateMachine::StartAudioThread()
|
|||
|
||||
int64_t MediaDecoderStateMachine::AudioDecodedUsecs()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
NS_ASSERTION(HasAudio(),
|
||||
"Should only call AudioDecodedUsecs() when we have audio");
|
||||
// The amount of audio we have decoded is the amount of audio data we've
|
||||
|
@ -2058,6 +2072,7 @@ int64_t MediaDecoderStateMachine::AudioDecodedUsecs()
|
|||
|
||||
bool MediaDecoderStateMachine::HasLowDecodedData(int64_t aAudioUsecs)
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
MOZ_ASSERT(mReader->UseBufferingHeuristics());
|
||||
// We consider ourselves low on decoded data if we're low on audio,
|
||||
|
@ -2071,6 +2086,7 @@ bool MediaDecoderStateMachine::HasLowDecodedData(int64_t aAudioUsecs)
|
|||
|
||||
bool MediaDecoderStateMachine::OutOfDecodedAudio()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
return IsAudioDecoding() && !AudioQueue().IsFinished() &&
|
||||
AudioQueue().GetSize() == 0 &&
|
||||
(!mAudioSink || !mAudioSink->HasUnplayedFrames());
|
||||
|
@ -2078,11 +2094,13 @@ bool MediaDecoderStateMachine::OutOfDecodedAudio()
|
|||
|
||||
bool MediaDecoderStateMachine::HasLowUndecodedData()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
return HasLowUndecodedData(mLowDataThresholdUsecs);
|
||||
}
|
||||
|
||||
bool MediaDecoderStateMachine::HasLowUndecodedData(int64_t aUsecs)
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
NS_ASSERTION(mState > DECODER_STATE_DECODING_FIRSTFRAME,
|
||||
"Must have loaded first frame for GetBuffered() to work");
|
||||
|
@ -2146,9 +2164,9 @@ MediaDecoderStateMachine::DecodeError()
|
|||
void
|
||||
MediaDecoderStateMachine::OnMetadataRead(MetadataHolder* aMetadata)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
MOZ_ASSERT(mState == DECODER_STATE_DECODING_METADATA);
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mMetadataRequest.Complete();
|
||||
|
||||
mDecoder->SetMediaSeekable(mReader->IsMediaSeekable());
|
||||
|
@ -2186,9 +2204,9 @@ MediaDecoderStateMachine::OnMetadataRead(MetadataHolder* aMetadata)
|
|||
void
|
||||
MediaDecoderStateMachine::OnMetadataNotRead(ReadMetadataFailureReason aReason)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
MOZ_ASSERT(mState == DECODER_STATE_DECODING_METADATA);
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mMetadataRequest.Complete();
|
||||
|
||||
if (aReason == ReadMetadataFailureReason::WAITING_FOR_RESOURCES) {
|
||||
|
@ -2299,8 +2317,8 @@ MediaDecoderStateMachine::DecodeFirstFrame()
|
|||
nsresult
|
||||
MediaDecoderStateMachine::FinishDecodeFirstFrame()
|
||||
{
|
||||
AssertCurrentThreadInMonitor();
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
DECODER_LOG("FinishDecodeFirstFrame");
|
||||
|
||||
if (IsShutdown()) {
|
||||
|
@ -2375,8 +2393,8 @@ MediaDecoderStateMachine::FinishDecodeFirstFrame()
|
|||
void
|
||||
MediaDecoderStateMachine::OnSeekCompleted(int64_t aTime)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mSeekRequest.Complete();
|
||||
|
||||
// We must decode the first samples of active streams, so we can determine
|
||||
|
@ -2389,8 +2407,8 @@ MediaDecoderStateMachine::OnSeekCompleted(int64_t aTime)
|
|||
void
|
||||
MediaDecoderStateMachine::OnSeekFailed(nsresult aResult)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mSeekRequest.Complete();
|
||||
MOZ_ASSERT(NS_FAILED(aResult), "Cancels should also disconnect mSeekRequest");
|
||||
DecodeError();
|
||||
|
@ -2838,6 +2856,7 @@ void MediaDecoderStateMachine::RenderVideoFrame(VideoData* aData,
|
|||
|
||||
void MediaDecoderStateMachine::ResyncAudioClock()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
if (IsPlaying()) {
|
||||
SetPlayStartTime(TimeStamp::Now());
|
||||
|
@ -2848,6 +2867,7 @@ void MediaDecoderStateMachine::ResyncAudioClock()
|
|||
int64_t
|
||||
MediaDecoderStateMachine::GetAudioClock() const
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
// We must hold the decoder monitor while using the audio stream off the
|
||||
// audio sink to ensure that it doesn't get destroyed on the audio sink
|
||||
// while we're using it.
|
||||
|
@ -2874,6 +2894,7 @@ int64_t MediaDecoderStateMachine::GetVideoStreamPosition() const
|
|||
|
||||
int64_t MediaDecoderStateMachine::GetClock() const
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
|
||||
// Determine the clock time. If we've got audio, and we've not reached
|
||||
|
@ -3053,6 +3074,7 @@ void MediaDecoderStateMachine::AdvanceFrame()
|
|||
nsresult
|
||||
MediaDecoderStateMachine::DropVideoUpToSeekTarget(VideoData* aSample)
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
nsRefPtr<VideoData> video(aSample);
|
||||
MOZ_ASSERT(video);
|
||||
DECODER_LOG("DropVideoUpToSeekTarget() frame [%lld, %lld] dup=%d",
|
||||
|
@ -3104,6 +3126,7 @@ MediaDecoderStateMachine::DropVideoUpToSeekTarget(VideoData* aSample)
|
|||
nsresult
|
||||
MediaDecoderStateMachine::DropAudioUpToSeekTarget(AudioData* aSample)
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
nsRefPtr<AudioData> audio(aSample);
|
||||
MOZ_ASSERT(audio &&
|
||||
mCurrentSeek.Exists() &&
|
||||
|
@ -3199,7 +3222,8 @@ void MediaDecoderStateMachine::SetStartTime(int64_t aStartTimeUsecs)
|
|||
DECODER_LOG("Set media start time to %lld", mStartTime);
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::UpdateNextFrameStatus() {
|
||||
void MediaDecoderStateMachine::UpdateNextFrameStatus()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
|
||||
|
@ -3228,6 +3252,7 @@ void MediaDecoderStateMachine::UpdateNextFrameStatus() {
|
|||
|
||||
bool MediaDecoderStateMachine::JustExitedQuickBuffering()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
return !mDecodeStartTime.IsNull() &&
|
||||
mQuickBuffering &&
|
||||
(TimeStamp::Now() - mDecodeStartTime) < TimeDuration::FromMicroseconds(QUICK_BUFFER_THRESHOLD_USECS);
|
||||
|
@ -3285,7 +3310,9 @@ void MediaDecoderStateMachine::SetPlayStartTime(const TimeStamp& aTimeStamp)
|
|||
}
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::ScheduleStateMachineWithLockAndWakeDecoder() {
|
||||
void MediaDecoderStateMachine::ScheduleStateMachineWithLockAndWakeDecoder()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
DispatchAudioDecodeTaskIfNeeded();
|
||||
DispatchVideoDecodeTaskIfNeeded();
|
||||
|
@ -3471,6 +3498,7 @@ void MediaDecoderStateMachine::OnAudioSinkError()
|
|||
|
||||
uint32_t MediaDecoderStateMachine::GetAmpleVideoFrames() const
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
return (mReader->IsAsync() && mReader->VideoIsHardwareAccelerated())
|
||||
? std::max<uint32_t>(sVideoQueueHWAccelSize, MIN_VIDEO_QUEUE_SIZE)
|
||||
|
|
|
@ -1080,12 +1080,14 @@ protected:
|
|||
|
||||
bool DonePrerollingAudio()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
return !IsAudioDecoding() || GetDecodedAudioDuration() >= AudioPrerollUsecs() * mPlaybackRate;
|
||||
}
|
||||
|
||||
bool DonePrerollingVideo()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
return !IsVideoDecoding() ||
|
||||
static_cast<uint32_t>(VideoQueue().GetSize()) >= VideoPrerollFrames() * mPlaybackRate;
|
||||
|
|
Загрузка…
Ссылка в новой задаче