Backed out changeset 304e3ccaf533 (bug 1123452) for windows crashtest bustage on a CLOSED TREE

This commit is contained in:
Carsten "Tomcat" Book 2015-01-27 09:39:41 +01:00
Родитель 97952b7caa
Коммит 67dca2efae
2 изменённых файлов: 8 добавлений и 116 удалений

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

@ -36,9 +36,6 @@
using namespace mozilla::layers;
using namespace mozilla::dom;
// Default timeout msecs until try to enter dormant state by heuristic.
static const int DEFAULT_HEURISTIC_DORMANT_TIMEOUT_MSECS = 60000;
namespace mozilla {
// Number of estimated seconds worth of data we need to have buffered
@ -126,55 +123,27 @@ void MediaDecoder::NotifyOwnerActivityChanged()
MOZ_ASSERT(NS_IsMainThread());
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
if (!mOwner) {
NS_WARNING("MediaDecoder without a decoder owner, can't update dormant");
return;
}
UpdateDormantState(false /* aDormantTimeout */, false /* aActivity */);
// Start dormant timer if necessary
StartDormantTimer();
}
void MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity)
{
MOZ_ASSERT(NS_IsMainThread());
GetReentrantMonitor().AssertCurrentThreadIn();
if (!mDecoderStateMachine ||
!mOwner->GetVideoFrameContainer() ||
!mDecoderStateMachine->IsDormantNeeded() ||
mPlayState == PLAY_STATE_SHUTDOWN) {
return;
}
if (!mOwner) {
NS_WARNING("MediaDecoder without a decoder owner, can't update dormant");
return;
}
bool prevDormant = mIsDormant;
mIsDormant = false;
if (!mOwner->IsActive()) {
if (!mOwner->IsActive() && mOwner->GetVideoFrameContainer()) {
mIsDormant = true;
}
#ifdef MOZ_WIDGET_GONK
if (mOwner->IsHidden()) {
if (mOwner->IsHidden() && mOwner->GetVideoFrameContainer()) {
mIsDormant = true;
}
#endif
// Try to enable dormant by idle heuristic, when the owner is hidden.
bool prevHeuristicDormant = mIsHeuristicDormant;
mIsHeuristicDormant = false;
if (mIsHeuristicDormantSupported && mOwner->IsHidden()) {
if (aDormantTimeout && !aActivity &&
(mPlayState == PLAY_STATE_PAUSED || mPlayState == PLAY_STATE_ENDED)) {
// Enable heuristic dormant
mIsHeuristicDormant = true;
} else if(prevHeuristicDormant && !aActivity) {
// Continue heuristic dormant
mIsHeuristicDormant = true;
}
if (mIsHeuristicDormant) {
mIsDormant = true;
}
}
if (prevDormant == mIsDormant) {
// No update to dormant state
@ -198,45 +167,6 @@ void MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity)
}
}
void MediaDecoder::DormantTimerExpired(nsITimer* aTimer, void* aClosure)
{
MOZ_ASSERT(aClosure);
MediaDecoder* decoder = static_cast<MediaDecoder*>(aClosure);
ReentrantMonitorAutoEnter mon(decoder->GetReentrantMonitor());
decoder->UpdateDormantState(true /* aDormantTimeout */,
false /* aActivity */);
}
void MediaDecoder::StartDormantTimer()
{
if (!mIsHeuristicDormantSupported) {
return;
}
if (mIsHeuristicDormant ||
!mOwner->IsHidden() ||
(mPlayState != PLAY_STATE_PAUSED &&
mPlayState != PLAY_STATE_ENDED))
{
return;
}
if (!mDormantTimer) {
mDormantTimer = do_CreateInstance("@mozilla.org/timer;1");
}
mDormantTimer->InitWithFuncCallback(&MediaDecoder::DormantTimerExpired,
this,
mHeuristicDormantTimeout,
nsITimer::TYPE_ONE_SHOT);
}
void MediaDecoder::CancelDormantTimer()
{
if (mDormantTimer) {
mDormantTimer->Cancel();
}
}
void MediaDecoder::Pause()
{
MOZ_ASSERT(NS_IsMainThread());
@ -542,13 +472,7 @@ MediaDecoder::MediaDecoder() :
mPausedForPlaybackRateNull(false),
mMinimizePreroll(false),
mMediaTracksConstructed(false),
mIsDormant(false),
mIsHeuristicDormantSupported(
Preferences::GetBool("media.decoder.heuristic.dormant.enabled", false)),
mHeuristicDormantTimeout(
Preferences::GetInt("media.decoder.heuristic.dormant.timeout",
DEFAULT_HEURISTIC_DORMANT_TIMEOUT_MSECS)),
mIsHeuristicDormant(false)
mIsDormant(false)
{
MOZ_COUNT_CTOR(MediaDecoder);
MOZ_ASSERT(NS_IsMainThread());
@ -597,8 +521,6 @@ void MediaDecoder::Shutdown()
mResource->Close();
}
CancelDormantTimer();
ChangeState(PLAY_STATE_SHUTDOWN);
mOwner = nullptr;
@ -700,8 +622,6 @@ nsresult MediaDecoder::Play()
{
MOZ_ASSERT(NS_IsMainThread());
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
UpdateDormantState(false /* aDormantTimeout */, true /* aActivity */);
NS_ASSERTION(mDecoderStateMachine != nullptr, "Should have state machine.");
if (mPausedForPlaybackRateNull) {
return NS_OK;
@ -724,7 +644,6 @@ nsresult MediaDecoder::Seek(double aTime, SeekTarget::Type aSeekType)
{
MOZ_ASSERT(NS_IsMainThread());
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
UpdateDormantState(false /* aDormantTimeout */, true /* aActivity */);
NS_ABORT_IF_FALSE(aTime >= 0.0, "Cannot seek to a negative value.");
@ -1273,10 +1192,6 @@ void MediaDecoder::ChangeState(PlayState aState)
ApplyStateToStateMachine(mPlayState);
CancelDormantTimer();
// Start dormant timer if necessary
StartDormantTimer();
GetReentrantMonitor().NotifyAll();
}

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

@ -188,7 +188,6 @@ destroying the MediaDecoder object.
#include "nsCOMPtr.h"
#include "nsIObserver.h"
#include "nsAutoPtr.h"
#include "nsITimer.h"
#include "MediaResource.h"
#include "mozilla/dom/AudioChannelBinding.h"
#include "mozilla/gfx/Rect.h"
@ -368,8 +367,6 @@ public:
// It is used to share scarece media resources in system.
virtual void NotifyOwnerActivityChanged();
void UpdateDormantState(bool aDormantTimeout, bool aActivity);
// Pause video playback.
virtual void Pause();
// Adjust the speed of the playback, optionally with pitch correction,
@ -1025,14 +1022,6 @@ protected:
virtual ~MediaDecoder();
void SetStateMachineParameters();
static void DormantTimerExpired(nsITimer *aTimer, void *aClosure);
// Start a timer for heuristic dormant.
void StartDormantTimer();
// Cancel a timer for heuristic dormant.
void CancelDormantTimer();
/******
* The following members should be accessed with the decoder lock held.
******/
@ -1230,18 +1219,6 @@ protected:
// True if MediaDecoder is in dormant state.
bool mIsDormant;
// True if heuristic dormant is supported.
const bool mIsHeuristicDormantSupported;
// Timeout ms of heuristic dormant timer.
const int mHeuristicDormantTimeout;
// True if MediaDecoder is in dormant by heuristic.
bool mIsHeuristicDormant;
// Timer to schedule updating dormant state.
nsCOMPtr<nsITimer> mDormantTimer;
};
} // namespace mozilla