Bug 515552 - Enable in-monitor assertions in nsOggDecoder. r=chris.double
--- a/content/media/ogg/nsOggDecoder.cpp
+++ b/content/media/ogg/nsOggDecoder.cpp
@@ -286,17 +286,17 @@ public:
void Seek(float aTime);
void StopStepDecodeThread(nsAutoMonitor* aMonitor);
NS_IMETHOD Run();
PRBool HasAudio()
{
NS_ASSERTION(mState > DECODER_STATE_DECODING_METADATA, "HasAudio() called during invalid state");
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "HasAudio() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
return mAudioTrack != -1;
}
// Decode one frame of data, returning the OggPlay error code. Must
// be called only when the current state > DECODING_METADATA. The decode
// monitor MUST NOT be locked during this call since it can take a long
// time. liboggplay internally handles locking.
// Any return value apart from those below is mean decoding cannot continue.
@@ -969,17 +969,17 @@ void nsOggDecodeStateMachine::PlayFrame(
return;
}
}
}
}
void nsOggDecodeStateMachine::PlayVideo(FrameData* aFrame)
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "PlayVideo() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
if (aFrame && aFrame->mVideoHeader) {
OggPlayVideoData* videoData = oggplay_callback_info_get_video_data(aFrame->mVideoHeader);
OggPlayYUVChannels yuv;
yuv.ptry = videoData->y;
yuv.ptru = videoData->u;
yuv.ptrv = videoData->v;
yuv.uv_width = aFrame->mUVWidth;
@@ -1004,64 +1004,64 @@ void nsOggDecodeStateMachine::PlayVideo(
// Don't play the frame's video data more than once.
aFrame->ClearVideoHeader();
}
}
void nsOggDecodeStateMachine::PlayAudio(FrameData* aFrame)
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "PlayAudio() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
if (!mAudioStream)
return;
aFrame->Write(mAudioStream);
}
void nsOggDecodeStateMachine::OpenAudioStream()
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "OpenAudioStream() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
mAudioStream = new nsAudioStream();
if (!mAudioStream) {
LOG(PR_LOG_ERROR, ("Could not create audio stream"));
}
else {
mAudioStream->Init(mAudioChannels, mAudioRate, nsAudioStream::FORMAT_FLOAT32);
mAudioStream->SetVolume(mVolume);
}
}
void nsOggDecodeStateMachine::CloseAudioStream()
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "CloseAudioStream() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
if (mAudioStream) {
mAudioStream->Shutdown();
mAudioStream = nsnull;
}
}
void nsOggDecodeStateMachine::StartAudio()
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "StartAudio() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
if (HasAudio()) {
OpenAudioStream();
}
}
void nsOggDecodeStateMachine::StopAudio()
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "StopAudio() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
if (HasAudio()) {
CloseAudioStream();
}
}
void nsOggDecodeStateMachine::StartPlayback()
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "StartPlayback() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
StartAudio();
mPlaying = PR_TRUE;
// If this is the very first play, then set the initial start time
if (mPlayStartTime.IsNull()) {
mPlayStartTime = TimeStamp::Now();
}
@@ -1073,17 +1073,17 @@ void nsOggDecodeStateMachine::StartPlayb
}
mPlayStartTime = TimeStamp::Now();
mPauseDuration = 0;
}
void nsOggDecodeStateMachine::StopPlayback()
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "StopPlayback() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
mLastFrame = mDecodedFrames.ResetTimes(mCallbackPeriod);
StopAudio();
mPlaying = PR_FALSE;
mPauseStartTime = TimeStamp::Now();
}
void nsOggDecodeStateMachine::PausePlayback()
{
@@ -1128,17 +1128,17 @@ void nsOggDecodeStateMachine::UpdatePlay
nsCOMPtr<nsIRunnable> event =
NS_NEW_RUNNABLE_METHOD(nsOggDecoder, mDecoder, PlaybackPositionChanged);
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
}
}
void nsOggDecodeStateMachine::QueueDecodedFrames()
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "QueueDecodedFrames() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
FrameData* frame;
while (!mDecodedFrames.IsFull() && (frame = NextFrame())) {
if (mDecodedFrames.GetCount() < 2) {
// Transitioning from 0 to 1 frames or from 1 to 2 frames could
// affect HaveNextFrameData and hence what UpdateReadyStateForData does.
// This could change us from HAVE_CURRENT_DATA to HAVE_FUTURE_DATA
// (or even HAVE_ENOUGH_DATA), so we'd better trigger an
// UpdateReadyStateForData.
@@ -1147,51 +1147,51 @@ void nsOggDecodeStateMachine::QueueDecod
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
}
mDecodedFrames.Push(frame);
}
}
void nsOggDecodeStateMachine::ClearPositionChangeFlag()
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "ClearPositionChangeFlag() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
mPositionChangeQueued = PR_FALSE;
}
void nsOggDecodeStateMachine::SetVolume(float volume)
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "SetVolume() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
if (mAudioStream) {
mAudioStream->SetVolume(volume);
}
mVolume = volume;
}
float nsOggDecodeStateMachine::GetCurrentTime()
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "GetCurrentTime() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
return mCurrentFrameTime;
}
PRInt64 nsOggDecodeStateMachine::GetDuration()
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "GetDuration() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
return mDuration;
}
void nsOggDecodeStateMachine::SetDuration(PRInt64 aDuration)
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "SetDuration() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
mDuration = aDuration;
}
void nsOggDecodeStateMachine::SetSeekable(PRBool aSeekable)
{
- // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "SetSeekable() called without acquiring decoder monitor");
+ PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
mSeekable = aSeekable;
}
void nsOggDecodeStateMachine::Shutdown()
{
// oggplay_prepare_for_close cannot be undone. Once called, the
// mPlayer object cannot decode any more frames. Once we've entered
// the shutdown state here there's no going back.