зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1362912. P2 - fix the callers. r=gerald
MozReview-Commit-ID: LdYcIWAFDUn --HG-- extra : rebase_source : eb943f7e5b7674c3397fce3ad0e8193b4c0ddc01 extra : source : fdfd468b6edbabf3830eb78fc705f6d6682b7126
This commit is contained in:
Родитель
4f8f4d86e6
Коммит
20f3ad9f2f
|
@ -54,8 +54,11 @@ MediaDecoderReaderWrapper::RequestAudioData()
|
|||
->Then(mOwnerThread, __func__,
|
||||
[startTime] (AudioData* aAudio) {
|
||||
aAudio->AdjustForStartTime(startTime);
|
||||
return AudioDataPromise::CreateAndResolve(aAudio, __func__);
|
||||
},
|
||||
[] (const MediaResult& aError) {});
|
||||
[] (const MediaResult& aError) {
|
||||
return AudioDataPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<MediaDecoderReaderWrapper::VideoDataPromise>
|
||||
|
@ -77,8 +80,11 @@ MediaDecoderReaderWrapper::RequestVideoData(bool aSkipToNextKeyframe,
|
|||
->Then(mOwnerThread, __func__,
|
||||
[startTime] (VideoData* aVideo) {
|
||||
aVideo->AdjustForStartTime(startTime);
|
||||
return VideoDataPromise::CreateAndResolve(aVideo, __func__);
|
||||
},
|
||||
[] (const MediaResult& aError) {});
|
||||
[] (const MediaResult& aError) {
|
||||
return VideoDataPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<MediaDecoderReader::SeekPromise>
|
||||
|
@ -131,17 +137,25 @@ MediaDecoderReaderWrapper::Shutdown()
|
|||
&MediaDecoderReader::Shutdown);
|
||||
}
|
||||
|
||||
void
|
||||
RefPtr<MediaDecoderReaderWrapper::MetadataPromise>
|
||||
MediaDecoderReaderWrapper::OnMetadataRead(MetadataHolder* aMetadata)
|
||||
{
|
||||
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
|
||||
if (mShutdown) {
|
||||
return;
|
||||
return MetadataPromise::CreateAndReject(
|
||||
NS_ERROR_DOM_MEDIA_ABORT_ERR, __func__);
|
||||
}
|
||||
|
||||
if (mStartTime.isNothing()) {
|
||||
mStartTime.emplace(aMetadata->mInfo.mStartTime);
|
||||
}
|
||||
return MetadataPromise::CreateAndResolve(aMetadata, __func__);
|
||||
}
|
||||
|
||||
RefPtr<MediaDecoderReaderWrapper::MetadataPromise>
|
||||
MediaDecoderReaderWrapper::OnMetadataNotRead(const MediaResult& aError)
|
||||
{
|
||||
return MetadataPromise::CreateAndReject(aError, __func__);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -90,8 +90,8 @@ public:
|
|||
|
||||
private:
|
||||
~MediaDecoderReaderWrapper();
|
||||
void OnMetadataRead(MetadataHolder* aMetadata);
|
||||
void OnMetadataNotRead() {}
|
||||
RefPtr<MetadataPromise> OnMetadataRead(MetadataHolder* aMetadata);
|
||||
RefPtr<MetadataPromise> OnMetadataNotRead(const MediaResult& aError);
|
||||
|
||||
const RefPtr<AbstractThread> mOwnerThread;
|
||||
const RefPtr<MediaDecoderReader> mReader;
|
||||
|
|
|
@ -570,8 +570,9 @@ public:
|
|||
RefPtr<Token> token = mToken.forget();
|
||||
return decoder->Shutdown()->Then(
|
||||
AbstractThread::GetCurrent(), __func__,
|
||||
[token]() {},
|
||||
[token]() { MOZ_RELEASE_ASSERT(false, "Can't reach here"); });
|
||||
[token]() {
|
||||
return ShutdownPromise::CreateAndResolve(true, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -889,8 +890,14 @@ public:
|
|||
mTaskQueue, __func__,
|
||||
[self, aTime]() { return self->mTrackDemuxer->Seek(aTime); })
|
||||
->Then(mTaskQueue, __func__,
|
||||
[self]() { self->UpdateRandomAccessPoint(); },
|
||||
[self]() { self->UpdateRandomAccessPoint(); });
|
||||
[self](const TimeUnit& aTime) {
|
||||
self->UpdateRandomAccessPoint();
|
||||
return SeekPromise::CreateAndResolve(aTime, __func__);
|
||||
},
|
||||
[self](const MediaResult& aError) {
|
||||
self->UpdateRandomAccessPoint();
|
||||
return SeekPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<SamplesPromise> GetSamples(int32_t aNumSamples) override
|
||||
|
@ -901,8 +908,14 @@ public:
|
|||
return self->mTrackDemuxer->GetSamples(aNumSamples);
|
||||
})
|
||||
->Then(mTaskQueue, __func__,
|
||||
[self]() { self->UpdateRandomAccessPoint(); },
|
||||
[self]() { self->UpdateRandomAccessPoint(); });
|
||||
[self](RefPtr<SamplesHolder> aSamples) {
|
||||
self->UpdateRandomAccessPoint();
|
||||
return SamplesPromise::CreateAndResolve(aSamples.forget(), __func__);
|
||||
},
|
||||
[self](const MediaResult& aError) {
|
||||
self->UpdateRandomAccessPoint();
|
||||
return SamplesPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
bool GetSamplesMayBlock() const override
|
||||
|
@ -938,8 +951,14 @@ public:
|
|||
aTimeThreshold);
|
||||
})
|
||||
->Then(mTaskQueue, __func__,
|
||||
[self]() { self->UpdateRandomAccessPoint(); },
|
||||
[self]() { self->UpdateRandomAccessPoint(); });
|
||||
[self](uint32_t aVal) {
|
||||
self->UpdateRandomAccessPoint();
|
||||
return SkipAccessPointPromise::CreateAndResolve(aVal, __func__);
|
||||
},
|
||||
[self](const SkipFailureHolder& aError) {
|
||||
self->UpdateRandomAccessPoint();
|
||||
return SkipAccessPointPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
TimeIntervals GetBuffered() override
|
||||
|
@ -997,12 +1016,14 @@ private:
|
|||
RefPtr<MediaDataDemuxer::InitPromise>
|
||||
MediaFormatReader::DemuxerProxy::Init()
|
||||
{
|
||||
using InitPromise = MediaDataDemuxer::InitPromise;
|
||||
|
||||
RefPtr<Data> data = mData;
|
||||
RefPtr<AutoTaskQueue> taskQueue = mTaskQueue;
|
||||
return InvokeAsync(mTaskQueue, __func__,
|
||||
[data, taskQueue]() {
|
||||
if (!data->mDemuxer) {
|
||||
return MediaDataDemuxer::InitPromise::CreateAndReject(
|
||||
return InitPromise::CreateAndReject(
|
||||
NS_ERROR_DOM_MEDIA_CANCELED, __func__);
|
||||
}
|
||||
return data->mDemuxer->Init();
|
||||
|
@ -1010,7 +1031,8 @@ MediaFormatReader::DemuxerProxy::Init()
|
|||
->Then(taskQueue, __func__,
|
||||
[data, taskQueue]() {
|
||||
if (!data->mDemuxer) { // Was shutdown.
|
||||
return;
|
||||
return InitPromise::CreateAndReject(
|
||||
NS_ERROR_DOM_MEDIA_CANCELED, __func__);
|
||||
}
|
||||
data->mNumAudioTrack =
|
||||
data->mDemuxer->GetNumberTracks(TrackInfo::kAudioTrack);
|
||||
|
@ -1043,8 +1065,11 @@ MediaFormatReader::DemuxerProxy::Init()
|
|||
data->mShouldComputeStartTime =
|
||||
data->mDemuxer->ShouldComputeStartTime();
|
||||
data->mInitDone = true;
|
||||
return InitPromise::CreateAndResolve(NS_OK, __func__);
|
||||
},
|
||||
[]() {});
|
||||
[](const MediaResult& aError) {
|
||||
return InitPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<MediaFormatReader::NotifyDataArrivedPromise>
|
||||
|
@ -1614,6 +1639,8 @@ MediaFormatReader::OnDemuxFailed(TrackType aTrack, const MediaResult& aError)
|
|||
void
|
||||
MediaFormatReader::DoDemuxVideo()
|
||||
{
|
||||
using SamplesPromise = MediaTrackDemuxer::SamplesPromise;
|
||||
|
||||
auto p = mVideo.mTrackDemuxer->GetSamples(1);
|
||||
|
||||
if (mVideo.mFirstDemuxedSampleTime.isNothing()) {
|
||||
|
@ -1621,9 +1648,11 @@ MediaFormatReader::DoDemuxVideo()
|
|||
p = p->Then(OwnerThread(), __func__,
|
||||
[self] (RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) {
|
||||
self->OnFirstDemuxCompleted(TrackInfo::kVideoTrack, aSamples);
|
||||
return SamplesPromise::CreateAndResolve(aSamples.forget(), __func__);
|
||||
},
|
||||
[self] (const MediaResult& aError) {
|
||||
self->OnFirstDemuxFailed(TrackInfo::kVideoTrack, aError);
|
||||
return SamplesPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1687,6 +1716,8 @@ MediaFormatReader::RequestAudioData()
|
|||
void
|
||||
MediaFormatReader::DoDemuxAudio()
|
||||
{
|
||||
using SamplesPromise = MediaTrackDemuxer::SamplesPromise;
|
||||
|
||||
auto p = mAudio.mTrackDemuxer->GetSamples(1);
|
||||
|
||||
if (mAudio.mFirstDemuxedSampleTime.isNothing()) {
|
||||
|
@ -1694,9 +1725,11 @@ MediaFormatReader::DoDemuxAudio()
|
|||
p = p->Then(OwnerThread(), __func__,
|
||||
[self] (RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) {
|
||||
self->OnFirstDemuxCompleted(TrackInfo::kAudioTrack, aSamples);
|
||||
return SamplesPromise::CreateAndResolve(aSamples.forget(), __func__);
|
||||
},
|
||||
[self] (const MediaResult& aError) {
|
||||
self->OnFirstDemuxFailed(TrackInfo::kAudioTrack, aError);
|
||||
return SamplesPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -648,15 +648,17 @@ GeckoMediaPluginServiceParent::AsyncAddPluginDirectory(const nsAString& aDirecto
|
|||
->Then(
|
||||
mMainThread,
|
||||
__func__,
|
||||
[dir, self]() -> void {
|
||||
[dir, self](bool aVal) {
|
||||
LOGD(("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s succeeded",
|
||||
NS_ConvertUTF16toUTF8(dir).get()));
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
self->UpdateContentProcessGMPCapabilities();
|
||||
return GenericPromise::CreateAndResolve(aVal, __func__);
|
||||
},
|
||||
[dir]() -> void {
|
||||
[dir](nsresult aResult) {
|
||||
LOGD(("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s failed",
|
||||
NS_ConvertUTF16toUTF8(dir).get()));
|
||||
return GenericPromise::CreateAndReject(aResult, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -874,15 +876,17 @@ GeckoMediaPluginServiceParent::AddOnGMPThread(nsString aDirectory)
|
|||
|
||||
RefPtr<GeckoMediaPluginServiceParent> self(this);
|
||||
return gmp->Init(this, directory)->Then(thread, __func__,
|
||||
[gmp, self, dir]() -> void {
|
||||
[gmp, self, dir](bool aVal) {
|
||||
LOGD(("%s::%s: %s Succeeded", __CLASS__, __FUNCTION__, dir.get()));
|
||||
{
|
||||
MutexAutoLock lock(self->mMutex);
|
||||
self->mPlugins.AppendElement(gmp);
|
||||
}
|
||||
return GenericPromise::CreateAndResolve(aVal, __func__);
|
||||
},
|
||||
[dir]() -> void {
|
||||
[dir](nsresult aResult) {
|
||||
LOGD(("%s::%s: %s Failed", __CLASS__, __FUNCTION__, dir.get()));
|
||||
return GenericPromise::CreateAndReject(aResult, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ RunOnTaskQueue(TaskQueue* aQueue, FunctionType aFun)
|
|||
}
|
||||
|
||||
// std::function can't come soon enough. :-(
|
||||
#define DO_FAIL []()->void { EXPECT_TRUE(false); }
|
||||
#define DO_FAIL []() { EXPECT_TRUE(false); return TestPromise::CreateAndReject(0, __func__); }
|
||||
|
||||
TEST(MozPromise, BasicResolve)
|
||||
{
|
||||
|
@ -185,7 +185,11 @@ TEST(MozPromise, CompletionPromises)
|
|||
->Then(queue, __func__,
|
||||
[] (int aVal) -> RefPtr<TestPromise> { return TestPromise::CreateAndResolve(aVal + 10, __func__); },
|
||||
DO_FAIL)
|
||||
->Then(queue, __func__, [&invokedPass] () -> void { invokedPass = true; }, DO_FAIL)
|
||||
->Then(queue, __func__,
|
||||
[&invokedPass] (int aVal) {
|
||||
invokedPass = true;
|
||||
return TestPromise::CreateAndResolve(aVal, __func__);
|
||||
}, DO_FAIL)
|
||||
->Then(queue, __func__,
|
||||
[queue] (int aVal) -> RefPtr<TestPromise> {
|
||||
RefPtr<TestPromise::Private> p = new TestPromise::Private(__func__);
|
||||
|
@ -222,7 +226,7 @@ TEST(MozPromise, PromiseAllResolve)
|
|||
EXPECT_EQ(aResolveValues[2], 42);
|
||||
queue->BeginShutdown();
|
||||
},
|
||||
DO_FAIL
|
||||
[]() { EXPECT_TRUE(false); }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -241,7 +245,7 @@ TEST(MozPromise, PromiseAllReject)
|
|||
promises.AppendElement(TestPromise::CreateAndReject(52.0, __func__));
|
||||
|
||||
TestPromise::All(queue, promises)->Then(queue, __func__,
|
||||
DO_FAIL,
|
||||
[]() { EXPECT_TRUE(false); },
|
||||
[queue] (float aRejectValue) -> void {
|
||||
EXPECT_EQ(aRejectValue, 32.0);
|
||||
queue->BeginShutdown();
|
||||
|
@ -265,8 +269,11 @@ TEST(MozPromise, Chaining)
|
|||
p = p->Then(queue, __func__,
|
||||
[] (int aVal) {
|
||||
EXPECT_EQ(aVal, 42);
|
||||
return TestPromise::CreateAndResolve(aVal, __func__);
|
||||
},
|
||||
[] () {}
|
||||
[] (double aVal) {
|
||||
return TestPromise::CreateAndReject(aVal, __func__);
|
||||
}
|
||||
);
|
||||
|
||||
if (i == kIterations / 2) {
|
||||
|
|
|
@ -173,8 +173,12 @@ public:
|
|||
iter.Remove();
|
||||
}
|
||||
RefPtr<SamplesWaitingForKey> k = mSamplesWaitingForKey;
|
||||
return mDecoder->Flush()->Then(mTaskQueue, __func__,
|
||||
[k]() { k->Flush(); });
|
||||
return mDecoder->Flush()->Then(
|
||||
mTaskQueue, __func__,
|
||||
[k]() {
|
||||
k->Flush();
|
||||
return FlushPromise::CreateAndResolve(true, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<DecodePromise> Drain() override
|
||||
|
|
|
@ -241,8 +241,9 @@ OmxDataDecoder::DoAsyncShutdown()
|
|||
LOGL("DoAsyncShutdown: flush complete");
|
||||
return self->mOmxLayer->SendCommand(OMX_CommandStateSet, OMX_StateIdle, nullptr);
|
||||
},
|
||||
[self] () {
|
||||
[self] (const OmxCommandFailureHolder& aError) {
|
||||
self->mOmxLayer->Shutdown();
|
||||
return OmxCommandPromise::CreateAndReject(aError, __func__);
|
||||
})
|
||||
->Then(mOmxTaskQueue, __func__,
|
||||
[self] () -> RefPtr<OmxCommandPromise> {
|
||||
|
@ -263,8 +264,9 @@ OmxDataDecoder::DoAsyncShutdown()
|
|||
|
||||
return p;
|
||||
},
|
||||
[self] () {
|
||||
[self] (const OmxCommandFailureHolder& aError) {
|
||||
self->mOmxLayer->Shutdown();
|
||||
return OmxCommandPromise::CreateAndReject(aError, __func__);
|
||||
})
|
||||
->Then(mOmxTaskQueue, __func__,
|
||||
[self] () {
|
||||
|
@ -786,8 +788,9 @@ OmxDataDecoder::PortSettingsChanged()
|
|||
|
||||
return p;
|
||||
},
|
||||
[self] () {
|
||||
[self] (const OmxCommandFailureHolder& aError) {
|
||||
self->NotifyError(OMX_ErrorUndefined, __func__);
|
||||
return OmxCommandPromise::CreateAndReject(aError, __func__);
|
||||
})
|
||||
->Then(mOmxTaskQueue, __func__,
|
||||
[self] () {
|
||||
|
|
Загрузка…
Ссылка в новой задаче