Bug 1179499 - Assert NS_IsMainThread on a bunch of MediaDecoder methods. r=jww

This commit is contained in:
Bobby Holley 2015-06-30 14:39:41 -07:00
Родитель f7e9590b7b
Коммит bb1f9a0082
2 изменённых файлов: 30 добавлений и 6 удалений

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

@ -128,6 +128,7 @@ PRLogModuleInfo* gMediaSampleLog;
void
MediaDecoder::InitStatics()
{
MOZ_ASSERT(NS_IsMainThread());
AbstractThread::InitStatics();
SharedThreadPool::InitStatics();
@ -240,6 +241,7 @@ void MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity)
void MediaDecoder::DormantTimerExpired(nsITimer* aTimer, void* aClosure)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aClosure);
MediaDecoder* decoder = static_cast<MediaDecoder*>(aClosure);
ReentrantMonitorAutoEnter mon(decoder->GetReentrantMonitor());
@ -249,6 +251,7 @@ void MediaDecoder::DormantTimerExpired(nsITimer* aTimer, void* aClosure)
void MediaDecoder::StartDormantTimer()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mIsHeuristicDormantSupported) {
return;
}
@ -274,6 +277,7 @@ void MediaDecoder::StartDormantTimer()
void MediaDecoder::CancelDormantTimer()
{
MOZ_ASSERT(NS_IsMainThread());
if (mDormantTimer) {
mDormantTimer->Cancel();
}
@ -508,7 +512,7 @@ nsresult MediaDecoder::InitializeStateMachine(MediaDecoder* aCloneDonor)
void MediaDecoder::SetStateMachineParameters()
{
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
MOZ_ASSERT(NS_IsMainThread());
if (mMinimizePreroll) {
mDecoderStateMachine->DispatchMinimizePrerollUntilPlaybackStarts();
}
@ -516,8 +520,8 @@ void MediaDecoder::SetStateMachineParameters()
void MediaDecoder::SetMinimizePrerollUntilPlaybackStarts()
{
DECODER_LOG("SetMinimizePrerollUntilPlaybackStarts()");
MOZ_ASSERT(NS_IsMainThread());
DECODER_LOG("SetMinimizePrerollUntilPlaybackStarts()");
mMinimizePreroll = true;
// This needs to be called before we init the state machine, otherwise it will
@ -595,6 +599,7 @@ nsresult MediaDecoder::Seek(double aTime, SeekTarget::Type aSeekType)
void MediaDecoder::CallSeek(const SeekTarget& aTarget)
{
MOZ_ASSERT(NS_IsMainThread());
mSeekRequest.DisconnectIfExists();
mSeekRequest.Begin(ProxyMediaCall(mDecoderStateMachine->TaskQueue(),
mDecoderStateMachine.get(), __func__,
@ -674,6 +679,7 @@ void MediaDecoder::MetadataLoaded(nsAutoPtr<MediaInfo> aInfo,
const char*
MediaDecoder::PlayStateStr()
{
MOZ_ASSERT(NS_IsMainThread());
switch (mPlayState) {
case PLAY_STATE_START: return "PLAY_STATE_START";
case PLAY_STATE_LOADING: return "PLAY_STATE_LOADING";
@ -766,6 +772,7 @@ void MediaDecoder::DecodeError()
void MediaDecoder::UpdateSameOriginStatus(bool aSameOrigin)
{
MOZ_ASSERT(NS_IsMainThread());
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
mSameOriginMedia = aSameOrigin;
}
@ -790,6 +797,7 @@ bool MediaDecoder::IsEndedOrShutdown() const
bool MediaDecoder::IsEnded() const
{
MOZ_ASSERT(NS_IsMainThread());
return mPlayState == PLAY_STATE_ENDED ||
(mWasEndedWhenEnteredDormant && (mPlayState != PLAY_STATE_SHUTDOWN));
}
@ -863,7 +871,7 @@ double MediaDecoder::ComputePlaybackRate(bool* aReliable)
void MediaDecoder::UpdatePlaybackRate()
{
MOZ_ASSERT(NS_IsMainThread() || OnStateMachineTaskQueue());
MOZ_ASSERT(NS_IsMainThread());
GetReentrantMonitor().AssertCurrentThreadIn();
if (!mResource)
return;
@ -933,6 +941,7 @@ void MediaDecoder::NotifyDownloadEnded(nsresult aStatus)
void MediaDecoder::NotifyPrincipalChanged()
{
MOZ_ASSERT(NS_IsMainThread());
if (mOwner) {
mOwner->NotifyDecoderPrincipalChanged();
}
@ -1139,6 +1148,7 @@ bool MediaDecoder::IsMediaSeekable()
media::TimeIntervals MediaDecoder::GetSeekable()
{
MOZ_ASSERT(NS_IsMainThread());
// We can seek in buffered range if the media is seekable. Also, we can seek
// in unbuffered ranges if the transport level is seekable (local file or the
// server supports range requests, etc.)
@ -1225,6 +1235,7 @@ bool MediaDecoder::OnStateMachineTaskQueue() const
void MediaDecoder::SetPlaybackRate(double aPlaybackRate)
{
MOZ_ASSERT(NS_IsMainThread());
mPlaybackRate = aPlaybackRate;
if (mPlaybackRate == 0.0) {
mPausedForPlaybackRateNull = true;
@ -1242,6 +1253,7 @@ void MediaDecoder::SetPlaybackRate(double aPlaybackRate)
void MediaDecoder::SetPreservesPitch(bool aPreservesPitch)
{
MOZ_ASSERT(NS_IsMainThread());
mPreservesPitch = aPreservesPitch;
}
@ -1253,6 +1265,7 @@ bool MediaDecoder::OnDecodeTaskQueue() const {
void
MediaDecoder::SetStateMachine(MediaDecoderStateMachine* aStateMachine)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT_IF(aStateMachine, !mDecoderStateMachine);
mDecoderStateMachine = aStateMachine;
@ -1297,10 +1310,12 @@ void MediaDecoder::Invalidate()
// Constructs the time ranges representing what segments of the media
// are buffered and playable.
media::TimeIntervals MediaDecoder::GetBuffered() {
MOZ_ASSERT(NS_IsMainThread());
return mBuffered.Ref();
}
size_t MediaDecoder::SizeOfVideoQueue() {
MOZ_ASSERT(NS_IsMainThread());
if (mDecoderStateMachine) {
return mDecoderStateMachine->SizeOfVideoQueue();
}
@ -1308,6 +1323,7 @@ size_t MediaDecoder::SizeOfVideoQueue() {
}
size_t MediaDecoder::SizeOfAudioQueue() {
MOZ_ASSERT(NS_IsMainThread());
if (mDecoderStateMachine) {
return mDecoderStateMachine->SizeOfAudioQueue();
}
@ -1360,6 +1376,7 @@ MediaDecoderOwner* MediaDecoder::GetMediaOwner() const
void MediaDecoder::FireTimeUpdate()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mOwner)
return;
mOwner->FireTimeUpdate(true);
@ -1367,6 +1384,7 @@ void MediaDecoder::FireTimeUpdate()
void MediaDecoder::PinForSeek()
{
MOZ_ASSERT(NS_IsMainThread());
MediaResource* resource = GetResource();
if (!resource || mPinnedForSeek) {
return;
@ -1377,6 +1395,7 @@ void MediaDecoder::PinForSeek()
void MediaDecoder::UnpinForSeek()
{
MOZ_ASSERT(NS_IsMainThread());
MediaResource* resource = GetResource();
if (!resource || !mPinnedForSeek) {
return;
@ -1425,8 +1444,8 @@ bool MediaDecoder::CanPlayThrough()
nsresult
MediaDecoder::SetCDMProxy(CDMProxy* aProxy)
{
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
MOZ_ASSERT(NS_IsMainThread());
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
mProxy = aProxy;
// Awaken any readers waiting for the proxy.
NotifyWaitingForResourcesStatusChanged();

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

@ -339,7 +339,7 @@ public:
}
void SetResource(MediaResource* aResource)
{
NS_ASSERTION(NS_IsMainThread(), "Should only be called on main thread");
MOZ_ASSERT(NS_IsMainThread());
mResource = aResource;
}
@ -640,6 +640,7 @@ public:
void OnSeekRejected()
{
MOZ_ASSERT(NS_IsMainThread());
mSeekRequest.Complete();
mLogicallySeeking = false;
}
@ -650,7 +651,11 @@ public:
void SeekingStarted(MediaDecoderEventVisibility aEventVisibility = MediaDecoderEventVisibility::Observable);
void UpdateLogicalPosition(MediaDecoderEventVisibility aEventVisibility);
void UpdateLogicalPosition() { UpdateLogicalPosition(MediaDecoderEventVisibility::Observable); }
void UpdateLogicalPosition()
{
MOZ_ASSERT(NS_IsMainThread());
UpdateLogicalPosition(MediaDecoderEventVisibility::Observable);
}
// Find the end of the cached data starting at the current decoder
// position.