From f34df9db04b7adaff418b61c35fb1346c1c2fccd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 04:29:21 +0200 Subject: Adding upstream version 115.9.0esr. Signed-off-by: Daniel Baumann --- .../platforms/wrappers/MediaChangeMonitor.cpp | 27 ++++++++++++++++++---- dom/media/platforms/wrappers/MediaChangeMonitor.h | 2 ++ 2 files changed, 24 insertions(+), 5 deletions(-) (limited to 'dom/media/platforms') diff --git a/dom/media/platforms/wrappers/MediaChangeMonitor.cpp b/dom/media/platforms/wrappers/MediaChangeMonitor.cpp index 17387204ed..544abea161 100644 --- a/dom/media/platforms/wrappers/MediaChangeMonitor.cpp +++ b/dom/media/platforms/wrappers/MediaChangeMonitor.cpp @@ -519,6 +519,10 @@ RefPtr MediaChangeMonitor::Init() { mDecoderInitialized = true; mConversionRequired = Some(mDecoder->NeedsConversion()); mCanRecycleDecoder = Some(CanRecycleDecoder()); + if (mPendingSeekThreshold) { + mDecoder->SetSeekThreshold(*mPendingSeekThreshold); + mPendingSeekThreshold.reset(); + } } return mInitPromise.ResolveOrRejectIfExists(std::move(aValue), __func__); @@ -686,11 +690,19 @@ bool MediaChangeMonitor::IsHardwareAccelerated( } void MediaChangeMonitor::SetSeekThreshold(const media::TimeUnit& aTime) { - if (mDecoder) { - mDecoder->SetSeekThreshold(aTime); - } else { - MediaDataDecoder::SetSeekThreshold(aTime); - } + GetCurrentSerialEventTarget()->Dispatch(NS_NewRunnableFunction( + "MediaChangeMonitor::SetSeekThreshold", + [self = RefPtr(this), time = aTime, this] { + // During the shutdown. + if (mShutdownPromise) { + return; + } + if (mDecoder && mDecoderInitialized) { + mDecoder->SetSeekThreshold(time); + } else { + mPendingSeekThreshold = Some(time); + } + })); } RefPtr @@ -744,6 +756,11 @@ MediaResult MediaChangeMonitor::CreateDecoderAndInit(MediaRawData* aSample) { mConversionRequired = Some(mDecoder->NeedsConversion()); mCanRecycleDecoder = Some(CanRecycleDecoder()); + if (mPendingSeekThreshold) { + mDecoder->SetSeekThreshold(*mPendingSeekThreshold); + mPendingSeekThreshold.reset(); + } + if (!mFlushPromise.IsEmpty()) { // A Flush is pending, abort the current operation. mFlushPromise.Resolve(true, __func__); diff --git a/dom/media/platforms/wrappers/MediaChangeMonitor.h b/dom/media/platforms/wrappers/MediaChangeMonitor.h index a85c23fcb2..843dd9035b 100644 --- a/dom/media/platforms/wrappers/MediaChangeMonitor.h +++ b/dom/media/platforms/wrappers/MediaChangeMonitor.h @@ -135,6 +135,8 @@ class MediaChangeMonitor final Maybe mConversionRequired; bool mDecoderInitialized = false; const CreateDecoderParamsForAsync mParams; + // Keep any seek threshold set for after decoder creation and initialization. + Maybe mPendingSeekThreshold; }; } // namespace mozilla -- cgit v1.2.3