mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 1685358 - Apply seek threshold after decoder creation. r=media-playback-reviewers,padenot, a=dsmith
Differential Revision: https://phabricator.services.mozilla.com/D201297
This commit is contained in:
parent
25ed1ebadf
commit
88a214c21b
@ -519,6 +519,10 @@ RefPtr<MediaDataDecoder::InitPromise> 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<MediaChangeMonitor>(this), time = aTime, this] {
|
||||
// During the shutdown.
|
||||
if (mShutdownPromise) {
|
||||
return;
|
||||
}
|
||||
if (mDecoder && mDecoderInitialized) {
|
||||
mDecoder->SetSeekThreshold(time);
|
||||
} else {
|
||||
mPendingSeekThreshold = Some(time);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
RefPtr<MediaChangeMonitor::CreateDecoderPromise>
|
||||
@ -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__);
|
||||
|
@ -135,6 +135,8 @@ class MediaChangeMonitor final
|
||||
Maybe<MediaDataDecoder::ConversionRequired> mConversionRequired;
|
||||
bool mDecoderInitialized = false;
|
||||
const CreateDecoderParamsForAsync mParams;
|
||||
// Keep any seek threshold set for after decoder creation and initialization.
|
||||
Maybe<media::TimeUnit> mPendingSeekThreshold;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
Loading…
Reference in New Issue
Block a user