Bug 1161901 - Sprinkle more assertions and fix some formatting. r=jww

This commit is contained in:
Bobby Holley 2015-05-05 21:32:33 -07:00
Родитель 973ebd793d
Коммит aec6ecb986
2 изменённых файлов: 25 добавлений и 7 удалений

Просмотреть файл

@ -325,7 +325,8 @@ MediaDecoderStateMachine::InitializationTask()
mWatchManager.Watch(mLogicallySeeking, &MediaDecoderStateMachine::LogicallySeekingChanged); mWatchManager.Watch(mLogicallySeeking, &MediaDecoderStateMachine::LogicallySeekingChanged);
} }
bool MediaDecoderStateMachine::HasFutureAudio() { bool MediaDecoderStateMachine::HasFutureAudio()
{
MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(OnTaskQueue());
AssertCurrentThreadInMonitor(); AssertCurrentThreadInMonitor();
NS_ASSERTION(HasAudio(), "Should only call HasFutureAudio() when we have audio"); NS_ASSERTION(HasAudio(), "Should only call HasFutureAudio() when we have audio");
@ -340,14 +341,16 @@ bool MediaDecoderStateMachine::HasFutureAudio() {
AudioQueue().IsFinished()); AudioQueue().IsFinished());
} }
bool MediaDecoderStateMachine::HaveNextFrameData() { bool MediaDecoderStateMachine::HaveNextFrameData()
{
MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(OnTaskQueue());
AssertCurrentThreadInMonitor(); AssertCurrentThreadInMonitor();
return (!HasAudio() || HasFutureAudio()) && return (!HasAudio() || HasFutureAudio()) &&
(!HasVideo() || VideoQueue().GetSize() > 0); (!HasVideo() || VideoQueue().GetSize() > 0);
} }
int64_t MediaDecoderStateMachine::GetDecodedAudioDuration() { int64_t MediaDecoderStateMachine::GetDecodedAudioDuration()
{
MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(OnTaskQueue());
AssertCurrentThreadInMonitor(); AssertCurrentThreadInMonitor();
int64_t audioDecoded = AudioQueue().Duration(); int64_t audioDecoded = AudioQueue().Duration();
@ -1395,7 +1398,8 @@ int64_t MediaDecoderStateMachine::GetCurrentTimeUs() const
return mCurrentFrameTime; return mCurrentFrameTime;
} }
bool MediaDecoderStateMachine::IsRealTime() const { bool MediaDecoderStateMachine::IsRealTime() const
{
return mRealTime; return mRealTime;
} }
@ -3305,7 +3309,8 @@ void MediaDecoderStateMachine::ScheduleStateMachineWithLockAndWakeDecoder()
} }
void void
MediaDecoderStateMachine::ScheduleStateMachine() { MediaDecoderStateMachine::ScheduleStateMachine()
{
MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(OnTaskQueue());
AssertCurrentThreadInMonitor(); AssertCurrentThreadInMonitor();
if (mDispatchedStateMachine) { if (mDispatchedStateMachine) {
@ -3354,6 +3359,7 @@ bool MediaDecoderStateMachine::OnTaskQueue() const
bool MediaDecoderStateMachine::IsStateMachineScheduled() const bool MediaDecoderStateMachine::IsStateMachineScheduled() const
{ {
MOZ_ASSERT(OnTaskQueue());
return mDispatchedStateMachine || mDelayedScheduler.IsScheduled(); return mDispatchedStateMachine || mDelayedScheduler.IsScheduled();
} }

Просмотреть файл

@ -278,15 +278,15 @@ public:
// Must be called with the decode monitor held. // Must be called with the decode monitor held.
bool IsBuffering() const { bool IsBuffering() const {
MOZ_ASSERT(OnTaskQueue());
AssertCurrentThreadInMonitor(); AssertCurrentThreadInMonitor();
return mState == DECODER_STATE_BUFFERING; return mState == DECODER_STATE_BUFFERING;
} }
// Must be called with the decode monitor held. // Must be called with the decode monitor held.
bool IsSeeking() const { bool IsSeeking() const {
MOZ_ASSERT(OnTaskQueue());
AssertCurrentThreadInMonitor(); AssertCurrentThreadInMonitor();
return mState == DECODER_STATE_SEEKING; return mState == DECODER_STATE_SEEKING;
} }
@ -358,6 +358,7 @@ public:
// Drop reference to decoder. Only called during shutdown dance. // Drop reference to decoder. Only called during shutdown dance.
void BreakCycles() { void BreakCycles() {
MOZ_ASSERT(NS_IsMainThread());
if (mReader) { if (mReader) {
mReader->BreakCycles(); mReader->BreakCycles();
} }
@ -413,10 +414,12 @@ public:
void OnNotDecoded(MediaData::Type aType, MediaDecoderReader::NotDecodedReason aReason); void OnNotDecoded(MediaData::Type aType, MediaDecoderReader::NotDecodedReason aReason);
void OnAudioNotDecoded(MediaDecoderReader::NotDecodedReason aReason) void OnAudioNotDecoded(MediaDecoderReader::NotDecodedReason aReason)
{ {
MOZ_ASSERT(OnTaskQueue());
OnNotDecoded(MediaData::AUDIO_DATA, aReason); OnNotDecoded(MediaData::AUDIO_DATA, aReason);
} }
void OnVideoNotDecoded(MediaDecoderReader::NotDecodedReason aReason) void OnVideoNotDecoded(MediaDecoderReader::NotDecodedReason aReason)
{ {
MOZ_ASSERT(OnTaskQueue());
OnNotDecoded(MediaData::VIDEO_DATA, aReason); OnNotDecoded(MediaData::VIDEO_DATA, aReason);
} }
@ -507,6 +510,7 @@ protected:
bool OutOfDecodedVideo() bool OutOfDecodedVideo()
{ {
MOZ_ASSERT(OnTaskQueue());
// In buffering mode, we keep the last already-played frame in the queue. // In buffering mode, we keep the last already-played frame in the queue.
int emptyVideoSize = mState == DECODER_STATE_BUFFERING ? 1 : 0; int emptyVideoSize = mState == DECODER_STATE_BUFFERING ? 1 : 0;
return IsVideoDecoding() && !VideoQueue().IsFinished() && VideoQueue().GetSize() <= emptyVideoSize; return IsVideoDecoding() && !VideoQueue().IsFinished() && VideoQueue().GetSize() <= emptyVideoSize;
@ -826,6 +830,7 @@ public:
void CompleteRequest() void CompleteRequest()
{ {
MOZ_ASSERT(mSelf->OnTaskQueue());
mRequest.Complete(); mRequest.Complete();
mTarget = TimeStamp(); mTarget = TimeStamp();
} }
@ -1070,6 +1075,7 @@ protected:
// samples we must consume before are considered to be finished prerolling. // samples we must consume before are considered to be finished prerolling.
uint32_t AudioPrerollUsecs() const uint32_t AudioPrerollUsecs() const
{ {
MOZ_ASSERT(OnTaskQueue());
if (IsRealTime()) { if (IsRealTime()) {
return 0; return 0;
} }
@ -1081,6 +1087,7 @@ protected:
uint32_t VideoPrerollFrames() const uint32_t VideoPrerollFrames() const
{ {
MOZ_ASSERT(OnTaskQueue());
return IsRealTime() ? 0 : GetAmpleVideoFrames() / 2; return IsRealTime() ? 0 : GetAmpleVideoFrames() / 2;
} }
@ -1101,6 +1108,7 @@ protected:
void StopPrerollingAudio() void StopPrerollingAudio()
{ {
MOZ_ASSERT(OnTaskQueue());
AssertCurrentThreadInMonitor(); AssertCurrentThreadInMonitor();
if (mIsAudioPrerolling) { if (mIsAudioPrerolling) {
mIsAudioPrerolling = false; mIsAudioPrerolling = false;
@ -1110,6 +1118,7 @@ protected:
void StopPrerollingVideo() void StopPrerollingVideo()
{ {
MOZ_ASSERT(OnTaskQueue());
AssertCurrentThreadInMonitor(); AssertCurrentThreadInMonitor();
if (mIsVideoPrerolling) { if (mIsVideoPrerolling) {
mIsVideoPrerolling = false; mIsVideoPrerolling = false;
@ -1141,6 +1150,7 @@ protected:
MediaPromiseConsumerHolder<MediaDecoderReader::WaitForDataPromise> mAudioWaitRequest; MediaPromiseConsumerHolder<MediaDecoderReader::WaitForDataPromise> mAudioWaitRequest;
const char* AudioRequestStatus() const char* AudioRequestStatus()
{ {
MOZ_ASSERT(OnTaskQueue());
if (mAudioDataRequest.Exists()) { if (mAudioDataRequest.Exists()) {
MOZ_DIAGNOSTIC_ASSERT(!mAudioWaitRequest.Exists()); MOZ_DIAGNOSTIC_ASSERT(!mAudioWaitRequest.Exists());
return "pending"; return "pending";
@ -1154,6 +1164,7 @@ protected:
MediaPromiseConsumerHolder<MediaDecoderReader::VideoDataPromise> mVideoDataRequest; MediaPromiseConsumerHolder<MediaDecoderReader::VideoDataPromise> mVideoDataRequest;
const char* VideoRequestStatus() const char* VideoRequestStatus()
{ {
MOZ_ASSERT(OnTaskQueue());
if (mVideoDataRequest.Exists()) { if (mVideoDataRequest.Exists()) {
MOZ_DIAGNOSTIC_ASSERT(!mVideoWaitRequest.Exists()); MOZ_DIAGNOSTIC_ASSERT(!mVideoWaitRequest.Exists());
return "pending"; return "pending";
@ -1165,6 +1176,7 @@ protected:
MediaPromiseConsumerHolder<MediaDecoderReader::WaitForDataPromise>& WaitRequestRef(MediaData::Type aType) MediaPromiseConsumerHolder<MediaDecoderReader::WaitForDataPromise>& WaitRequestRef(MediaData::Type aType)
{ {
MOZ_ASSERT(OnTaskQueue());
return aType == MediaData::AUDIO_DATA ? mAudioWaitRequest : mVideoWaitRequest; return aType == MediaData::AUDIO_DATA ? mAudioWaitRequest : mVideoWaitRequest;
} }