зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1504643 - Enforce template-parameter classes restrictions in MozPromise. r=gerald
Make thorough use of move semantic for MozPromise using nsTArray Differential Revision: https://phabricator.services.mozilla.com/D11346 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
82ff6f280d
Коммит
c30e8ca9f0
|
@ -335,7 +335,7 @@ BenchmarkPlayback::GlobalShutdown()
|
|||
}
|
||||
|
||||
void
|
||||
BenchmarkPlayback::Output(const MediaDataDecoder::DecodedData& aResults)
|
||||
BenchmarkPlayback::Output(MediaDataDecoder::DecodedData&& aResults)
|
||||
{
|
||||
MOZ_ASSERT(OnThread());
|
||||
MOZ_ASSERT(!mFinished);
|
||||
|
@ -391,14 +391,14 @@ BenchmarkPlayback::InputExhausted()
|
|||
if (mSampleIndex == mSamples.Length() && !ref->mParameters.mStopAtFrame) {
|
||||
// Complete current frame decode then drain if still necessary.
|
||||
p->Then(Thread(), __func__,
|
||||
[ref, this](const MediaDataDecoder::DecodedData& aResults) {
|
||||
Output(aResults);
|
||||
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
|
||||
Output(std::move(aResults));
|
||||
if (!mFinished) {
|
||||
mDecoder->Drain()->Then(
|
||||
Thread(), __func__,
|
||||
[ref, this](const MediaDataDecoder::DecodedData& aResults) {
|
||||
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
|
||||
mDrained = true;
|
||||
Output(aResults);
|
||||
Output(std::move(aResults));
|
||||
MOZ_ASSERT(mFinished, "We must be done now");
|
||||
},
|
||||
[ref, this](const MediaResult& aError) { Error(aError); });
|
||||
|
@ -411,8 +411,8 @@ BenchmarkPlayback::InputExhausted()
|
|||
}
|
||||
// Continue decoding
|
||||
p->Then(Thread(), __func__,
|
||||
[ref, this](const MediaDataDecoder::DecodedData& aResults) {
|
||||
Output(aResults);
|
||||
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
|
||||
Output(std::move(aResults));
|
||||
if (!mFinished) {
|
||||
InputExhausted();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class BenchmarkPlayback : public QueueObject
|
|||
void GlobalShutdown();
|
||||
void InitDecoder(TrackInfo&& aInfo);
|
||||
|
||||
void Output(const MediaDataDecoder::DecodedData& aResults);
|
||||
void Output(MediaDataDecoder::DecodedData&& aResults);
|
||||
void Error(const MediaResult& aError);
|
||||
void InputExhausted();
|
||||
|
||||
|
|
|
@ -1845,7 +1845,7 @@ MediaFormatReader::OnAudioDemuxCompleted(
|
|||
|
||||
void
|
||||
MediaFormatReader::NotifyNewOutput(
|
||||
TrackType aTrack, const MediaDataDecoder::DecodedData& aResults)
|
||||
TrackType aTrack, MediaDataDecoder::DecodedData&& aResults)
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
auto& decoder = GetDecoderData(aTrack);
|
||||
|
@ -1854,7 +1854,7 @@ MediaFormatReader::NotifyNewOutput(
|
|||
aTrack == TrackInfo::kAudioTrack ? "decoded_audio" : "decoded_video",
|
||||
"no output samples");
|
||||
} else
|
||||
for (auto& sample : aResults) {
|
||||
for (auto&& sample : aResults) {
|
||||
if (DecoderDoctorLogger::IsDDLoggingEnabled()) {
|
||||
switch (sample->mType) {
|
||||
case MediaData::AUDIO_DATA:
|
||||
|
@ -2180,9 +2180,9 @@ MediaFormatReader::DecodeDemuxedSamples(TrackType aTrack,
|
|||
decoder.mDecoder->Decode(aSample)
|
||||
->Then(mTaskQueue, __func__,
|
||||
[self, aTrack, &decoder]
|
||||
(const MediaDataDecoder::DecodedData& aResults) {
|
||||
(MediaDataDecoder::DecodedData&& aResults) {
|
||||
decoder.mDecodeRequest.Complete();
|
||||
self->NotifyNewOutput(aTrack, aResults);
|
||||
self->NotifyNewOutput(aTrack, std::move(aResults));
|
||||
|
||||
// When we recovered from a GPU crash and get the first decoded
|
||||
// frame, report the recovery time telemetry.
|
||||
|
@ -2395,13 +2395,13 @@ MediaFormatReader::DrainDecoder(TrackType aTrack)
|
|||
decoder.mDecoder->Drain()
|
||||
->Then(mTaskQueue, __func__,
|
||||
[self, aTrack, &decoder]
|
||||
(const MediaDataDecoder::DecodedData& aResults) {
|
||||
(MediaDataDecoder::DecodedData&& aResults) {
|
||||
decoder.mDrainRequest.Complete();
|
||||
DDLOGEX(self.get(), DDLogCategory::Log, "drained", DDNoValue{});
|
||||
if (aResults.IsEmpty()) {
|
||||
decoder.mDrainState = DrainState::DrainCompleted;
|
||||
} else {
|
||||
self->NotifyNewOutput(aTrack, aResults);
|
||||
self->NotifyNewOutput(aTrack, std::move(aResults));
|
||||
// Let's see if we have any more data available to drain.
|
||||
decoder.mDrainState = DrainState::PartialDrainPending;
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ private:
|
|||
// Drain the current decoder.
|
||||
void DrainDecoder(TrackType aTrack);
|
||||
void NotifyNewOutput(TrackType aTrack,
|
||||
const MediaDataDecoder::DecodedData& aResults);
|
||||
MediaDataDecoder::DecodedData&& aResults);
|
||||
void NotifyError(TrackType aTrack, const MediaResult& aError);
|
||||
void NotifyWaitingForData(TrackType aTrack);
|
||||
void NotifyWaitingForKey(TrackType aTrack);
|
||||
|
|
|
@ -119,8 +119,8 @@ mozilla::ipc::IPCResult
|
|||
RemoteVideoDecoderChild::RecvInputExhausted()
|
||||
{
|
||||
AssertOnManagerThread();
|
||||
mDecodePromise.ResolveIfExists(mDecodedData, __func__);
|
||||
mDecodedData.Clear();
|
||||
mDecodePromise.ResolveIfExists(std::move(mDecodedData), __func__);
|
||||
mDecodedData = MediaDataDecoder::DecodedData();
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -128,8 +128,8 @@ mozilla::ipc::IPCResult
|
|||
RemoteVideoDecoderChild::RecvDrainComplete()
|
||||
{
|
||||
AssertOnManagerThread();
|
||||
mDrainPromise.ResolveIfExists(mDecodedData, __func__);
|
||||
mDecodedData.Clear();
|
||||
mDecodePromise.ResolveIfExists(std::move(mDecodedData), __func__);
|
||||
mDecodedData = MediaDataDecoder::DecodedData();
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ mozilla::ipc::IPCResult
|
|||
RemoteVideoDecoderChild::RecvError(const nsresult& aError)
|
||||
{
|
||||
AssertOnManagerThread();
|
||||
mDecodedData.Clear();
|
||||
mDecodedData = MediaDataDecoder::DecodedData();
|
||||
mDecodePromise.RejectIfExists(aError, __func__);
|
||||
mDrainPromise.RejectIfExists(aError, __func__);
|
||||
mFlushPromise.RejectIfExists(aError, __func__);
|
||||
|
|
|
@ -81,8 +81,8 @@ mozilla::ipc::IPCResult
|
|||
VideoDecoderChild::RecvInputExhausted()
|
||||
{
|
||||
AssertOnManagerThread();
|
||||
mDecodePromise.ResolveIfExists(mDecodedData, __func__);
|
||||
mDecodedData.Clear();
|
||||
mDecodePromise.ResolveIfExists(std::move(mDecodedData), __func__);
|
||||
mDecodedData = MediaDataDecoder::DecodedData();
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -90,8 +90,8 @@ mozilla::ipc::IPCResult
|
|||
VideoDecoderChild::RecvDrainComplete()
|
||||
{
|
||||
AssertOnManagerThread();
|
||||
mDrainPromise.ResolveIfExists(mDecodedData, __func__);
|
||||
mDecodedData.Clear();
|
||||
mDrainPromise.ResolveIfExists(std::move(mDecodedData), __func__);
|
||||
mDecodedData = MediaDataDecoder::DecodedData();
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ mozilla::ipc::IPCResult
|
|||
VideoDecoderChild::RecvError(const nsresult& aError)
|
||||
{
|
||||
AssertOnManagerThread();
|
||||
mDecodedData.Clear();
|
||||
mDecodedData = MediaDataDecoder::DecodedData();
|
||||
mDecodePromise.RejectIfExists(aError, __func__);
|
||||
mDrainPromise.RejectIfExists(aError, __func__);
|
||||
mFlushPromise.RejectIfExists(aError, __func__);
|
||||
|
@ -153,7 +153,7 @@ VideoDecoderChild::ActorDestroy(ActorDestroyReason aWhy)
|
|||
MediaResult error(NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER);
|
||||
error.SetGPUCrashTimeStamp(ref->mGPUCrashTime);
|
||||
if (ref->mInitialized) {
|
||||
mDecodedData.Clear();
|
||||
mDecodedData = MediaDataDecoder::DecodedData();
|
||||
mDecodePromise.RejectIfExists(error, __func__);
|
||||
mDrainPromise.RejectIfExists(error, __func__);
|
||||
mFlushPromise.RejectIfExists(error, __func__);
|
||||
|
|
|
@ -165,11 +165,11 @@ VideoDecoderParent::RecvInput(const MediaRawDataIPDL& aData)
|
|||
RefPtr<VideoDecoderParent> self = this;
|
||||
mDecoder->Decode(data)->Then(
|
||||
mManagerTaskQueue, __func__,
|
||||
[self, this](const MediaDataDecoder::DecodedData& aResults) {
|
||||
[self, this](MediaDataDecoder::DecodedData&& aResults) {
|
||||
if (mDestroyed) {
|
||||
return;
|
||||
}
|
||||
ProcessDecodedData(aResults);
|
||||
ProcessDecodedData(std::move(aResults));
|
||||
Unused << SendInputExhausted();
|
||||
},
|
||||
[self](const MediaResult& aError) { self->Error(aError); });
|
||||
|
@ -177,8 +177,7 @@ VideoDecoderParent::RecvInput(const MediaRawDataIPDL& aData)
|
|||
}
|
||||
|
||||
void
|
||||
VideoDecoderParent::ProcessDecodedData(
|
||||
const MediaDataDecoder::DecodedData& aData)
|
||||
VideoDecoderParent::ProcessDecodedData(MediaDataDecoder::DecodedData&& aData)
|
||||
{
|
||||
MOZ_ASSERT(OnManagerThread());
|
||||
|
||||
|
@ -187,7 +186,7 @@ VideoDecoderParent::ProcessDecodedData(
|
|||
return;
|
||||
}
|
||||
|
||||
for (const auto& data : aData) {
|
||||
for (auto&& data : aData) {
|
||||
MOZ_ASSERT(data->mType == MediaData::VIDEO_DATA,
|
||||
"Can only decode videos using VideoDecoderParent!");
|
||||
VideoData* video = static_cast<VideoData*>(data.get());
|
||||
|
@ -200,7 +199,7 @@ VideoDecoderParent::ProcessDecodedData(
|
|||
|
||||
if (!texture) {
|
||||
texture = ImageClient::CreateTextureClientForImage(video->mImage,
|
||||
mKnowsCompositor);
|
||||
mKnowsCompositor);
|
||||
}
|
||||
|
||||
if (texture && !texture->IsAddedToCompositableClient()) {
|
||||
|
@ -248,9 +247,9 @@ VideoDecoderParent::RecvDrain()
|
|||
RefPtr<VideoDecoderParent> self = this;
|
||||
mDecoder->Drain()->Then(
|
||||
mManagerTaskQueue, __func__,
|
||||
[self, this](const MediaDataDecoder::DecodedData& aResults) {
|
||||
[self, this](MediaDataDecoder::DecodedData&& aResults) {
|
||||
if (!mDestroyed) {
|
||||
ProcessDecodedData(aResults);
|
||||
ProcessDecodedData(std::move(aResults));
|
||||
Unused << SendDrainComplete();
|
||||
}
|
||||
},
|
||||
|
|
|
@ -53,7 +53,7 @@ private:
|
|||
void Error(const MediaResult& aError);
|
||||
|
||||
~VideoDecoderParent();
|
||||
void ProcessDecodedData(const MediaDataDecoder::DecodedData& aData);
|
||||
void ProcessDecodedData(MediaDataDecoder::DecodedData&& aData);
|
||||
|
||||
RefPtr<VideoDecoderManagerParent> mParent;
|
||||
RefPtr<VideoDecoderParent> mIPDLSelfRef;
|
||||
|
|
|
@ -251,8 +251,10 @@ MediaCapabilities::DecodingInfo(
|
|||
promises.AppendElement(InvokeAsync(
|
||||
taskQueue,
|
||||
__func__,
|
||||
[taskQueue, frameRate, compositor, config = std::move(config)]() mutable
|
||||
-> RefPtr<CapabilitiesPromise> {
|
||||
[ taskQueue,
|
||||
frameRate,
|
||||
compositor,
|
||||
config = std::move(config) ]() mutable -> RefPtr<CapabilitiesPromise> {
|
||||
// MediaDataDecoder keeps a reference to the config object, so we must
|
||||
// keep it alive until the decoder has been shutdown.
|
||||
CreateDecoderParams params{ *config,
|
||||
|
@ -264,25 +266,25 @@ MediaCapabilities::DecodingInfo(
|
|||
return AllocationWrapper::CreateDecoder(params)->Then(
|
||||
taskQueue,
|
||||
__func__,
|
||||
[taskQueue, frameRate, config = std::move(config)](
|
||||
const AllocationWrapper::AllocateDecoderPromise::
|
||||
ResolveOrRejectValue& aValue) mutable {
|
||||
[ taskQueue, frameRate, config = std::move(config) ](
|
||||
AllocationWrapper::AllocateDecoderPromise::ResolveOrRejectValue&&
|
||||
aValue) mutable {
|
||||
if (aValue.IsReject()) {
|
||||
return CapabilitiesPromise::CreateAndReject(aValue.RejectValue(),
|
||||
__func__);
|
||||
return CapabilitiesPromise::CreateAndReject(
|
||||
std::move(aValue.RejectValue()), __func__);
|
||||
}
|
||||
RefPtr<MediaDataDecoder> decoder = aValue.ResolveValue();
|
||||
RefPtr<MediaDataDecoder> decoder = std::move(aValue.ResolveValue());
|
||||
// We now query the decoder to determine if it's power efficient.
|
||||
RefPtr<CapabilitiesPromise> p = decoder->Init()->Then(
|
||||
taskQueue,
|
||||
__func__,
|
||||
[taskQueue, decoder, frameRate, config = std::move(config)](
|
||||
const MediaDataDecoder::InitPromise::ResolveOrRejectValue&
|
||||
aValue) mutable {
|
||||
[ taskQueue, decoder, frameRate, config = std::move(config) ](
|
||||
MediaDataDecoder::InitPromise::ResolveOrRejectValue&&
|
||||
aValue) mutable {
|
||||
RefPtr<CapabilitiesPromise> p;
|
||||
if (aValue.IsReject()) {
|
||||
p = CapabilitiesPromise::CreateAndReject(aValue.RejectValue(),
|
||||
__func__);
|
||||
p = CapabilitiesPromise::CreateAndReject(
|
||||
std::move(aValue.RejectValue()), __func__);
|
||||
} else {
|
||||
MOZ_ASSERT(config->IsVideo());
|
||||
nsAutoCString reason;
|
||||
|
@ -368,14 +370,15 @@ MediaCapabilities::DecodingInfo(
|
|||
->Then(
|
||||
targetThread,
|
||||
__func__,
|
||||
[promise,
|
||||
tracks = std::move(tracks),
|
||||
workerRef,
|
||||
holder,
|
||||
aConfiguration,
|
||||
self,
|
||||
this](const CapabilitiesPromise::AllPromiseType::ResolveOrRejectValue&
|
||||
aValue) {
|
||||
[
|
||||
promise,
|
||||
tracks = std::move(tracks),
|
||||
workerRef,
|
||||
holder,
|
||||
aConfiguration,
|
||||
self,
|
||||
this
|
||||
](CapabilitiesPromise::AllPromiseType::ResolveOrRejectValue&& aValue) {
|
||||
holder->Complete();
|
||||
if (aValue.IsReject()) {
|
||||
auto info =
|
||||
|
|
|
@ -214,14 +214,12 @@ public:
|
|||
writer->mCrypto = CryptoSample();
|
||||
RefPtr<EMEDecryptor> self = this;
|
||||
mDecoder->Decode(aDecrypted.mSample)
|
||||
->Then(mTaskQueue, __func__,
|
||||
[self](const DecodedData& aResults) {
|
||||
->Then(mTaskQueue,
|
||||
__func__,
|
||||
[self](DecodePromise::ResolveOrRejectValue&& aValue) {
|
||||
self->mDecodeRequest.Complete();
|
||||
self->mDecodePromise.ResolveIfExists(aResults, __func__);
|
||||
},
|
||||
[self](const MediaResult& aError) {
|
||||
self->mDecodeRequest.Complete();
|
||||
self->mDecodePromise.RejectIfExists(aError, __func__);
|
||||
self->mDecodePromise.ResolveOrReject(std::move(aValue),
|
||||
__func__);
|
||||
})
|
||||
->Track(mDecodeRequest);
|
||||
}
|
||||
|
@ -350,16 +348,14 @@ EMEMediaDataDecoderProxy::Decode(MediaRawData* aSample)
|
|||
mKeyRequest.Complete();
|
||||
|
||||
MediaDataDecoderProxy::Decode(aSample)
|
||||
->Then(mTaskQueue,
|
||||
__func__,
|
||||
[self, this](const DecodedData& aResults) {
|
||||
mDecodeRequest.Complete();
|
||||
mDecodePromise.Resolve(aResults, __func__);
|
||||
},
|
||||
[self, this](const MediaResult& aError) {
|
||||
mDecodeRequest.Complete();
|
||||
mDecodePromise.Reject(aError, __func__);
|
||||
})
|
||||
->Then(
|
||||
mTaskQueue,
|
||||
__func__,
|
||||
[self, this](DecodePromise::ResolveOrRejectValue&& aValue) {
|
||||
mDecodeRequest.Complete();
|
||||
mDecodePromise.ResolveOrReject(std::move(aValue),
|
||||
__func__);
|
||||
})
|
||||
->Track(mDecodeRequest);
|
||||
},
|
||||
[self]() {
|
||||
|
|
|
@ -101,16 +101,16 @@ void
|
|||
GMPVideoDecoder::InputDataExhausted()
|
||||
{
|
||||
MOZ_ASSERT(IsOnGMPThread());
|
||||
mDecodePromise.ResolveIfExists(mDecodedData, __func__);
|
||||
mDecodedData.Clear();
|
||||
mDecodePromise.ResolveIfExists(std::move(mDecodedData), __func__);
|
||||
mDecodedData = DecodedData();
|
||||
}
|
||||
|
||||
void
|
||||
GMPVideoDecoder::DrainComplete()
|
||||
{
|
||||
MOZ_ASSERT(IsOnGMPThread());
|
||||
mDrainPromise.ResolveIfExists(mDecodedData, __func__);
|
||||
mDecodedData.Clear();
|
||||
mDrainPromise.ResolveIfExists(std::move(mDecodedData), __func__);
|
||||
mDecodedData = DecodedData();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -498,7 +498,7 @@ RemoteDataDecoder::Flush()
|
|||
{
|
||||
RefPtr<RemoteDataDecoder> self = this;
|
||||
return InvokeAsync(mTaskQueue, __func__, [self, this]() {
|
||||
mDecodedData.Clear();
|
||||
mDecodedData = DecodedData();
|
||||
mNumPendingInputs = 0;
|
||||
mDecodePromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
|
||||
mDrainPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
|
||||
|
@ -726,12 +726,12 @@ RemoteDataDecoder::ReturnDecodedData()
|
|||
|
||||
// We only want to clear mDecodedData when we have resolved the promises.
|
||||
if (!mDecodePromise.IsEmpty()) {
|
||||
mDecodePromise.Resolve(mDecodedData, __func__);
|
||||
mDecodedData.Clear();
|
||||
mDecodePromise.Resolve(std::move(mDecodedData), __func__);
|
||||
mDecodedData = DecodedData();
|
||||
} else if (!mDrainPromise.IsEmpty() &&
|
||||
(!mDecodedData.IsEmpty() || mDrainStatus == DrainStatus::DRAINED)) {
|
||||
mDrainPromise.Resolve(mDecodedData, __func__);
|
||||
mDecodedData.Clear();
|
||||
mDrainPromise.Resolve(std::move(mDecodedData), __func__);
|
||||
mDecodedData = DecodedData();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -223,7 +223,9 @@ AppleATDecoder::ProcessDecode(MediaRawData* aSample)
|
|||
mQueuedSamples.Clear();
|
||||
}
|
||||
|
||||
return DecodePromise::CreateAndResolve(std::move(mDecodedSamples), __func__);
|
||||
DecodedData results = std::move(mDecodedSamples);
|
||||
mDecodedSamples = DecodedData();
|
||||
return DecodePromise::CreateAndResolve(std::move(results), __func__);
|
||||
}
|
||||
|
||||
MediaResult
|
||||
|
|
|
@ -137,15 +137,12 @@ OmxDataDecoder::EndOfStream()
|
|||
|
||||
RefPtr<OmxDataDecoder> self = this;
|
||||
mOmxLayer->SendCommand(OMX_CommandFlush, OMX_ALL, nullptr)
|
||||
->Then(mOmxTaskQueue, __func__,
|
||||
[self, this] () {
|
||||
mDrainPromise.ResolveIfExists(mDecodedData, __func__);
|
||||
mDecodedData.Clear();
|
||||
},
|
||||
[self, this] () {
|
||||
mDrainPromise.ResolveIfExists(mDecodedData, __func__);
|
||||
mDecodedData.Clear();
|
||||
});
|
||||
->Then(mOmxTaskQueue,
|
||||
__func__,
|
||||
[self, this](OmxCommandPromise::ResolveOrRejectValue&& aValue) {
|
||||
mDrainPromise.ResolveIfExists(std::move(mDecodedData), __func__);
|
||||
mDecodedData = DecodedData();
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<MediaDataDecoder::InitPromise>
|
||||
|
@ -401,8 +398,8 @@ OmxDataDecoder::EmptyBufferDone(BufferData* aData)
|
|||
return;
|
||||
}
|
||||
|
||||
mDecodePromise.ResolveIfExists(mDecodedData, __func__);
|
||||
mDecodedData.Clear();
|
||||
mDecodePromise.ResolveIfExists(std::move(mDecodedData), __func__);
|
||||
mDecodedData = DecodedData();
|
||||
});
|
||||
|
||||
nsresult rv = mOmxTaskQueue->Dispatch(r.forget());
|
||||
|
@ -422,7 +419,7 @@ OmxDataDecoder::NotifyError(OMX_ERRORTYPE aOmxError, const char* aLine, const Me
|
|||
{
|
||||
LOG("NotifyError %d (%s) at %s", static_cast<int>(aOmxError),
|
||||
aError.ErrorName().get(), aLine);
|
||||
mDecodedData.Clear();
|
||||
mDecodedData = DecodedData();
|
||||
mDecodePromise.RejectIfExists(aError, __func__);
|
||||
mDrainPromise.RejectIfExists(aError, __func__);
|
||||
mFlushPromise.RejectIfExists(aError, __func__);
|
||||
|
@ -855,7 +852,7 @@ OmxDataDecoder::DoFlush()
|
|||
{
|
||||
MOZ_ASSERT(mOmxTaskQueue->IsCurrentThreadIn());
|
||||
|
||||
mDecodedData.Clear();
|
||||
mDecodedData = DecodedData();
|
||||
mDecodePromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
|
||||
mDrainPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
|
||||
|
||||
|
|
|
@ -552,8 +552,8 @@ MediaChangeMonitor::DecodeFirstSample(MediaRawData* aSample)
|
|||
AssertOnTaskQueue();
|
||||
|
||||
if (mNeedKeyframe && !aSample->mKeyframe) {
|
||||
mDecodePromise.Resolve(mPendingFrames, __func__);
|
||||
mPendingFrames.Clear();
|
||||
mDecodePromise.Resolve(std::move(mPendingFrames), __func__);
|
||||
mPendingFrames = DecodedData();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -569,11 +569,11 @@ MediaChangeMonitor::DecodeFirstSample(MediaRawData* aSample)
|
|||
RefPtr<MediaChangeMonitor> self = this;
|
||||
mDecoder->Decode(aSample)
|
||||
->Then(AbstractThread::GetCurrent()->AsTaskQueue(), __func__,
|
||||
[self, this](const MediaDataDecoder::DecodedData& aResults) {
|
||||
[self, this](MediaDataDecoder::DecodedData&& aResults) {
|
||||
mDecodePromiseRequest.Complete();
|
||||
mPendingFrames.AppendElements(aResults);
|
||||
mDecodePromise.Resolve(mPendingFrames, __func__);
|
||||
mPendingFrames.Clear();
|
||||
mPendingFrames.AppendElements(std::move(aResults));
|
||||
mDecodePromise.Resolve(std::move(mPendingFrames), __func__);
|
||||
mPendingFrames = DecodedData();
|
||||
},
|
||||
[self, this](const MediaResult& aError) {
|
||||
mDecodePromiseRequest.Complete();
|
||||
|
@ -619,7 +619,7 @@ MediaChangeMonitor::DrainThenFlushDecoder(MediaRawData* aPendingSample)
|
|||
mDecoder->Drain()
|
||||
->Then(AbstractThread::GetCurrent()->AsTaskQueue(),
|
||||
__func__,
|
||||
[self, sample, this](const MediaDataDecoder::DecodedData& aResults) {
|
||||
[self, sample, this](MediaDataDecoder::DecodedData&& aResults) {
|
||||
mDrainRequest.Complete();
|
||||
if (!mFlushPromise.IsEmpty()) {
|
||||
// A Flush is pending, abort the current operation.
|
||||
|
@ -627,7 +627,7 @@ MediaChangeMonitor::DrainThenFlushDecoder(MediaRawData* aPendingSample)
|
|||
return;
|
||||
}
|
||||
if (aResults.Length() > 0) {
|
||||
mPendingFrames.AppendElements(aResults);
|
||||
mPendingFrames.AppendElements(std::move(aResults));
|
||||
DrainThenFlushDecoder(sample);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1219,6 +1219,11 @@ public:
|
|||
template<typename ResolveValueType_>
|
||||
void Resolve(ResolveValueType_&& aResolveValue, const char* aMethodName)
|
||||
{
|
||||
static_assert(
|
||||
IsConvertible<ResolveValueType_,
|
||||
typename PromiseType::ResolveValueType>::value,
|
||||
"Resolve() argument must be convertible to MozPromise's ResolveValueT");
|
||||
|
||||
if (mMonitor) {
|
||||
mMonitor->AssertCurrentThreadOwns();
|
||||
}
|
||||
|
@ -1240,6 +1245,11 @@ public:
|
|||
template<typename RejectValueType_>
|
||||
void Reject(RejectValueType_&& aRejectValue, const char* aMethodName)
|
||||
{
|
||||
static_assert(
|
||||
IsConvertible<RejectValueType_,
|
||||
typename PromiseType::RejectValueType>::value,
|
||||
"Reject() argument must be convertible to MozPromise's RejectValueT");
|
||||
|
||||
if (mMonitor) {
|
||||
mMonitor->AssertCurrentThreadOwns();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче