Bug 1289004. Part 2 - Add MediaDecoder::IsShutdown(). r=cpearce

MozReview-Commit-ID: 50muOKcUqYi

--HG--
extra : rebase_source : d97e968c980dcc146824bb6703747f23b0a5b651
extra : source : 2ca76a5cecbb9c6ef107794eab32bb13633880a2
This commit is contained in:
JW Wang 2016-07-13 16:45:30 +08:00
Родитель 694dff250f
Коммит 12fd7814cd
3 изменённых файлов: 43 добавлений и 34 удалений

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

@ -293,7 +293,7 @@ MediaDecoder::NotifyOwnerActivityChanged(bool aIsVisible)
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown) {
if (IsShutdown()) {
return;
}
@ -323,7 +323,7 @@ MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity)
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown ||
if (IsShutdown() ||
!mDecoderStateMachine ||
mPlayState == PLAY_STATE_SHUTDOWN ||
!mOwner->GetVideoFrameContainer() ||
@ -395,7 +395,7 @@ MediaDecoder::StartDormantTimer()
}
if (mIsHeuristicDormant ||
mShuttingDown ||
IsShutdown() ||
mIsVisible ||
(mPlayState != PLAY_STATE_PAUSED &&
!IsEnded()))
@ -476,7 +476,7 @@ void
MediaDecoder::SetInfinite(bool aInfinite)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShuttingDown);
MOZ_ASSERT(!IsShutdown());
mInfiniteStream = aInfinite;
DurationChanged();
}
@ -607,7 +607,7 @@ MediaDecoder::Shutdown()
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown) {
if (IsShutdown()) {
return;
}
@ -807,7 +807,7 @@ nsresult
MediaDecoder::Seek(double aTime, SeekTarget::Type aSeekType, dom::Promise* aPromise /*=nullptr*/)
{
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_TRUE(!mShuttingDown, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(!IsShutdown(), NS_ERROR_FAILURE);
UpdateDormantState(false /* aDormantTimeout */, true /* aActivity */);
@ -910,7 +910,7 @@ MediaDecoder::MetadataLoaded(nsAutoPtr<MediaInfo> aInfo,
MediaDecoderEventVisibility aEventVisibility)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShuttingDown);
MOZ_ASSERT(!IsShutdown());
DECODER_LOG("MetadataLoaded, channels=%u rate=%u hasAudio=%d hasVideo=%d",
aInfo->mAudio.mChannels, aInfo->mAudio.mRate,
@ -983,7 +983,7 @@ MediaDecoder::FirstFrameLoaded(nsAutoPtr<MediaInfo> aInfo,
MediaDecoderEventVisibility aEventVisibility)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShuttingDown);
MOZ_ASSERT(!IsShutdown());
DECODER_LOG("FirstFrameLoaded, channels=%u rate=%u hasAudio=%d hasVideo=%d mPlayState=%s mIsDormant=%d",
aInfo->mAudio.mChannels, aInfo->mAudio.mRate,
@ -1016,7 +1016,7 @@ nsresult
MediaDecoder::FinishDecoderSetup(MediaResource* aResource)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShuttingDown);
MOZ_ASSERT(!IsShutdown());
HTMLMediaElement* element = mOwner->GetMediaElement();
NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
element->FinishDecoderSetup(this, aResource);
@ -1027,7 +1027,7 @@ void
MediaDecoder::ResetConnectionState()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShuttingDown);
MOZ_ASSERT(!IsShutdown());
// Notify the media element that connection gets lost.
mOwner->ResetConnectionState();
@ -1042,7 +1042,7 @@ void
MediaDecoder::NetworkError()
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown)
if (IsShutdown())
return;
mOwner->NetworkError();
@ -1053,7 +1053,7 @@ void
MediaDecoder::DecodeError()
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown)
if (IsShutdown())
return;
mOwner->DecodeError();
@ -1085,7 +1085,7 @@ bool
MediaDecoder::OwnerHasError() const
{
MOZ_ASSERT(NS_IsMainThread());
return mShuttingDown || mOwner->HasError();
return IsShutdown() || mOwner->HasError();
}
class MediaElementGMPCrashHelper : public GMPCrashHelper
@ -1123,12 +1123,19 @@ MediaDecoder::IsEnded() const
return mPlayState == PLAY_STATE_ENDED;
}
bool
MediaDecoder::IsShutdown() const
{
MOZ_ASSERT(NS_IsMainThread());
return mShuttingDown;
}
void
MediaDecoder::PlaybackEnded()
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown ||
if (IsShutdown() ||
mLogicallySeeking ||
mPlayState == PLAY_STATE_LOADING) {
return;
@ -1205,7 +1212,7 @@ void
MediaDecoder::NotifySuspendedStatusChanged()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShuttingDown);
MOZ_ASSERT(!IsShutdown());
if (mResource) {
bool suspended = mResource->IsSuspendedByCache();
mOwner->NotifySuspendedByCache(suspended);
@ -1216,7 +1223,7 @@ void
MediaDecoder::NotifyBytesDownloaded()
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown) {
if (IsShutdown()) {
return;
}
UpdatePlaybackRate();
@ -1227,7 +1234,7 @@ void
MediaDecoder::NotifyDownloadEnded(nsresult aStatus)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShuttingDown);
MOZ_ASSERT(!IsShutdown());
DECODER_LOG("NotifyDownloadEnded, status=%x", aStatus);
@ -1253,7 +1260,7 @@ void
MediaDecoder::NotifyPrincipalChanged()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShuttingDown);
MOZ_ASSERT(!IsShutdown());
nsCOMPtr<nsIPrincipal> newPrincipal = GetCurrentPrincipal();
mMediaPrincipalHandle = MakePrincipalHandle(newPrincipal);
mOwner->NotifyDecoderPrincipalChanged();
@ -1263,7 +1270,7 @@ void
MediaDecoder::NotifyBytesConsumed(int64_t aBytes, int64_t aOffset)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShuttingDown);
MOZ_ASSERT(!IsShutdown());
if (mIgnoreProgressData) {
return;
@ -1282,7 +1289,7 @@ MediaDecoder::OnSeekResolved(SeekResolveValue aVal)
MOZ_ASSERT(NS_IsMainThread());
mSeekRequest.Complete();
if (mShuttingDown)
if (IsShutdown())
return;
bool fireEnded = false;
@ -1322,7 +1329,7 @@ void
MediaDecoder::SeekingStarted(MediaDecoderEventVisibility aEventVisibility)
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown)
if (IsShutdown())
return;
if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) {
@ -1361,7 +1368,7 @@ void
MediaDecoder::UpdateLogicalPositionInternal(MediaDecoderEventVisibility aEventVisibility)
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown) {
if (IsShutdown()) {
return;
}
@ -1386,7 +1393,7 @@ MediaDecoder::DurationChanged()
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown) {
if (IsShutdown()) {
return;
}
@ -1666,7 +1673,7 @@ MediaDecoder::NotifyDataArrived() {
MOZ_ASSERT(NS_IsMainThread());
// Don't publish events since task queues might be shutting down.
if (mShuttingDown) {
if (IsShutdown()) {
return;
}
@ -1684,7 +1691,7 @@ void
MediaDecoder::FireTimeUpdate()
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown) {
if (IsShutdown()) {
return;
}
mOwner->FireTimeUpdate(true);
@ -1864,7 +1871,7 @@ MediaDecoder::GetOwner()
{
MOZ_ASSERT(NS_IsMainThread());
// mOwner is valid until shutdown.
return !mShuttingDown ? mOwner : nullptr;
return !IsShutdown() ? mOwner : nullptr;
}
void
@ -1872,7 +1879,7 @@ MediaDecoder::ConstructMediaTracks()
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown || mMediaTracksConstructed || !mInfo) {
if (IsShutdown() || mMediaTracksConstructed || !mInfo) {
return;
}
@ -1908,7 +1915,7 @@ MediaDecoder::RemoveMediaTracks()
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown) {
if (IsShutdown()) {
return;
}
@ -1949,16 +1956,16 @@ void
MediaDecoder::DumpDebugInfo()
{
DUMP_LOG("metadata: channels=%u rate=%u hasAudio=%d hasVideo=%d, "
"state: mPlayState=%s mIsDormant=%d, mShuttingDown=%d",
"state: mPlayState=%s mIsDormant=%d, IsShutdown()=%d",
mInfo ? mInfo->mAudio.mChannels : 0, mInfo ? mInfo->mAudio.mRate : 0,
mInfo ? mInfo->HasAudio() : 0, mInfo ? mInfo->HasVideo() : 0,
PlayStateStr(), mIsDormant, mShuttingDown);
PlayStateStr(), mIsDormant, IsShutdown());
nsString str;
GetMozDebugReaderData(str);
DUMP_LOG("reader data:\n%s", NS_ConvertUTF16toUTF8(str).get());
if (!mShuttingDown && GetStateMachine()) {
if (!IsShutdown() && GetStateMachine()) {
GetStateMachine()->DumpDebugInfo();
}
}
@ -1966,7 +1973,7 @@ MediaDecoder::DumpDebugInfo()
void
MediaDecoder::NotifyAudibleStateChanged()
{
MOZ_ASSERT(!mShuttingDown);
MOZ_ASSERT(!IsShutdown());
mOwner->SetAudibleState(mIsAudioDataAudible);
}

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

@ -493,7 +493,7 @@ private:
void UpdateReadyState()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mShuttingDown) {
if (!IsShutdown()) {
mOwner->UpdateReadyState();
}
}
@ -528,6 +528,8 @@ protected:
// Return true if the decoder has reached the end of playback
bool IsEnded() const;
bool IsShutdown() const;
// Called by the state machine to notify the decoder that the duration
// has changed.
void DurationChanged();

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

@ -138,7 +138,7 @@ MediaOmxCommonDecoder::ResumeStateMachine()
MOZ_ASSERT(NS_IsMainThread());
DECODER_LOG(LogLevel::Debug, ("%s current time %f", __PRETTY_FUNCTION__, mLogicalPosition));
if (mShuttingDown) {
if (IsShutdown()) {
return;
}