зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1168008 - Replace 'Consumer' with 'Request' in MediaPromise naming. r=jww
I think this makes more sense, and it matches the naming convention that all of the consumers of this stuff are actually using.
This commit is contained in:
Родитель
f665db1eee
Коммит
80857671e7
|
@ -1019,7 +1019,7 @@ protected:
|
|||
|
||||
virtual void CallSeek(const SeekTarget& aTarget);
|
||||
|
||||
MediaPromiseConsumerHolder<SeekPromise> mSeekRequest;
|
||||
MediaPromiseRequestHolder<SeekPromise> mSeekRequest;
|
||||
|
||||
// True when seeking or otherwise moving the play position around in
|
||||
// such a manner that progress event data is inaccurate. This is set
|
||||
|
|
|
@ -841,7 +841,7 @@ public:
|
|||
private:
|
||||
MediaDecoderStateMachine* mSelf;
|
||||
nsRefPtr<MediaTimer> mMediaTimer;
|
||||
MediaPromiseConsumerHolder<mozilla::MediaTimerPromise> mRequest;
|
||||
MediaPromiseRequestHolder<mozilla::MediaTimerPromise> mRequest;
|
||||
TimeStamp mTarget;
|
||||
|
||||
} mDelayedScheduler;
|
||||
|
@ -1151,8 +1151,8 @@ protected:
|
|||
// Only one of a given pair of ({Audio,Video}DataPromise, WaitForDataPromise)
|
||||
// should exist at any given moment.
|
||||
|
||||
MediaPromiseConsumerHolder<MediaDecoderReader::AudioDataPromise> mAudioDataRequest;
|
||||
MediaPromiseConsumerHolder<MediaDecoderReader::WaitForDataPromise> mAudioWaitRequest;
|
||||
MediaPromiseRequestHolder<MediaDecoderReader::AudioDataPromise> mAudioDataRequest;
|
||||
MediaPromiseRequestHolder<MediaDecoderReader::WaitForDataPromise> mAudioWaitRequest;
|
||||
const char* AudioRequestStatus()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
|
@ -1165,8 +1165,8 @@ protected:
|
|||
return "idle";
|
||||
}
|
||||
|
||||
MediaPromiseConsumerHolder<MediaDecoderReader::WaitForDataPromise> mVideoWaitRequest;
|
||||
MediaPromiseConsumerHolder<MediaDecoderReader::VideoDataPromise> mVideoDataRequest;
|
||||
MediaPromiseRequestHolder<MediaDecoderReader::WaitForDataPromise> mVideoWaitRequest;
|
||||
MediaPromiseRequestHolder<MediaDecoderReader::VideoDataPromise> mVideoDataRequest;
|
||||
const char* VideoRequestStatus()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
|
@ -1179,7 +1179,7 @@ protected:
|
|||
return "idle";
|
||||
}
|
||||
|
||||
MediaPromiseConsumerHolder<MediaDecoderReader::WaitForDataPromise>& WaitRequestRef(MediaData::Type aType)
|
||||
MediaPromiseRequestHolder<MediaDecoderReader::WaitForDataPromise>& WaitRequestRef(MediaData::Type aType)
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
return aType == MediaData::AUDIO_DATA ? mAudioWaitRequest : mVideoWaitRequest;
|
||||
|
@ -1255,7 +1255,7 @@ protected:
|
|||
bool mDecodeToSeekTarget;
|
||||
|
||||
// Track the current seek promise made by the reader.
|
||||
MediaPromiseConsumerHolder<MediaDecoderReader::SeekPromise> mSeekRequest;
|
||||
MediaPromiseRequestHolder<MediaDecoderReader::SeekPromise> mSeekRequest;
|
||||
|
||||
// We record the playback position before we seek in order to
|
||||
// determine where the seek terminated relative to the playback position
|
||||
|
@ -1263,7 +1263,7 @@ protected:
|
|||
int64_t mCurrentTimeBeforeSeek;
|
||||
|
||||
// Track our request for metadata from the reader.
|
||||
MediaPromiseConsumerHolder<MediaDecoderReader::MetadataPromise> mMetadataRequest;
|
||||
MediaPromiseRequestHolder<MediaDecoderReader::MetadataPromise> mMetadataRequest;
|
||||
|
||||
// Stores presentation info required for playback. The decoder monitor
|
||||
// must be held when accessing this.
|
||||
|
|
|
@ -224,7 +224,7 @@ private:
|
|||
|
||||
// Queued demux samples waiting to be decoded.
|
||||
nsTArray<nsRefPtr<MediaRawData>> mQueuedSamples;
|
||||
MediaPromiseConsumerHolder<MediaTrackDemuxer::SamplesPromise> mDemuxRequest;
|
||||
MediaPromiseRequestHolder<MediaTrackDemuxer::SamplesPromise> mDemuxRequest;
|
||||
MediaPromiseHolder<WaitForDataPromise> mWaitingPromise;
|
||||
bool HasWaitingPromise()
|
||||
{
|
||||
|
@ -316,7 +316,7 @@ private:
|
|||
// Demuxer objects.
|
||||
void OnDemuxerInitDone(nsresult);
|
||||
void OnDemuxerInitFailed(DemuxerFailureReason aFailure);
|
||||
MediaPromiseConsumerHolder<MediaDataDemuxer::InitPromise> mDemuxerInitRequest;
|
||||
MediaPromiseRequestHolder<MediaDataDemuxer::InitPromise> mDemuxerInitRequest;
|
||||
void OnDemuxFailed(TrackType aTrack, DemuxerFailureReason aFailure);
|
||||
|
||||
void DoDemuxVideo();
|
||||
|
@ -334,7 +334,7 @@ private:
|
|||
}
|
||||
|
||||
void SkipVideoDemuxToNextKeyFrame(media::TimeUnit aTimeThreshold);
|
||||
MediaPromiseConsumerHolder<MediaTrackDemuxer::SkipAccessPointPromise> mSkipRequest;
|
||||
MediaPromiseRequestHolder<MediaTrackDemuxer::SkipAccessPointPromise> mSkipRequest;
|
||||
void OnVideoSkipCompleted(uint32_t aSkipped);
|
||||
void OnVideoSkipFailed(MediaTrackDemuxer::SkipFailureHolder aFailure);
|
||||
|
||||
|
@ -382,8 +382,8 @@ private:
|
|||
}
|
||||
// Temporary seek information while we wait for the data
|
||||
Maybe<media::TimeUnit> mPendingSeekTime;
|
||||
MediaPromiseConsumerHolder<MediaTrackDemuxer::SeekPromise> mVideoSeekRequest;
|
||||
MediaPromiseConsumerHolder<MediaTrackDemuxer::SeekPromise> mAudioSeekRequest;
|
||||
MediaPromiseRequestHolder<MediaTrackDemuxer::SeekPromise> mVideoSeekRequest;
|
||||
MediaPromiseRequestHolder<MediaTrackDemuxer::SeekPromise> mAudioSeekRequest;
|
||||
MediaPromiseHolder<SeekPromise> mSeekPromise;
|
||||
|
||||
#ifdef MOZ_EME
|
||||
|
|
|
@ -140,7 +140,7 @@ protected:
|
|||
explicit MediaPromise(const char* aCreationSite)
|
||||
: mCreationSite(aCreationSite)
|
||||
, mMutex("MediaPromise Mutex")
|
||||
, mHaveConsumer(false)
|
||||
, mHaveRequest(false)
|
||||
{
|
||||
PROMISE_LOG("%s creating MediaPromise (%p)", mCreationSite, this);
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ public:
|
|||
return Move(p);
|
||||
}
|
||||
|
||||
class Consumer : public MediaPromiseRefcountable
|
||||
class Request : public MediaPromiseRefcountable
|
||||
{
|
||||
public:
|
||||
virtual void Disconnect() = 0;
|
||||
|
@ -184,8 +184,8 @@ public:
|
|||
virtual MediaPromise* CompletionPromise() = 0;
|
||||
|
||||
protected:
|
||||
Consumer() : mComplete(false), mDisconnected(false) {}
|
||||
virtual ~Consumer() {}
|
||||
Request() : mComplete(false), mDisconnected(false) {}
|
||||
virtual ~Request() {}
|
||||
|
||||
bool mComplete;
|
||||
bool mDisconnected;
|
||||
|
@ -199,7 +199,7 @@ protected:
|
|||
* resolved or rejected, a {Resolve,Reject}Runnable is dispatched, which
|
||||
* invokes the resolve/reject method and then deletes the ThenValue.
|
||||
*/
|
||||
class ThenValueBase : public Consumer
|
||||
class ThenValueBase : public Request
|
||||
{
|
||||
public:
|
||||
class ResolveOrRejectRunnable : public nsRunnable
|
||||
|
@ -233,7 +233,7 @@ protected:
|
|||
MediaPromise* CompletionPromise() override
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(mResponseTarget->IsCurrentThreadIn());
|
||||
MOZ_DIAGNOSTIC_ASSERT(!Consumer::mComplete);
|
||||
MOZ_DIAGNOSTIC_ASSERT(!Request::mComplete);
|
||||
if (!mCompletionPromise) {
|
||||
mCompletionPromise = new MediaPromise::Private("<completion promise>");
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ protected:
|
|||
aPromise->mValue.IsResolve() ? "Resolving" : "Rejecting", ThenValueBase::mCallSite,
|
||||
runnable.get(), aPromise, this);
|
||||
|
||||
// Promise consumers are allowed to disconnect the Consumer object and
|
||||
// Promise consumers are allowed to disconnect the Request object and
|
||||
// then shut down the thread or task queue that the promise result would
|
||||
// be dispatched on. So we unfortunately can't assert that promise
|
||||
// dispatch succeeds. :-(
|
||||
|
@ -261,8 +261,8 @@ protected:
|
|||
virtual void Disconnect() override
|
||||
{
|
||||
MOZ_ASSERT(ThenValueBase::mResponseTarget->IsCurrentThreadIn());
|
||||
MOZ_DIAGNOSTIC_ASSERT(!Consumer::mComplete);
|
||||
Consumer::mDisconnected = true;
|
||||
MOZ_DIAGNOSTIC_ASSERT(!Request::mComplete);
|
||||
Request::mDisconnected = true;
|
||||
|
||||
// We could support rejecting the completion promise on disconnection, but
|
||||
// then we'd need to have some sort of default reject value. The use cases
|
||||
|
@ -276,8 +276,8 @@ protected:
|
|||
|
||||
void DoResolveOrReject(ResolveOrRejectValue& aValue)
|
||||
{
|
||||
Consumer::mComplete = true;
|
||||
if (Consumer::mDisconnected) {
|
||||
Request::mComplete = true;
|
||||
if (Request::mDisconnected) {
|
||||
PROMISE_LOG("ThenValue::DoResolveOrReject disconnected - bailing out [this=%p]", this);
|
||||
return;
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ protected:
|
|||
{
|
||||
ThenValueBase::Disconnect();
|
||||
|
||||
// If a Consumer has been disconnected, we don't guarantee that the
|
||||
// If a Request has been disconnected, we don't guarantee that the
|
||||
// resolve/reject runnable will be dispatched. Null out our refcounted
|
||||
// this-value now so that it's released predictably on the dispatch thread.
|
||||
mThisVal = nullptr;
|
||||
|
@ -422,7 +422,7 @@ protected:
|
|||
{
|
||||
ThenValueBase::Disconnect();
|
||||
|
||||
// If a Consumer has been disconnected, we don't guarantee that the
|
||||
// If a Request has been disconnected, we don't guarantee that the
|
||||
// resolve/reject runnable will be dispatched. Destroy our callbacks
|
||||
// now so that any references in closures are released predictable on
|
||||
// the dispatch thread.
|
||||
|
@ -466,8 +466,8 @@ public:
|
|||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
MOZ_ASSERT(aResponseThread->IsDispatchReliable());
|
||||
MOZ_DIAGNOSTIC_ASSERT(!IsExclusive || !mHaveConsumer);
|
||||
mHaveConsumer = true;
|
||||
MOZ_DIAGNOSTIC_ASSERT(!IsExclusive || !mHaveRequest);
|
||||
mHaveRequest = true;
|
||||
PROMISE_LOG("%s invoking Then() [this=%p, aThenValue=%p, isPending=%d]",
|
||||
aCallSite, this, aThenValue, (int) IsPending());
|
||||
if (!IsPending()) {
|
||||
|
@ -480,30 +480,30 @@ public:
|
|||
public:
|
||||
|
||||
template<typename ThisType, typename ResolveMethodType, typename RejectMethodType>
|
||||
nsRefPtr<Consumer> Then(AbstractThread* aResponseThread, const char* aCallSite, ThisType* aThisVal,
|
||||
ResolveMethodType aResolveMethod, RejectMethodType aRejectMethod)
|
||||
nsRefPtr<Request> Then(AbstractThread* aResponseThread, const char* aCallSite, ThisType* aThisVal,
|
||||
ResolveMethodType aResolveMethod, RejectMethodType aRejectMethod)
|
||||
{
|
||||
nsRefPtr<ThenValueBase> thenValue = new MethodThenValue<ThisType, ResolveMethodType, RejectMethodType>(
|
||||
aResponseThread, aThisVal, aResolveMethod, aRejectMethod, aCallSite);
|
||||
ThenInternal(aResponseThread, thenValue, aCallSite);
|
||||
return thenValue.forget(); // Implicit conversion from already_AddRefed<ThenValueBase> to nsRefPtr<Consumer>.
|
||||
return thenValue.forget(); // Implicit conversion from already_AddRefed<ThenValueBase> to nsRefPtr<Request>.
|
||||
}
|
||||
|
||||
template<typename ResolveFunction, typename RejectFunction>
|
||||
nsRefPtr<Consumer> Then(AbstractThread* aResponseThread, const char* aCallSite,
|
||||
ResolveFunction&& aResolveFunction, RejectFunction&& aRejectFunction)
|
||||
nsRefPtr<Request> Then(AbstractThread* aResponseThread, const char* aCallSite,
|
||||
ResolveFunction&& aResolveFunction, RejectFunction&& aRejectFunction)
|
||||
{
|
||||
nsRefPtr<ThenValueBase> thenValue = new FunctionThenValue<ResolveFunction, RejectFunction>(aResponseThread,
|
||||
Move(aResolveFunction), Move(aRejectFunction), aCallSite);
|
||||
ThenInternal(aResponseThread, thenValue, aCallSite);
|
||||
return thenValue.forget(); // Implicit conversion from already_AddRefed<ThenValueBase> to nsRefPtr<Consumer>.
|
||||
return thenValue.forget(); // Implicit conversion from already_AddRefed<ThenValueBase> to nsRefPtr<Request>.
|
||||
}
|
||||
|
||||
void ChainTo(already_AddRefed<Private> aChainedPromise, const char* aCallSite)
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
MOZ_DIAGNOSTIC_ASSERT(!IsExclusive || !mHaveConsumer);
|
||||
mHaveConsumer = true;
|
||||
MOZ_DIAGNOSTIC_ASSERT(!IsExclusive || !mHaveRequest);
|
||||
mHaveRequest = true;
|
||||
nsRefPtr<Private> chainedPromise = aChainedPromise;
|
||||
PROMISE_LOG("%s invoking Chain() [this=%p, chainedPromise=%p, isPending=%d]",
|
||||
aCallSite, this, chainedPromise.get(), (int) IsPending());
|
||||
|
@ -553,7 +553,7 @@ protected:
|
|||
ResolveOrRejectValue mValue;
|
||||
nsTArray<nsRefPtr<ThenValueBase>> mThenValues;
|
||||
nsTArray<nsRefPtr<Private>> mChainedPromises;
|
||||
bool mHaveConsumer;
|
||||
bool mHaveRequest;
|
||||
};
|
||||
|
||||
template<typename ResolveValueT, typename RejectValueT, bool IsExclusive>
|
||||
|
@ -693,34 +693,34 @@ private:
|
|||
};
|
||||
|
||||
/*
|
||||
* Class to encapsulate a MediaPromise::Consumer reference. Use this as the member
|
||||
* Class to encapsulate a MediaPromise::Request reference. Use this as the member
|
||||
* variable for a class waiting on a media promise.
|
||||
*/
|
||||
template<typename PromiseType>
|
||||
class MediaPromiseConsumerHolder
|
||||
class MediaPromiseRequestHolder
|
||||
{
|
||||
public:
|
||||
MediaPromiseConsumerHolder() {}
|
||||
~MediaPromiseConsumerHolder() { MOZ_ASSERT(!mConsumer); }
|
||||
MediaPromiseRequestHolder() {}
|
||||
~MediaPromiseRequestHolder() { MOZ_ASSERT(!mRequest); }
|
||||
|
||||
void Begin(typename PromiseType::Consumer* aConsumer)
|
||||
void Begin(typename PromiseType::Request* aRequest)
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(!Exists());
|
||||
mConsumer = aConsumer;
|
||||
mRequest = aRequest;
|
||||
}
|
||||
|
||||
void Complete()
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(Exists());
|
||||
mConsumer = nullptr;
|
||||
mRequest = nullptr;
|
||||
}
|
||||
|
||||
// Disconnects and forgets an outstanding promise. The resolve/reject methods
|
||||
// will never be called.
|
||||
void Disconnect() {
|
||||
MOZ_ASSERT(Exists());
|
||||
mConsumer->Disconnect();
|
||||
mConsumer = nullptr;
|
||||
mRequest->Disconnect();
|
||||
mRequest = nullptr;
|
||||
}
|
||||
|
||||
void DisconnectIfExists() {
|
||||
|
@ -729,10 +729,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
bool Exists() { return !!mConsumer; }
|
||||
bool Exists() { return !!mRequest; }
|
||||
|
||||
private:
|
||||
nsRefPtr<typename PromiseType::Consumer> mConsumer;
|
||||
nsRefPtr<typename PromiseType::Request> mRequest;
|
||||
};
|
||||
|
||||
// Proxy Media Calls.
|
||||
|
|
|
@ -240,8 +240,8 @@ private:
|
|||
nsRefPtr<TrackBuffer> mAudioTrack;
|
||||
nsRefPtr<TrackBuffer> mVideoTrack;
|
||||
|
||||
MediaPromiseConsumerHolder<AudioDataPromise> mAudioRequest;
|
||||
MediaPromiseConsumerHolder<VideoDataPromise> mVideoRequest;
|
||||
MediaPromiseRequestHolder<AudioDataPromise> mAudioRequest;
|
||||
MediaPromiseRequestHolder<VideoDataPromise> mVideoRequest;
|
||||
|
||||
MediaPromiseHolder<AudioDataPromise> mAudioPromise;
|
||||
MediaPromiseHolder<VideoDataPromise> mVideoPromise;
|
||||
|
@ -261,8 +261,8 @@ private:
|
|||
int64_t mLastAudioTime;
|
||||
int64_t mLastVideoTime;
|
||||
|
||||
MediaPromiseConsumerHolder<SeekPromise> mAudioSeekRequest;
|
||||
MediaPromiseConsumerHolder<SeekPromise> mVideoSeekRequest;
|
||||
MediaPromiseRequestHolder<SeekPromise> mAudioSeekRequest;
|
||||
MediaPromiseRequestHolder<SeekPromise> mVideoSeekRequest;
|
||||
MediaPromiseHolder<SeekPromise> mSeekPromise;
|
||||
|
||||
// Temporary seek information while we wait for the data
|
||||
|
|
|
@ -186,7 +186,7 @@ private:
|
|||
// aborted and another AppendData queued.
|
||||
uint32_t mUpdateID;
|
||||
|
||||
MediaPromiseConsumerHolder<TrackBufferAppendPromise> mPendingAppend;
|
||||
MediaPromiseRequestHolder<TrackBufferAppendPromise> mPendingAppend;
|
||||
const nsCString mType;
|
||||
};
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ private:
|
|||
|
||||
MediaPromiseHolder<TrackBufferAppendPromise> mInitializationPromise;
|
||||
// Track our request for metadata from the reader.
|
||||
MediaPromiseConsumerHolder<MediaDecoderReader::MetadataPromise> mMetadataRequest;
|
||||
MediaPromiseRequestHolder<MediaDecoderReader::MetadataPromise> mMetadataRequest;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -651,7 +651,7 @@ MediaCodecReader::AsyncReadMetadata()
|
|||
|
||||
nsRefPtr<MediaCodecReader> self = this;
|
||||
mMediaResourceRequest.Begin(CreateMediaCodecs()
|
||||
->RefableThen(GetTaskQueue(), __func__,
|
||||
->Then(GetTaskQueue(), __func__,
|
||||
[self] (bool) -> void {
|
||||
self->mMediaResourceRequest.Complete();
|
||||
self->HandleResourceAllocated();
|
||||
|
|
|
@ -182,7 +182,7 @@ protected:
|
|||
|
||||
MediaPromiseHolder<MediaDecoderReader::MetadataPromise> mMetadataPromise;
|
||||
// XXX Remove after bug 1168008 land.
|
||||
MediaPromiseConsumerHolder<MediaResourcePromise> mMediaResourceRequest;
|
||||
MediaPromiseRequestHolder<MediaResourcePromise> mMediaResourceRequest;
|
||||
MediaPromiseHolder<MediaResourcePromise> mMediaResourcePromise;
|
||||
|
||||
private:
|
||||
|
|
|
@ -251,7 +251,7 @@ MediaOmxReader::AsyncReadMetadata()
|
|||
|
||||
nsRefPtr<MediaOmxReader> self = this;
|
||||
mMediaResourceRequest.Begin(mOmxDecoder->AllocateMediaResources()
|
||||
->RefableThen(GetTaskQueue(), __func__,
|
||||
->Then(GetTaskQueue(), __func__,
|
||||
[self] (bool) -> void {
|
||||
self->mMediaResourceRequest.Complete();
|
||||
self->HandleResourceAllocated();
|
||||
|
|
|
@ -45,7 +45,7 @@ class MediaOmxReader : public MediaOmxCommonReader
|
|||
// AbstractMediaDecoder::mDecoder will be non-null.
|
||||
bool mIsShutdown;
|
||||
MediaPromiseHolder<MediaDecoderReader::MetadataPromise> mMetadataPromise;
|
||||
MediaPromiseConsumerHolder<MediaResourcePromise> mMediaResourceRequest;
|
||||
MediaPromiseRequestHolder<MediaResourcePromise> mMediaResourceRequest;
|
||||
protected:
|
||||
android::sp<android::OmxDecoder> mOmxDecoder;
|
||||
android::sp<android::MediaExtractor> mExtractor;
|
||||
|
|
Загрузка…
Ссылка в новой задаче