Bug 1196417 - Make video software fallback only affect the current video instead of the entire browser. r=cpearce

This commit is contained in:
Matt Woodrow 2015-08-20 11:43:36 -04:00
Родитель e2765944f2
Коммит ec61d0727e
9 изменённых файлов: 15 добавлений и 38 удалений

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

@ -218,7 +218,6 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
mCurrentTimeBeforeSeek(0),
mCorruptFrames(30),
mDecodingFirstFrame(true),
mDisabledHardwareAcceleration(false),
mSentLoadedMetadataEvent(false),
mSentFirstFrameLoadedEvent(false),
mSentPlaybackEndedEvent(false),
@ -2482,14 +2481,13 @@ bool MediaDecoderStateMachine::CheckFrameValidity(VideoData* aData)
// hardware acceleration. We use 10 as the corrupt value because RollingMean<>
// only supports integer types.
mCorruptFrames.insert(10);
if (!mDisabledHardwareAcceleration &&
mReader->VideoIsHardwareAccelerated() &&
if (mReader->VideoIsHardwareAccelerated() &&
frameStats.GetPresentedFrames() > 30 &&
mCorruptFrames.mean() >= 1 /* 10% */) {
nsCOMPtr<nsIRunnable> task =
NS_NewRunnableMethod(mReader, &MediaDecoderReader::DisableHardwareAcceleration);
DecodeTaskQueue()->Dispatch(task.forget());
mDisabledHardwareAcceleration = true;
mCorruptFrames.clear();
gfxCriticalNote << "Too many dropped/corrupted frames, disabling DXVA";
}
return false;

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

@ -1271,8 +1271,6 @@ private:
// successeeding.
bool mDecodingFirstFrame;
bool mDisabledHardwareAcceleration;
// True if we are back from DECODER_STATE_DORMANT state and
// LoadedMetadataEvent was already sent.
bool mSentLoadedMetadataEvent;

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

@ -73,6 +73,7 @@ MediaFormatReader::MediaFormatReader(AbstractMediaDecoder* aDecoder,
, mSeekable(false)
, mIsEncrypted(false)
, mTrackDemuxersMayBlock(false)
, mHardwareAccelerationDisabled(false)
{
MOZ_ASSERT(aDemuxer);
MOZ_COUNT_CTOR(MediaFormatReader);
@ -467,8 +468,11 @@ MediaFormatReader::EnsureDecodersCreated()
false);
mVideo.mDecoderInitialized = false;
// If we've disabled hardware acceleration for this reader, then we can't use
// the shared decoder.
if (mSharedDecoderManager &&
mPlatform->SupportsSharedDecoders(mInfo.mVideo)) {
mPlatform->SupportsSharedDecoders(mInfo.mVideo) &&
!mHardwareAccelerationDisabled) {
mVideo.mDecoder =
mSharedDecoderManager->CreateVideoDecoder(mPlatform,
mVideo.mInfo ?
@ -479,12 +483,15 @@ MediaFormatReader::EnsureDecodersCreated()
mVideo.mTaskQueue,
mVideo.mCallback);
} else {
// Decoders use the layers backend to decide if they can use hardware decoding,
// so specify LAYERS_NONE if we want to forcibly disable it.
mVideo.mDecoder =
mPlatform->CreateDecoder(mVideo.mInfo ?
*mVideo.mInfo->GetAsVideoInfo() :
mInfo.mVideo,
mVideo.mTaskQueue,
mVideo.mCallback,
mHardwareAccelerationDisabled ? LayersBackend::LAYERS_NONE :
mLayersBackendType,
mDecoder->GetImageContainer());
}
@ -590,8 +597,8 @@ void
MediaFormatReader::DisableHardwareAcceleration()
{
MOZ_ASSERT(OnTaskQueue());
if (HasVideo()) {
mPlatform->DisableHardwareAcceleration();
if (HasVideo() && !mHardwareAccelerationDisabled) {
mHardwareAccelerationDisabled = true;
Flush(TrackInfo::kVideoTrack);
mVideo.mDecoder->Shutdown();
mVideo.mDecoder = nullptr;

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

@ -399,6 +399,8 @@ private:
// Set to true if any of our track buffers may be blocking.
bool mTrackDemuxersMayBlock;
bool mHardwareAccelerationDisabled;
// Seeking objects.
bool IsSeeking() const { return mPendingSeekTime.isSome(); }
void AttemptSeek();

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

@ -110,8 +110,6 @@ public:
// feeding it to MediaDataDecoder::Input.
virtual ConversionRequired DecoderNeedsConversion(const TrackInfo& aConfig) const = 0;
virtual void DisableHardwareAcceleration() {}
virtual bool SupportsSharedDecoders(const VideoInfo& aConfig) const {
return !AgnosticMimeType(aConfig.mMimeType);
}

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

@ -120,13 +120,6 @@ SharedDecoderManager::CreateVideoDecoder(
return proxy.forget();
}
void
SharedDecoderManager::DisableHardwareAcceleration()
{
MOZ_ASSERT(mPDM);
mPDM->DisableHardwareAcceleration();
}
bool
SharedDecoderManager::Recreate(const VideoInfo& aConfig)
{

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

@ -41,7 +41,6 @@ public:
friend class SharedDecoderProxy;
friend class SharedDecoderCallback;
void DisableHardwareAcceleration();
bool Recreate(const VideoInfo& aConfig);
private:

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

@ -41,13 +41,6 @@ WMFDecoderModule::~WMFDecoderModule()
}
}
void
WMFDecoderModule::DisableHardwareAcceleration()
{
sDXVAEnabled = false;
sIsIntelDecoderEnabled = false;
}
static void
SetNumOfDecoderThreads()
{
@ -133,14 +126,6 @@ WMFDecoderModule::CreateAudioDecoder(const AudioInfo& aConfig,
return decoder.forget();
}
bool
WMFDecoderModule::SupportsSharedDecoders(const VideoInfo& aConfig) const
{
// If DXVA is enabled, but we're not going to use it for this specific config, then
// we can't use the shared decoder.
return !AgnosticMimeType(aConfig.mMimeType);
}
bool
WMFDecoderModule::SupportsMimeType(const nsACString& aMimeType)
{

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

@ -33,9 +33,6 @@ public:
bool SupportsMimeType(const nsACString& aMimeType) override;
virtual void DisableHardwareAcceleration() override;
virtual bool SupportsSharedDecoders(const VideoInfo& aConfig) const override;
virtual ConversionRequired
DecoderNeedsConversion(const TrackInfo& aConfig) const override;