Backed out changeset 157be32d85fe (bug 1504643) for conflicts while backing out bug 1471535

This commit is contained in:
Dorel Luca 2018-11-09 12:13:54 +02:00
parent a937d45657
commit c34d2cd0fa
16 changed files with 104 additions and 111 deletions

View File

@ -335,7 +335,7 @@ BenchmarkPlayback::GlobalShutdown()
}
void
BenchmarkPlayback::Output(MediaDataDecoder::DecodedData&& aResults)
BenchmarkPlayback::Output(const 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](MediaDataDecoder::DecodedData&& aResults) {
Output(std::move(aResults));
[ref, this](const MediaDataDecoder::DecodedData& aResults) {
Output(aResults);
if (!mFinished) {
mDecoder->Drain()->Then(
Thread(), __func__,
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
[ref, this](const MediaDataDecoder::DecodedData& aResults) {
mDrained = true;
Output(std::move(aResults));
Output(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](MediaDataDecoder::DecodedData&& aResults) {
Output(std::move(aResults));
[ref, this](const MediaDataDecoder::DecodedData& aResults) {
Output(aResults);
if (!mFinished) {
InputExhausted();
}

View File

@ -29,7 +29,7 @@ class BenchmarkPlayback : public QueueObject
void GlobalShutdown();
void InitDecoder(TrackInfo&& aInfo);
void Output(MediaDataDecoder::DecodedData&& aResults);
void Output(const MediaDataDecoder::DecodedData& aResults);
void Error(const MediaResult& aError);
void InputExhausted();

View File

@ -1845,7 +1845,7 @@ MediaFormatReader::OnAudioDemuxCompleted(
void
MediaFormatReader::NotifyNewOutput(
TrackType aTrack, MediaDataDecoder::DecodedData&& aResults)
TrackType aTrack, const 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]
(MediaDataDecoder::DecodedData&& aResults) {
(const MediaDataDecoder::DecodedData& aResults) {
decoder.mDecodeRequest.Complete();
self->NotifyNewOutput(aTrack, std::move(aResults));
self->NotifyNewOutput(aTrack, 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]
(MediaDataDecoder::DecodedData&& aResults) {
(const MediaDataDecoder::DecodedData& aResults) {
decoder.mDrainRequest.Complete();
DDLOGEX(self.get(), DDLogCategory::Log, "drained", DDNoValue{});
if (aResults.IsEmpty()) {
decoder.mDrainState = DrainState::DrainCompleted;
} else {
self->NotifyNewOutput(aTrack, std::move(aResults));
self->NotifyNewOutput(aTrack, aResults);
// Let's see if we have any more data available to drain.
decoder.mDrainState = DrainState::PartialDrainPending;
}

View File

@ -318,7 +318,7 @@ private:
// Drain the current decoder.
void DrainDecoder(TrackType aTrack);
void NotifyNewOutput(TrackType aTrack,
MediaDataDecoder::DecodedData&& aResults);
const MediaDataDecoder::DecodedData& aResults);
void NotifyError(TrackType aTrack, const MediaResult& aError);
void NotifyWaitingForData(TrackType aTrack);
void NotifyWaitingForKey(TrackType aTrack);

View File

@ -119,8 +119,8 @@ mozilla::ipc::IPCResult
RemoteVideoDecoderChild::RecvInputExhausted()
{
AssertOnManagerThread();
mDecodePromise.ResolveIfExists(std::move(mDecodedData), __func__);
mDecodedData = MediaDataDecoder::DecodedData();
mDecodePromise.ResolveIfExists(mDecodedData, __func__);
mDecodedData.Clear();
return IPC_OK();
}
@ -128,8 +128,8 @@ mozilla::ipc::IPCResult
RemoteVideoDecoderChild::RecvDrainComplete()
{
AssertOnManagerThread();
mDecodePromise.ResolveIfExists(std::move(mDecodedData), __func__);
mDecodedData = MediaDataDecoder::DecodedData();
mDrainPromise.ResolveIfExists(mDecodedData, __func__);
mDecodedData.Clear();
return IPC_OK();
}
@ -137,7 +137,7 @@ mozilla::ipc::IPCResult
RemoteVideoDecoderChild::RecvError(const nsresult& aError)
{
AssertOnManagerThread();
mDecodedData = MediaDataDecoder::DecodedData();
mDecodedData.Clear();
mDecodePromise.RejectIfExists(aError, __func__);
mDrainPromise.RejectIfExists(aError, __func__);
mFlushPromise.RejectIfExists(aError, __func__);

View File

@ -81,8 +81,8 @@ mozilla::ipc::IPCResult
VideoDecoderChild::RecvInputExhausted()
{
AssertOnManagerThread();
mDecodePromise.ResolveIfExists(std::move(mDecodedData), __func__);
mDecodedData = MediaDataDecoder::DecodedData();
mDecodePromise.ResolveIfExists(mDecodedData, __func__);
mDecodedData.Clear();
return IPC_OK();
}
@ -90,8 +90,8 @@ mozilla::ipc::IPCResult
VideoDecoderChild::RecvDrainComplete()
{
AssertOnManagerThread();
mDrainPromise.ResolveIfExists(std::move(mDecodedData), __func__);
mDecodedData = MediaDataDecoder::DecodedData();
mDrainPromise.ResolveIfExists(mDecodedData, __func__);
mDecodedData.Clear();
return IPC_OK();
}
@ -99,7 +99,7 @@ mozilla::ipc::IPCResult
VideoDecoderChild::RecvError(const nsresult& aError)
{
AssertOnManagerThread();
mDecodedData = MediaDataDecoder::DecodedData();
mDecodedData.Clear();
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 = MediaDataDecoder::DecodedData();
mDecodedData.Clear();
mDecodePromise.RejectIfExists(error, __func__);
mDrainPromise.RejectIfExists(error, __func__);
mFlushPromise.RejectIfExists(error, __func__);

View File

@ -165,11 +165,11 @@ VideoDecoderParent::RecvInput(const MediaRawDataIPDL& aData)
RefPtr<VideoDecoderParent> self = this;
mDecoder->Decode(data)->Then(
mManagerTaskQueue, __func__,
[self, this](MediaDataDecoder::DecodedData&& aResults) {
[self, this](const MediaDataDecoder::DecodedData& aResults) {
if (mDestroyed) {
return;
}
ProcessDecodedData(std::move(aResults));
ProcessDecodedData(aResults);
Unused << SendInputExhausted();
},
[self](const MediaResult& aError) { self->Error(aError); });
@ -177,7 +177,8 @@ VideoDecoderParent::RecvInput(const MediaRawDataIPDL& aData)
}
void
VideoDecoderParent::ProcessDecodedData(MediaDataDecoder::DecodedData&& aData)
VideoDecoderParent::ProcessDecodedData(
const MediaDataDecoder::DecodedData& aData)
{
MOZ_ASSERT(OnManagerThread());
@ -186,7 +187,7 @@ VideoDecoderParent::ProcessDecodedData(MediaDataDecoder::DecodedData&& aData)
return;
}
for (auto&& data : aData) {
for (const auto& data : aData) {
MOZ_ASSERT(data->mType == MediaData::VIDEO_DATA,
"Can only decode videos using VideoDecoderParent!");
VideoData* video = static_cast<VideoData*>(data.get());
@ -199,7 +200,7 @@ VideoDecoderParent::ProcessDecodedData(MediaDataDecoder::DecodedData&& aData)
if (!texture) {
texture = ImageClient::CreateTextureClientForImage(video->mImage,
mKnowsCompositor);
mKnowsCompositor);
}
if (texture && !texture->IsAddedToCompositableClient()) {
@ -247,9 +248,9 @@ VideoDecoderParent::RecvDrain()
RefPtr<VideoDecoderParent> self = this;
mDecoder->Drain()->Then(
mManagerTaskQueue, __func__,
[self, this](MediaDataDecoder::DecodedData&& aResults) {
[self, this](const MediaDataDecoder::DecodedData& aResults) {
if (!mDestroyed) {
ProcessDecodedData(std::move(aResults));
ProcessDecodedData(aResults);
Unused << SendDrainComplete();
}
},

View File

@ -53,7 +53,7 @@ private:
void Error(const MediaResult& aError);
~VideoDecoderParent();
void ProcessDecodedData(MediaDataDecoder::DecodedData&& aData);
void ProcessDecodedData(const MediaDataDecoder::DecodedData& aData);
RefPtr<VideoDecoderManagerParent> mParent;
RefPtr<VideoDecoderParent> mIPDLSelfRef;

View File

@ -251,10 +251,8 @@ 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,
@ -266,25 +264,25 @@ MediaCapabilities::DecodingInfo(
return AllocationWrapper::CreateDecoder(params)->Then(
taskQueue,
__func__,
[ taskQueue, frameRate, config = std::move(config) ](
AllocationWrapper::AllocateDecoderPromise::ResolveOrRejectValue&&
aValue) mutable {
[taskQueue, frameRate, config = std::move(config)](
const AllocationWrapper::AllocateDecoderPromise::
ResolveOrRejectValue& aValue) mutable {
if (aValue.IsReject()) {
return CapabilitiesPromise::CreateAndReject(
std::move(aValue.RejectValue()), __func__);
return CapabilitiesPromise::CreateAndReject(aValue.RejectValue(),
__func__);
}
RefPtr<MediaDataDecoder> decoder = std::move(aValue.ResolveValue());
RefPtr<MediaDataDecoder> decoder = 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) ](
MediaDataDecoder::InitPromise::ResolveOrRejectValue&&
aValue) mutable {
[taskQueue, decoder, frameRate, config = std::move(config)](
const MediaDataDecoder::InitPromise::ResolveOrRejectValue&
aValue) mutable {
RefPtr<CapabilitiesPromise> p;
if (aValue.IsReject()) {
p = CapabilitiesPromise::CreateAndReject(
std::move(aValue.RejectValue()), __func__);
p = CapabilitiesPromise::CreateAndReject(aValue.RejectValue(),
__func__);
} else {
MOZ_ASSERT(config->IsVideo());
nsAutoCString reason;
@ -370,15 +368,14 @@ MediaCapabilities::DecodingInfo(
->Then(
targetThread,
__func__,
[
promise,
tracks = std::move(tracks),
workerRef,
holder,
aConfiguration,
self,
this
](CapabilitiesPromise::AllPromiseType::ResolveOrRejectValue&& aValue) {
[promise,
tracks = std::move(tracks),
workerRef,
holder,
aConfiguration,
self,
this](const CapabilitiesPromise::AllPromiseType::ResolveOrRejectValue&
aValue) {
holder->Complete();
if (aValue.IsReject()) {
auto info =

View File

@ -214,12 +214,14 @@ public:
writer->mCrypto = CryptoSample();
RefPtr<EMEDecryptor> self = this;
mDecoder->Decode(aDecrypted.mSample)
->Then(mTaskQueue,
__func__,
[self](DecodePromise::ResolveOrRejectValue&& aValue) {
->Then(mTaskQueue, __func__,
[self](const DecodedData& aResults) {
self->mDecodeRequest.Complete();
self->mDecodePromise.ResolveOrReject(std::move(aValue),
__func__);
self->mDecodePromise.ResolveIfExists(aResults, __func__);
},
[self](const MediaResult& aError) {
self->mDecodeRequest.Complete();
self->mDecodePromise.RejectIfExists(aError, __func__);
})
->Track(mDecodeRequest);
}
@ -348,14 +350,16 @@ EMEMediaDataDecoderProxy::Decode(MediaRawData* aSample)
mKeyRequest.Complete();
MediaDataDecoderProxy::Decode(aSample)
->Then(
mTaskQueue,
__func__,
[self, this](DecodePromise::ResolveOrRejectValue&& aValue) {
mDecodeRequest.Complete();
mDecodePromise.ResolveOrReject(std::move(aValue),
__func__);
})
->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__);
})
->Track(mDecodeRequest);
},
[self]() {

View File

@ -101,16 +101,16 @@ void
GMPVideoDecoder::InputDataExhausted()
{
MOZ_ASSERT(IsOnGMPThread());
mDecodePromise.ResolveIfExists(std::move(mDecodedData), __func__);
mDecodedData = DecodedData();
mDecodePromise.ResolveIfExists(mDecodedData, __func__);
mDecodedData.Clear();
}
void
GMPVideoDecoder::DrainComplete()
{
MOZ_ASSERT(IsOnGMPThread());
mDrainPromise.ResolveIfExists(std::move(mDecodedData), __func__);
mDecodedData = DecodedData();
mDrainPromise.ResolveIfExists(mDecodedData, __func__);
mDecodedData.Clear();
}
void

View File

@ -498,7 +498,7 @@ RemoteDataDecoder::Flush()
{
RefPtr<RemoteDataDecoder> self = this;
return InvokeAsync(mTaskQueue, __func__, [self, this]() {
mDecodedData = DecodedData();
mDecodedData.Clear();
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(std::move(mDecodedData), __func__);
mDecodedData = DecodedData();
mDecodePromise.Resolve(mDecodedData, __func__);
mDecodedData.Clear();
} else if (!mDrainPromise.IsEmpty() &&
(!mDecodedData.IsEmpty() || mDrainStatus == DrainStatus::DRAINED)) {
mDrainPromise.Resolve(std::move(mDecodedData), __func__);
mDecodedData = DecodedData();
mDrainPromise.Resolve(mDecodedData, __func__);
mDecodedData.Clear();
}
}

View File

@ -223,9 +223,7 @@ AppleATDecoder::ProcessDecode(MediaRawData* aSample)
mQueuedSamples.Clear();
}
DecodedData results = std::move(mDecodedSamples);
mDecodedSamples = DecodedData();
return DecodePromise::CreateAndResolve(std::move(results), __func__);
return DecodePromise::CreateAndResolve(std::move(mDecodedSamples), __func__);
}
MediaResult

View File

@ -137,12 +137,15 @@ OmxDataDecoder::EndOfStream()
RefPtr<OmxDataDecoder> self = this;
mOmxLayer->SendCommand(OMX_CommandFlush, OMX_ALL, nullptr)
->Then(mOmxTaskQueue,
__func__,
[self, this](OmxCommandPromise::ResolveOrRejectValue&& aValue) {
mDrainPromise.ResolveIfExists(std::move(mDecodedData), __func__);
mDecodedData = DecodedData();
});
->Then(mOmxTaskQueue, __func__,
[self, this] () {
mDrainPromise.ResolveIfExists(mDecodedData, __func__);
mDecodedData.Clear();
},
[self, this] () {
mDrainPromise.ResolveIfExists(mDecodedData, __func__);
mDecodedData.Clear();
});
}
RefPtr<MediaDataDecoder::InitPromise>
@ -398,8 +401,8 @@ OmxDataDecoder::EmptyBufferDone(BufferData* aData)
return;
}
mDecodePromise.ResolveIfExists(std::move(mDecodedData), __func__);
mDecodedData = DecodedData();
mDecodePromise.ResolveIfExists(mDecodedData, __func__);
mDecodedData.Clear();
});
nsresult rv = mOmxTaskQueue->Dispatch(r.forget());
@ -419,7 +422,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 = DecodedData();
mDecodedData.Clear();
mDecodePromise.RejectIfExists(aError, __func__);
mDrainPromise.RejectIfExists(aError, __func__);
mFlushPromise.RejectIfExists(aError, __func__);
@ -852,7 +855,7 @@ OmxDataDecoder::DoFlush()
{
MOZ_ASSERT(mOmxTaskQueue->IsCurrentThreadIn());
mDecodedData = DecodedData();
mDecodedData.Clear();
mDecodePromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
mDrainPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);

View File

@ -552,8 +552,8 @@ MediaChangeMonitor::DecodeFirstSample(MediaRawData* aSample)
AssertOnTaskQueue();
if (mNeedKeyframe && !aSample->mKeyframe) {
mDecodePromise.Resolve(std::move(mPendingFrames), __func__);
mPendingFrames = DecodedData();
mDecodePromise.Resolve(mPendingFrames, __func__);
mPendingFrames.Clear();
return;
}
@ -569,11 +569,11 @@ MediaChangeMonitor::DecodeFirstSample(MediaRawData* aSample)
RefPtr<MediaChangeMonitor> self = this;
mDecoder->Decode(aSample)
->Then(AbstractThread::GetCurrent()->AsTaskQueue(), __func__,
[self, this](MediaDataDecoder::DecodedData&& aResults) {
[self, this](const MediaDataDecoder::DecodedData& aResults) {
mDecodePromiseRequest.Complete();
mPendingFrames.AppendElements(std::move(aResults));
mDecodePromise.Resolve(std::move(mPendingFrames), __func__);
mPendingFrames = DecodedData();
mPendingFrames.AppendElements(aResults);
mDecodePromise.Resolve(mPendingFrames, __func__);
mPendingFrames.Clear();
},
[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](MediaDataDecoder::DecodedData&& aResults) {
[self, sample, this](const 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(std::move(aResults));
mPendingFrames.AppendElements(aResults);
DrainThenFlushDecoder(sample);
return;
}

View File

@ -1219,11 +1219,6 @@ 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();
}
@ -1245,11 +1240,6 @@ 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();
}