Bug 1299105 - Part2 - Make Part1 works behind a pref.
MozReview-Commit-ID: AcEFAGP8kuR
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1301,17 +1301,18 @@ MediaFormatReader::HandleDemuxedSamples(
RefPtr<SharedTrackInfo> info = sample->mTrackInfo;
if (info && decoder.mLastStreamSourceID != info->GetID()) {
if (samplesPending) {
// Let existing samples complete their decoding. We'll resume later.
return;
}
- bool supportRecycling = decoder.mDecoder->SupportDecoderRecycling();
+ bool supportRecycling = MediaPrefs::MediaDecoderCheckRecycling() &&
+ decoder.mDecoder->SupportDecoderRecycling();
if (decoder.mNextStreamSourceID.isNothing() ||
decoder.mNextStreamSourceID.ref() != info->GetID()) {
if (!supportRecycling) {
LOG("%s stream id has changed from:%d to:%d, draining decoder.",
TrackTypeToStr(aTrack), decoder.mLastStreamSourceID,
info->GetID());
decoder.mNeedDraining = true;
decoder.mNextStreamSourceID = Some(info->GetID());
--- a/dom/media/MediaPrefs.h
+++ b/dom/media/MediaPrefs.h
@@ -125,16 +125,17 @@ private:
DECL_MEDIA_PREF("media.wmf.skip-blacklist", PDMWMFSkipBlacklist, bool, false);
DECL_MEDIA_PREF("media.decoder-doctor.wmf-disabled-is-failure", DecoderDoctorWMFDisabledIsFailure, bool, false);
DECL_MEDIA_PREF("media.wmf.vp9.enabled", PDMWMFVP9DecoderEnabled, bool, true);
DECL_MEDIA_PREF("media.wmf.decoder.thread-count", PDMWMFThreadCount, int32_t, -1);
#endif
DECL_MEDIA_PREF("media.decoder.fuzzing.enabled", PDMFuzzingEnabled, bool, false);
DECL_MEDIA_PREF("media.decoder.fuzzing.video-output-minimum-interval-ms", PDMFuzzingInterval, uint32_t, 0);
DECL_MEDIA_PREF("media.decoder.fuzzing.dont-delay-inputexhausted", PDMFuzzingDelayInputExhausted, bool, true);
+ DECL_MEDIA_PREF("media.decoder.recycle.enabled", MediaDecoderCheckRecycling, bool, false);
DECL_MEDIA_PREF("media.gmp.decoder.enabled", PDMGMPEnabled, bool, true);
DECL_MEDIA_PREF("media.gmp.decoder.aac", GMPAACPreferred, uint32_t, 0);
DECL_MEDIA_PREF("media.gmp.decoder.h264", GMPH264Preferred, uint32_t, 0);
// MediaDecoderStateMachine
DECL_MEDIA_PREF("media.suspend-bkgnd-video.enabled", MDSMSuspendBackgroundVideoEnabled, bool, false);
DECL_MEDIA_PREF("media.suspend-bkgnd-video.delay-ms", MDSMSuspendBackgroundVideoDelay, AtomicUint32, SUSPEND_BACKGROUND_VIDEO_DELAY_MS);
DECL_MEDIA_PREF("media.dormant-on-pause-timeout-ms", DormantOnPauseTimeout, int32_t, 5000);
--- a/dom/media/platforms/wrappers/H264Converter.cpp
+++ b/dom/media/platforms/wrappers/H264Converter.cpp
@@ -4,16 +4,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/TaskQueue.h"
#include "H264Converter.h"
#include "ImageContainer.h"
#include "MediaInfo.h"
+#include "MediaPrefs.h"
#include "mp4_demuxer/AnnexB.h"
#include "mp4_demuxer/H264.h"
namespace mozilla
{
H264Converter::H264Converter(PlatformDecoderModule* aPDM,
const CreateDecoderParams& aParams)
@@ -281,17 +282,18 @@ H264Converter::CheckForSPSChange(MediaRa
RefPtr<MediaByteBuffer> extra_data =
mp4_demuxer::AnnexB::ExtractExtraData(aSample);
if (!mp4_demuxer::AnnexB::HasSPS(extra_data) ||
mp4_demuxer::AnnexB::CompareExtraData(extra_data,
mCurrentConfig.mExtraData)) {
return NS_OK;
}
- if (mDecoder->SupportDecoderRecycling()) {
+ if (MediaPrefs::MediaDecoderCheckRecycling() &&
+ mDecoder->SupportDecoderRecycling()) {
// Do not recreate the decoder, reuse it.
UpdateConfigFromExtraData(extra_data);
mNeedKeyframe = true;
return NS_OK;
}
// The SPS has changed, signal to flush the current decoder and create a
// new one.
mDecoder->Flush();
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -602,16 +602,19 @@ pref("media.video-queue.default-size", 1
// The maximum number of queued frames to send to the compositor.
// By default, send all of them.
pref("media.video-queue.send-to-compositor-size", 9999);
// Whether to disable the video stats to prevent fingerprinting
pref("media.video_stats.enabled", true);
+// Whether to check the decoder supports recycling.
+pref("media.decoder.recycle.enabled", false);
+
// Weather we allow AMD switchable graphics
pref("layers.amd-switchable-gfx.enabled", true);
// Whether to use async panning and zooming
pref("layers.async-pan-zoom.enabled", true);
// Whether to enable event region building during painting
pref("layout.event-regions.enabled", false);