Backed out 4 changesets (bug 1123535)

Backed out changeset b4eb1cc07186 (bug 1123535)
Backed out changeset dab05b7115f6 (bug 1123535)
Backed out changeset c2efa0319f04 (bug 1123535)
Backed out changeset 29304c69eff6 (bug 1123535)
This commit is contained in:
Ryan VanderMeulen 2015-01-27 22:00:11 -05:00
Родитель 3a4e166d49
Коммит ed4b315947
11 изменённых файлов: 47 добавлений и 159 удалений

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

@ -1578,9 +1578,9 @@ void MediaDecoderStateMachine::StartDecoding()
void MediaDecoderStateMachine::StartWaitForResources()
{
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
NS_ASSERTION(OnDecodeThread(),
"Should be on decode thread.");
NS_ASSERTION(OnStateMachineThread() || OnDecodeThread(),
"Should be on state machine or decode thread.");
AssertCurrentThreadInMonitor();
SetState(DECODER_STATE_WAIT_FOR_RESOURCES);
DECODER_LOG("StartWaitForResources");
}
@ -1967,7 +1967,7 @@ MediaDecoderStateMachine::EnsureAudioDecodeTaskQueued()
SAMPLE_LOG("EnsureAudioDecodeTaskQueued isDecoding=%d status=%d",
IsAudioDecoding(), mAudioRequestStatus);
if (mState >= DECODER_STATE_COMPLETED || mState == DECODER_STATE_DORMANT) {
if (mState >= DECODER_STATE_COMPLETED) {
return NS_OK;
}
@ -2012,7 +2012,7 @@ MediaDecoderStateMachine::EnsureVideoDecodeTaskQueued()
NS_ASSERTION(OnStateMachineThread() || OnDecodeThread(),
"Should be on state machine or decode thread.");
if (mState >= DECODER_STATE_COMPLETED || mState == DECODER_STATE_DORMANT) {
if (mState >= DECODER_STATE_COMPLETED) {
return NS_OK;
}
@ -2179,28 +2179,28 @@ nsresult MediaDecoderStateMachine::DecodeMetadata()
MOZ_ASSERT(mState == DECODER_STATE_DECODING_METADATA);
DECODER_LOG("Decoding Media Headers");
nsresult res;
MediaInfo info;
bool isAwaitingResources = false;
{
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
mReader->PreReadMetadata();
mReader->PreReadMetadata();
if (mReader->IsWaitingMediaResources()) {
StartWaitForResources();
return NS_OK;
}
res = mReader->ReadMetadata(&info, getter_Transfers(mMetadataTags));
isAwaitingResources = mReader->IsWaitingMediaResources();
if (mReader->IsWaitingMediaResources()) {
StartWaitForResources();
return NS_OK;
}
if (NS_SUCCEEDED(res) &&
mState == DECODER_STATE_DECODING_METADATA &&
isAwaitingResources) {
// change state to DECODER_STATE_WAIT_FOR_RESOURCES
StartWaitForResources();
// affect values only if ReadMetadata succeeds
return NS_OK;
nsresult res;
MediaInfo info;
{
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
res = mReader->ReadMetadata(&info, getter_Transfers(mMetadataTags));
}
if (NS_SUCCEEDED(res)) {
if (mState == DECODER_STATE_DECODING_METADATA &&
mReader->IsWaitingMediaResources()) {
// change state to DECODER_STATE_WAIT_FOR_RESOURCES
StartWaitForResources();
// affect values only if ReadMetadata succeeds
return NS_OK;
}
}
if (NS_SUCCEEDED(res)) {
@ -2766,10 +2766,12 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
// Now that those threads are stopped, there's no possibility of
// mPendingWakeDecoder being needed again. Revoke it.
mPendingWakeDecoder = nullptr;
DebugOnly<nsresult> rv = DecodeTaskQueue()->Dispatch(
NS_NewRunnableMethod(mReader, &MediaDecoderReader::ReleaseMediaResources));
MOZ_ASSERT(NS_SUCCEEDED(rv));
{
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
// Wait for the thread decoding, if any, to exit.
DecodeTaskQueue()->AwaitIdle();
mReader->ReleaseMediaResources();
}
return NS_OK;
}

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

@ -117,9 +117,6 @@ MP4Reader::MP4Reader(AbstractMediaDecoder* aDecoder)
, mIsEncrypted(false)
, mIndexReady(false)
, mDemuxerMonitor("MP4 Demuxer")
#if defined(XP_WIN)
, mDormantEnabled(Preferences::GetBool("media.decoder.heuristic.dormant.enabled", false))
#endif
{
MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
MOZ_COUNT_CTOR(MP4Reader);
@ -255,15 +252,15 @@ private:
#endif
void MP4Reader::RequestCodecResource() {
#if defined(MOZ_GONK_MEDIACODEC) || defined(XP_WIN)
if (mVideo.mDecoder) {
#ifdef MOZ_GONK_MEDIACODEC
if(mVideo.mDecoder) {
mVideo.mDecoder->AllocateMediaResources();
}
#endif
}
bool MP4Reader::IsWaitingOnCodecResource() {
#if defined(MOZ_GONK_MEDIACODEC) || defined(XP_WIN)
#ifdef MOZ_GONK_MEDIACODEC
return mVideo.mDecoder && mVideo.mDecoder->IsWaitingMediaResources();
#endif
return false;
@ -449,8 +446,7 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
mVideo.mCallback = new DecoderCallback(this, kVideo);
if (mSharedDecoderManager) {
mVideo.mDecoder =
mSharedDecoderManager->CreateVideoDecoder(mPlatform,
video,
mSharedDecoderManager->CreateVideoDecoder(video,
mLayersBackendType,
mDecoder->GetImageContainer(),
mVideo.mTaskQueue,
@ -1005,20 +1001,15 @@ MP4Reader::GetBuffered(dom::TimeRanges* aBuffered)
bool MP4Reader::IsDormantNeeded()
{
#if defined(MOZ_GONK_MEDIACODEC) || defined(XP_WIN)
return
#if defined(XP_WIN)
mDormantEnabled &&
#endif
mVideo.mDecoder &&
mVideo.mDecoder->IsDormantNeeded();
#ifdef MOZ_GONK_MEDIACODEC
return mVideo.mDecoder && mVideo.mDecoder->IsDormantNeeded();
#endif
return false;
}
void MP4Reader::ReleaseMediaResources()
{
#if defined(MOZ_GONK_MEDIACODEC) || defined(XP_WIN)
#ifdef MOZ_GONK_MEDIACODEC
// Before freeing a video codec, all video buffers needed to be released
// even from graphics pipeline.
VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
@ -1033,7 +1024,7 @@ void MP4Reader::ReleaseMediaResources()
void MP4Reader::NotifyResourcesStatusChanged()
{
#if defined(MOZ_GONK_MEDIACODEC) || defined(XP_WIN)
#ifdef MOZ_GONK_MEDIACODEC
if (mDecoder) {
mDecoder->NotifyWaitingForResourcesStatusChanged();
}
@ -1052,7 +1043,7 @@ MP4Reader::SetIdle()
void
MP4Reader::SetSharedDecoderManager(SharedDecoderManager* aManager)
{
#if defined(MOZ_GONK_MEDIACODEC) || defined(XP_WIN)
#ifdef MOZ_GONK_MEDIACODEC
mSharedDecoderManager = aManager;
#endif
}

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

@ -267,10 +267,6 @@ private:
bool mIndexReady;
Monitor mDemuxerMonitor;
nsRefPtr<SharedDecoderManager> mSharedDecoderManager;
#if defined(XP_WIN)
const bool mDormantEnabled;
#endif
};
} // namespace mozilla

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

@ -55,14 +55,11 @@ public:
};
SharedDecoderManager::SharedDecoderManager()
: mTaskQueue(new MediaTaskQueue(GetMediaDecodeThreadPool()))
, mActiveProxy(nullptr)
: mActiveProxy(nullptr)
, mActiveCallback(nullptr)
, mWaitForInternalDrain(false)
, mMonitor("SharedDecoderProxy")
, mDecoderReleasedResources(false)
{
MOZ_ASSERT(NS_IsMainThread()); // taskqueue must be created on main thread.
mCallback = new SharedDecoderCallback(this);
}
@ -70,18 +67,14 @@ SharedDecoderManager::~SharedDecoderManager() {}
already_AddRefed<MediaDataDecoder>
SharedDecoderManager::CreateVideoDecoder(
PlatformDecoderModule* aPDM,
const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend, layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue, MediaDataDecoderCallback* aCallback)
{
if (!mDecoder) {
// We use the manager's task queue for the decoder, rather than the one
// passed in, so that none of the objects sharing the decoder can shutdown
// the task queue while we're potentially still using it for a *different*
// object also sharing the decoder.
mDecoder = aPDM->CreateVideoDecoder(
aConfig, aLayersBackend, aImageContainer, mTaskQueue, mCallback);
nsRefPtr<PlatformDecoderModule> platform(PlatformDecoderModule::Create());
mDecoder = platform->CreateVideoDecoder(
aConfig, aLayersBackend, aImageContainer, aVideoTaskQueue, mCallback);
if (!mDecoder) {
return nullptr;
}
@ -103,11 +96,6 @@ SharedDecoderManager::Select(SharedDecoderProxy* aProxy)
mActiveProxy = aProxy;
mActiveCallback = aProxy->mCallback;
if (mDecoderReleasedResources) {
mDecoder->AllocateMediaResources();
mDecoderReleasedResources = false;
}
}
void
@ -137,28 +125,6 @@ SharedDecoderManager::DrainComplete()
}
}
void
SharedDecoderManager::ReleaseMediaResources()
{
mDecoderReleasedResources = true;
mDecoder->ReleaseMediaResources();
mActiveProxy = nullptr;
}
void
SharedDecoderManager::Shutdown()
{
if (mDecoder) {
mDecoder->Shutdown();
mDecoder = nullptr;
}
if (mTaskQueue) {
mTaskQueue->BeginShutdown();
mTaskQueue->AwaitShutdownAndIdle();
mTaskQueue = nullptr;
}
}
SharedDecoderProxy::SharedDecoderProxy(
SharedDecoderManager* aManager, MediaDataDecoderCallback* aCallback)
: mManager(aManager), mCallback(aCallback)
@ -180,6 +146,7 @@ SharedDecoderProxy::Input(mp4_demuxer::MP4Sample* aSample)
mManager->Select(this);
}
return mManager->mDecoder->Input(aSample);
return NS_OK;
}
nsresult
@ -226,7 +193,7 @@ void
SharedDecoderProxy::ReleaseMediaResources()
{
if (mManager->mActiveProxy == this) {
mManager->ReleaseMediaResources();
mManager->mDecoder->ReleaseMediaResources();
}
}

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

@ -25,7 +25,6 @@ public:
SharedDecoderManager();
already_AddRefed<MediaDataDecoder> CreateVideoDecoder(
PlatformDecoderModule* aPDM,
const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer, MediaTaskQueue* aVideoTaskQueue,
@ -34,8 +33,6 @@ public:
void SetReader(MediaDecoderReader* aReader);
void Select(SharedDecoderProxy* aProxy);
void SetIdle(MediaDataDecoder* aProxy);
void ReleaseMediaResources();
void Shutdown();
friend class SharedDecoderProxy;
friend class SharedDecoderCallback;
@ -45,13 +42,11 @@ private:
void DrainComplete();
nsRefPtr<MediaDataDecoder> mDecoder;
nsRefPtr<MediaTaskQueue> mTaskQueue;
SharedDecoderProxy* mActiveProxy;
MediaDataDecoderCallback* mActiveCallback;
nsAutoPtr<MediaDataDecoderCallback> mCallback;
bool mWaitForInternalDrain;
Monitor mMonitor;
bool mDecoderReleasedResources;
};
class SharedDecoderProxy : public MediaDataDecoder

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

@ -48,13 +48,7 @@ WMFMediaDataDecoder::Init()
nsresult
WMFMediaDataDecoder::Shutdown()
{
DebugOnly<nsresult> rv = mTaskQueue->FlushAndDispatch(
NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessShutdown));
#ifdef DEBUG
if (NS_FAILED(rv)) {
NS_WARNING("WMFMediaDataDecoder::Shutdown() dispatch of task failed!");
}
#endif
mTaskQueue->FlushAndDispatch(NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessShutdown));
return NS_OK;
}
@ -66,13 +60,6 @@ WMFMediaDataDecoder::ProcessShutdown()
mDecoder = nullptr;
}
void
WMFMediaDataDecoder::ProcessReleaseDecoder()
{
mMFTManager->Shutdown();
mDecoder = nullptr;
}
// Inserts data into the decoder's pipeline.
nsresult
WMFMediaDataDecoder::Input(mp4_demuxer::MP4Sample* aSample)
@ -155,28 +142,4 @@ WMFMediaDataDecoder::Drain()
return NS_OK;
}
void
WMFMediaDataDecoder::AllocateMediaResources()
{
mDecoder = mMFTManager->Init();
}
void
WMFMediaDataDecoder::ReleaseMediaResources()
{
DebugOnly<nsresult> rv = mTaskQueue->FlushAndDispatch(
NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessReleaseDecoder));
#ifdef DEBUG
if (NS_FAILED(rv)) {
NS_WARNING("WMFMediaDataDecoder::ReleaseMediaResources() dispatch of task failed!");
}
#endif
}
void
WMFMediaDataDecoder::ReleaseDecoder()
{
ReleaseMediaResources();
}
} // namespace mozilla

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

@ -70,12 +70,6 @@ public:
virtual nsresult Shutdown() MOZ_OVERRIDE;
virtual bool IsWaitingMediaResources() { return false; };
virtual bool IsDormantNeeded() { return true; };
virtual void AllocateMediaResources() MOZ_OVERRIDE;
virtual void ReleaseMediaResources() MOZ_OVERRIDE;
virtual void ReleaseDecoder() MOZ_OVERRIDE;
private:
// Called on the task queue. Inserts the sample into the decoder, and
@ -91,7 +85,6 @@ private:
void ProcessDrain();
void ProcessShutdown();
void ProcessReleaseDecoder();
RefPtr<MediaTaskQueue> mTaskQueue;
MediaDataDecoderCallback* mCallback;

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

@ -100,9 +100,7 @@ WMFVideoMFTManager::~WMFVideoMFTManager()
{
MOZ_COUNT_DTOR(WMFVideoMFTManager);
// Ensure DXVA/D3D9 related objects are released on the main thread.
if (mDXVA2Manager) {
DeleteOnMainThread(mDXVA2Manager);
}
DeleteOnMainThread(mDXVA2Manager);
}
const GUID&
@ -142,8 +140,6 @@ public:
bool
WMFVideoMFTManager::InitializeDXVA()
{
MOZ_ASSERT(!mDXVA2Manager);
// If we use DXVA but aren't running with a D3D layer manager then the
// readback of decoded video frames from GPU to CPU memory grinds painting
// to a halt, and makes playback performance *worse*.
@ -491,7 +487,6 @@ void
WMFVideoMFTManager::Shutdown()
{
mDecoder = nullptr;
DeleteOnMainThread(mDXVA2Manager);
}
} // namespace mozilla

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

@ -411,11 +411,6 @@ MediaSourceReader::ContinueShutdown()
mVideoTrack = nullptr;
mVideoReader = nullptr;
if (mSharedDecoderManager) {
mSharedDecoderManager->Shutdown();
mSharedDecoderManager = nullptr;
}
MOZ_ASSERT(mAudioPromise.IsEmpty());
MOZ_ASSERT(mVideoPromise.IsEmpty());

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

@ -262,11 +262,6 @@ pref("media.wakelock_timeout", 2000);
// opened as top-level documents, as opposed to inside a media element.
pref("media.play-stand-alone", true);
#if defined(XP_WIN)
pref("media.decoder.heuristic.dormant.enabled", true);
pref("media.decoder.heuristic.dormant.timeout", 60000);
#endif
#ifdef MOZ_WMF
pref("media.windows-media-foundation.enabled", true);
pref("media.windows-media-foundation.use-dxva", true);

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

@ -284,10 +284,6 @@ user_pref("browser.search.countryCode", "US");
user_pref("media.eme.enabled", true);
#if defined(XP_WIN)
user_pref("media.decoder.heuristic.dormant.timeout", 0);
#endif
// Don't prompt about e10s
user_pref("browser.displayedE10SPrompt.1", 5);
// Don't use auto-enabled e10s