Bug 1184634 - Rename "TaskQueue()" accessor to "OwnerThread()". r=gerald

Otherwise this name will collide with the rename of MediaTaskQueue to TaskQueue.
It's also a better naming convention, because it generalizes to things that are
owned by an AbstractThread that is not a Task Queue.

We rename to Queue() in TestMozPromise, because that's more accurate.
This commit is contained in:
Bobby Holley 2015-07-16 11:31:21 -07:00
parent 407d2c5f90
commit 78001ffc43
17 changed files with 105 additions and 105 deletions

View File

@ -235,7 +235,7 @@ void MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity)
mDecoderStateMachine,
&MediaDecoderStateMachine::SetDormant,
true);
mDecoderStateMachine->TaskQueue()->Dispatch(event.forget());
mDecoderStateMachine->OwnerThread()->Dispatch(event.forget());
if (IsEnded()) {
mWasEndedWhenEnteredDormant = true;
@ -251,7 +251,7 @@ void MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity)
mDecoderStateMachine,
&MediaDecoderStateMachine::SetDormant,
false);
mDecoderStateMachine->TaskQueue()->Dispatch(event.forget());
mDecoderStateMachine->OwnerThread()->Dispatch(event.forget());
}
}
@ -623,7 +623,7 @@ void MediaDecoder::CallSeek(const SeekTarget& aTarget)
{
MOZ_ASSERT(NS_IsMainThread());
mSeekRequest.DisconnectIfExists();
mSeekRequest.Begin(ProxyMediaCall(mDecoderStateMachine->TaskQueue(),
mSeekRequest.Begin(ProxyMediaCall(mDecoderStateMachine->OwnerThread(),
mDecoderStateMachine.get(), __func__,
&MediaDecoderStateMachine::Seek, aTarget)
->Then(AbstractThread::MainThread(), __func__, this,
@ -1376,7 +1376,7 @@ MediaDecoder::NotifyWaitingForResourcesStatusChanged()
RefPtr<nsRunnable> task =
NS_NewRunnableMethod(mDecoderStateMachine,
&MediaDecoderStateMachine::NotifyWaitingForResourcesStatusChanged);
mDecoderStateMachine->TaskQueue()->Dispatch(task.forget());
mDecoderStateMachine->OwnerThread()->Dispatch(task.forget());
}
}

View File

@ -166,7 +166,7 @@ MediaDecoderReader::DecodeToFirstVideoData()
}, [self] () -> bool {
MOZ_ASSERT(self->OnTaskQueue());
return self->VideoQueue().GetSize();
})->Then(TaskQueue(), __func__, [self, p] () {
})->Then(OwnerThread(), __func__, [self, p] () {
p->Resolve(self->VideoQueue().PeekFront(), __func__);
}, [p] () {
// We don't have a way to differentiate EOS, error, and shutdown here. :-(
@ -207,7 +207,7 @@ MediaDecoderReader::ThrottledNotifyDataArrived(const Interval<int64_t>& aInterva
nsRefPtr<MediaDecoderReader> self = this;
mThrottledNotify.Begin(
mTimer->WaitUntil(mLastThrottledNotify + mThrottleDuration, __func__)
->Then(TaskQueue(), __func__,
->Then(OwnerThread(), __func__,
[self] () -> void {
self->mThrottledNotify.Complete();
NS_ENSURE_TRUE_VOID(!self->mShutdown);

View File

@ -115,7 +115,7 @@ public:
virtual bool OnTaskQueue()
{
return TaskQueue()->IsCurrentThreadIn();
return OwnerThread()->IsCurrentThreadIn();
}
// Resets all state related to decoding, emptying all buffers etc.
@ -273,7 +273,7 @@ public:
NS_NewRunnableMethodWithArg<media::Interval<int64_t>>(this, aThrottleUpdates ? &MediaDecoderReader::ThrottledNotifyDataArrived
: &MediaDecoderReader::NotifyDataArrived,
media::Interval<int64_t>(aOffset, aOffset + aLength));
TaskQueue()->Dispatch(r.forget(), AbstractThread::DontAssertDispatchSuccess);
OwnerThread()->Dispatch(r.forget(), AbstractThread::DontAssertDispatchSuccess);
}
// Notify the reader that data from the resource was evicted (MediaSource only)
@ -307,10 +307,10 @@ public:
self->mStartTime.emplace(aStartTime);
self->UpdateBuffered();
});
TaskQueue()->Dispatch(r.forget());
OwnerThread()->Dispatch(r.forget());
}
MediaTaskQueue* TaskQueue() {
MediaTaskQueue* OwnerThread() {
return mTaskQueue;
}

View File

@ -734,7 +734,7 @@ MediaDecoderStateMachine::OnNotDecoded(MediaData::Type aType,
nsRefPtr<MediaDecoderStateMachine> self = this;
WaitRequestRef(aType).Begin(ProxyMediaCall(DecodeTaskQueue(), mReader.get(), __func__,
&MediaDecoderReader::WaitForData, aType)
->Then(TaskQueue(), __func__,
->Then(OwnerThread(), __func__,
[self] (MediaData::Type aType) -> void {
ReentrantMonitorAutoEnter mon(self->mDecoder->GetReentrantMonitor());
self->WaitRequestRef(aType).Complete();
@ -1304,7 +1304,7 @@ void MediaDecoderStateMachine::Shutdown()
// Put a task in the decode queue to shutdown the reader.
// the queue to spin down.
ProxyMediaCall(DecodeTaskQueue(), mReader.get(), __func__, &MediaDecoderReader::Shutdown)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaDecoderStateMachine::FinishShutdown,
&MediaDecoderStateMachine::FinishShutdown);
DECODER_LOG("Shutdown started");
@ -1491,7 +1491,7 @@ MediaDecoderStateMachine::EnqueueDecodeFirstFrameTask()
nsCOMPtr<nsIRunnable> task(
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::CallDecodeFirstFrame));
TaskQueue()->Dispatch(task.forget());
OwnerThread()->Dispatch(task.forget());
return NS_OK;
}
@ -1610,7 +1610,7 @@ MediaDecoderStateMachine::InitiateSeek()
mSeekRequest.Begin(ProxyMediaCall(DecodeTaskQueue(), mReader.get(), __func__,
&MediaDecoderReader::Seek, mCurrentSeek.mTarget.mTime,
Duration().ToMicroseconds())
->Then(TaskQueue(), __func__,
->Then(OwnerThread(), __func__,
[self] (int64_t) -> void {
ReentrantMonitorAutoEnter mon(self->mDecoder->GetReentrantMonitor());
self->mSeekRequest.Complete();
@ -1669,7 +1669,7 @@ MediaDecoderStateMachine::EnsureAudioDecodeTaskQueued()
mAudioDataRequest.Begin(ProxyMediaCall(DecodeTaskQueue(), mReader.get(),
__func__, &MediaDecoderReader::RequestAudioData)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaDecoderStateMachine::OnAudioDecoded,
&MediaDecoderStateMachine::OnAudioNotDecoded));
@ -1730,7 +1730,7 @@ MediaDecoderStateMachine::EnsureVideoDecodeTaskQueued()
mVideoDataRequest.Begin(ProxyMediaCall(DecodeTaskQueue(), mReader.get(), __func__,
&MediaDecoderReader::RequestVideoData,
skipToNextKeyFrame, currentTime, forceDecodeAhead)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaDecoderStateMachine::OnVideoDecoded,
&MediaDecoderStateMachine::OnVideoNotDecoded));
return NS_OK;
@ -1891,10 +1891,10 @@ MediaDecoderStateMachine::OnMetadataRead(MetadataHolder* aMetadata)
// Set up the start time rendezvous if it doesn't already exist (which is
// generally the case, unless we're coming out of dormant mode).
if (!mStartTimeRendezvous) {
mStartTimeRendezvous = new StartTimeRendezvous(TaskQueue(), HasAudio(), HasVideo(),
mStartTimeRendezvous = new StartTimeRendezvous(OwnerThread(), HasAudio(), HasVideo(),
mReader->ForceZeroStartTime() || IsRealTime());
mStartTimeRendezvous->AwaitStartTime()->Then(TaskQueue(), __func__,
mStartTimeRendezvous->AwaitStartTime()->Then(OwnerThread(), __func__,
[self] () -> void {
NS_ENSURE_TRUE_VOID(!self->IsShutdown());
self->mReader->DispatchSetStartTime(self->StartTime());
@ -1906,7 +1906,7 @@ MediaDecoderStateMachine::OnMetadataRead(MetadataHolder* aMetadata)
if (mInfo.mMetadataDuration.isSome()) {
RecomputeDuration();
} else if (mInfo.mUnadjustedMetadataEndTime.isSome()) {
mStartTimeRendezvous->AwaitStartTime()->Then(TaskQueue(), __func__,
mStartTimeRendezvous->AwaitStartTime()->Then(OwnerThread(), __func__,
[self] () -> void {
NS_ENSURE_TRUE_VOID(!self->IsShutdown());
TimeUnit unadjusted = self->mInfo.mUnadjustedMetadataEndTime.ref();
@ -2032,11 +2032,11 @@ MediaDecoderStateMachine::DecodeFirstFrame()
mAudioDataRequest.Begin(
ProxyMediaCall(DecodeTaskQueue(), mReader.get(), __func__,
&MediaDecoderReader::RequestAudioData)
->Then(TaskQueue(), __func__, mStartTimeRendezvous.get(),
->Then(OwnerThread(), __func__, mStartTimeRendezvous.get(),
&StartTimeRendezvous::ProcessFirstSample<AudioDataPromise>,
&StartTimeRendezvous::FirstSampleRejected<AudioData>)
->CompletionPromise()
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaDecoderStateMachine::OnAudioDecoded,
&MediaDecoderStateMachine::OnAudioNotDecoded)
);
@ -2046,11 +2046,11 @@ MediaDecoderStateMachine::DecodeFirstFrame()
mVideoDataRequest.Begin(
ProxyMediaCall(DecodeTaskQueue(), mReader.get(), __func__,
&MediaDecoderReader::RequestVideoData, false, int64_t(0), false)
->Then(TaskQueue(), __func__, mStartTimeRendezvous.get(),
->Then(OwnerThread(), __func__, mStartTimeRendezvous.get(),
&StartTimeRendezvous::ProcessFirstSample<VideoDataPromise>,
&StartTimeRendezvous::FirstSampleRejected<VideoData>)
->CompletionPromise()
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaDecoderStateMachine::OnVideoDecoded,
&MediaDecoderStateMachine::OnVideoNotDecoded));
}
@ -2265,10 +2265,10 @@ MediaDecoderStateMachine::FinishShutdown()
// state machine.
DECODER_LOG("Shutting down state machine task queue");
RefPtr<DecoderDisposer> disposer = new DecoderDisposer(mDecoder, this);
TaskQueue()->BeginShutdown()->Then(AbstractThread::MainThread(), __func__,
disposer.get(),
&DecoderDisposer::OnTaskQueueShutdown,
&DecoderDisposer::OnTaskQueueShutdown);
OwnerThread()->BeginShutdown()->Then(AbstractThread::MainThread(), __func__,
disposer.get(),
&DecoderDisposer::OnTaskQueueShutdown,
&DecoderDisposer::OnTaskQueueShutdown);
}
nsresult MediaDecoderStateMachine::RunStateMachine()
@ -2301,7 +2301,7 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
DECODER_LOG("Dispatching AsyncReadMetadata");
mMetadataRequest.Begin(ProxyMediaCall(DecodeTaskQueue(), mReader.get(), __func__,
&MediaDecoderReader::AsyncReadMetadata)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaDecoderStateMachine::OnMetadataRead,
&MediaDecoderStateMachine::OnMetadataNotRead));
@ -2965,7 +2965,7 @@ MediaDecoderStateMachine::ScheduleStateMachine()
nsCOMPtr<nsIRunnable> task =
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::RunStateMachine);
TaskQueue()->Dispatch(task.forget());
OwnerThread()->Dispatch(task.forget());
}
void
@ -2999,7 +2999,7 @@ bool MediaDecoderStateMachine::OnDecodeTaskQueue() const
bool MediaDecoderStateMachine::OnTaskQueue() const
{
return TaskQueue()->IsCurrentThreadIn();
return OwnerThread()->IsCurrentThreadIn();
}
bool MediaDecoderStateMachine::IsStateMachineScheduled() const
@ -3154,7 +3154,7 @@ void MediaDecoderStateMachine::DispatchAudioCaptured()
self->ScheduleStateMachine();
}
});
TaskQueue()->Dispatch(r.forget());
OwnerThread()->Dispatch(r.forget());
}
void MediaDecoderStateMachine::AddOutputStream(ProcessedMediaStream* aStream,

View File

@ -168,7 +168,7 @@ public:
{
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::Shutdown);
TaskQueue()->Dispatch(runnable.forget());
OwnerThread()->Dispatch(runnable.forget());
}
void FinishShutdown();
@ -208,7 +208,7 @@ public:
{
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::StartBuffering);
TaskQueue()->Dispatch(runnable.forget());
OwnerThread()->Dispatch(runnable.forget());
}
// This is called on the state machine thread and audio thread.
@ -264,7 +264,7 @@ public:
}
// Returns the state machine task queue.
MediaTaskQueue* TaskQueue() const { return mTaskQueue; }
MediaTaskQueue* OwnerThread() const { return mTaskQueue; }
// Calls ScheduleStateMachine() after taking the decoder lock. Also
// notifies the decoder thread in case it's waiting on the decoder lock.
@ -280,7 +280,7 @@ public:
{
nsCOMPtr<nsIRunnable> task =
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::RunStateMachine);
TaskQueue()->Dispatch(task.forget());
OwnerThread()->Dispatch(task.forget());
}
// Invokes ScheduleStateMachine to run in |aMicroseconds| microseconds,
@ -305,7 +305,7 @@ public:
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([self, aEndTime] () {
self->mFragmentEndTime = aEndTime;
});
TaskQueue()->Dispatch(r.forget());
OwnerThread()->Dispatch(r.forget());
}
// Drop reference to decoder. Only called during shutdown dance.
@ -359,7 +359,7 @@ public:
// have the intended effect.
MOZ_DIAGNOSTIC_ASSERT(self->mPlayState == MediaDecoder::PLAY_STATE_LOADING);
});
TaskQueue()->Dispatch(r.forget());
OwnerThread()->Dispatch(r.forget());
}
void OnAudioDecoded(AudioData* aSample);
@ -667,7 +667,7 @@ public:
{
RefPtr<nsRunnable> r =
NS_NewRunnableMethodWithArg<int64_t>(this, &MediaDecoderStateMachine::OnPlaybackOffsetUpdate, aPlaybackOffset);
TaskQueue()->Dispatch(r.forget());
OwnerThread()->Dispatch(r.forget());
}
private:
@ -679,7 +679,7 @@ public:
{
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::OnAudioSinkComplete);
TaskQueue()->Dispatch(runnable.forget());
OwnerThread()->Dispatch(runnable.forget());
}
private:
@ -690,7 +690,7 @@ private:
{
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::OnAudioSinkError);
TaskQueue()->Dispatch(runnable.forget());
OwnerThread()->Dispatch(runnable.forget());
}
// Return true if the video decoder's decode speed can not catch up the
@ -751,7 +751,7 @@ private:
Reset();
mTarget = aTarget;
mRequest.Begin(mMediaTimer->WaitUntil(mTarget, __func__)->Then(
mSelf->TaskQueue(), __func__, mSelf,
mSelf->OwnerThread(), __func__, mSelf,
&MediaDecoderStateMachine::OnDelayedSchedule,
&MediaDecoderStateMachine::NotReached));
}
@ -920,7 +920,7 @@ private:
// The task queue in which we run decode tasks. This is referred to as
// the "decode thread", though in practise tasks can run on a different
// thread every time they're called.
MediaTaskQueue* DecodeTaskQueue() const { return mReader->TaskQueue(); }
MediaTaskQueue* DecodeTaskQueue() const { return mReader->OwnerThread(); }
// The time that playback started from the system clock. This is used for
// timing the presentation of video frames when there's no audio.

View File

@ -286,7 +286,7 @@ MediaFormatReader::AsyncReadMetadata()
nsRefPtr<MetadataPromise> p = mMetadataPromise.Ensure(__func__);
mDemuxerInitRequest.Begin(mDemuxer->Init()
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaFormatReader::OnDemuxerInitDone,
&MediaFormatReader::OnDemuxerInitFailed));
return p;
@ -609,7 +609,7 @@ MediaFormatReader::DoDemuxVideo()
{
// TODO Use DecodeAhead value rather than 1.
mVideo.mDemuxRequest.Begin(mVideo.mTrackDemuxer->GetSamples(1)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaFormatReader::OnVideoDemuxCompleted,
&MediaFormatReader::OnVideoDemuxFailed));
}
@ -666,7 +666,7 @@ MediaFormatReader::DoDemuxAudio()
{
// TODO Use DecodeAhead value rather than 1.
mAudio.mDemuxRequest.Begin(mAudio.mTrackDemuxer->GetSamples(1)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaFormatReader::OnAudioDemuxCompleted,
&MediaFormatReader::OnAudioDemuxFailed));
}
@ -788,7 +788,7 @@ MediaFormatReader::ScheduleUpdate(TrackType aTrack)
decoder.mUpdateScheduled = true;
RefPtr<nsIRunnable> task(
NS_NewRunnableMethodWithArg<TrackType>(this, &MediaFormatReader::Update, aTrack));
TaskQueue()->Dispatch(task.forget());
OwnerThread()->Dispatch(task.forget());
}
bool
@ -921,7 +921,7 @@ MediaFormatReader::DecodeDemuxedSamples(TrackType aTrack,
decoder.mTimeThreshold = Some(TimeUnit::FromMicroseconds(sample->mTime));
nsRefPtr<MediaFormatReader> self = this;
decoder.mSeekRequest.Begin(decoder.mTrackDemuxer->Seek(decoder.mTimeThreshold.ref())
->Then(TaskQueue(), __func__,
->Then(OwnerThread(), __func__,
[self, aTrack] (media::TimeUnit aTime) {
auto& decoder = self->GetDecoderData(aTrack);
decoder.mSeekRequest.Complete();
@ -1187,7 +1187,7 @@ MediaFormatReader::Output(TrackType aTrack, MediaData* aSample)
RefPtr<nsIRunnable> task =
NS_NewRunnableMethodWithArgs<TrackType, MediaData*>(
this, &MediaFormatReader::NotifyNewOutput, aTrack, aSample);
TaskQueue()->Dispatch(task.forget());
OwnerThread()->Dispatch(task.forget());
}
void
@ -1196,7 +1196,7 @@ MediaFormatReader::DrainComplete(TrackType aTrack)
RefPtr<nsIRunnable> task =
NS_NewRunnableMethodWithArg<TrackType>(
this, &MediaFormatReader::NotifyDrainComplete, aTrack);
TaskQueue()->Dispatch(task.forget());
OwnerThread()->Dispatch(task.forget());
}
void
@ -1205,7 +1205,7 @@ MediaFormatReader::InputExhausted(TrackType aTrack)
RefPtr<nsIRunnable> task =
NS_NewRunnableMethodWithArg<TrackType>(
this, &MediaFormatReader::NotifyInputExhausted, aTrack);
TaskQueue()->Dispatch(task.forget());
OwnerThread()->Dispatch(task.forget());
}
void
@ -1214,7 +1214,7 @@ MediaFormatReader::Error(TrackType aTrack)
RefPtr<nsIRunnable> task =
NS_NewRunnableMethodWithArg<TrackType>(
this, &MediaFormatReader::NotifyError, aTrack);
TaskQueue()->Dispatch(task.forget());
OwnerThread()->Dispatch(task.forget());
}
void
@ -1251,7 +1251,7 @@ MediaFormatReader::SkipVideoDemuxToNextKeyFrame(media::TimeUnit aTimeThreshold)
}
mSkipRequest.Begin(mVideo.mTrackDemuxer->SkipToNextRandomAccessPoint(aTimeThreshold)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaFormatReader::OnVideoSkipCompleted,
&MediaFormatReader::OnVideoSkipFailed));
return;
@ -1368,7 +1368,7 @@ MediaFormatReader::DoVideoSeek()
LOGV("Seeking video to %lld", mPendingSeekTime.ref().ToMicroseconds());
media::TimeUnit seekTime = mPendingSeekTime.ref();
mVideo.mSeekRequest.Begin(mVideo.mTrackDemuxer->Seek(seekTime)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaFormatReader::OnVideoSeekCompleted,
&MediaFormatReader::OnVideoSeekFailed));
}
@ -1396,7 +1396,7 @@ MediaFormatReader::DoAudioSeek()
LOGV("Seeking audio to %lld", mPendingSeekTime.ref().ToMicroseconds());
media::TimeUnit seekTime = mPendingSeekTime.ref();
mAudio.mSeekRequest.Begin(mAudio.mTrackDemuxer->Seek(seekTime)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaFormatReader::OnAudioSeekCompleted,
&MediaFormatReader::OnAudioSeekFailed));
}

View File

@ -336,7 +336,7 @@ AndroidMediaReader::Seek(int64_t aTarget, int64_t aEndTime)
mVideoSeekTimeUs = aTarget;
nsRefPtr<AndroidMediaReader> self = this;
mSeekRequest.Begin(DecodeToFirstVideoData()->Then(TaskQueue(), __func__, [self] (VideoData* v) {
mSeekRequest.Begin(DecodeToFirstVideoData()->Then(OwnerThread(), __func__, [self] (VideoData* v) {
self->mSeekRequest.Complete();
self->mAudioSeekTimeUs = v->mTime;
self->mSeekPromise.Resolve(self->mAudioSeekTimeUs, __func__);

View File

@ -647,7 +647,7 @@ MP4Reader::ScheduleUpdate(TrackType aTrack)
decoder.mUpdateScheduled = true;
RefPtr<nsIRunnable> task(
NS_NewRunnableMethodWithArg<TrackType>(this, &MP4Reader::Update, aTrack));
TaskQueue()->Dispatch(task.forget());
OwnerThread()->Dispatch(task.forget());
}
bool

View File

@ -53,7 +53,7 @@ private:
virtual ~TestBinding()
{
{
nsRefPtr<MediaTaskQueue> queue = reader->TaskQueue();
nsRefPtr<MediaTaskQueue> queue = reader->OwnerThread();
nsCOMPtr<nsIRunnable> task = NS_NewRunnableMethod(reader, &MP4Reader::Shutdown);
// Hackily bypass the tail dispatcher so that we can AwaitShutdownAndIdle.
// In production code we'd use BeginShutdown + promises.

View File

@ -27,7 +27,7 @@ public:
mTaskQueue->AwaitShutdownAndIdle();
}
MediaTaskQueue* TaskQueue() { return mTaskQueue; }
MediaTaskQueue* Queue() { return mTaskQueue; }
private:
nsRefPtr<MediaTaskQueue> mTaskQueue;
};
@ -91,7 +91,7 @@ RunOnTaskQueue(MediaTaskQueue* aQueue, FunctionType aFun)
TEST(MozPromise, BasicResolve)
{
AutoTaskQueue atq;
nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue();
nsRefPtr<MediaTaskQueue> queue = atq.Queue();
RunOnTaskQueue(queue, [queue] () -> void {
TestPromise::CreateAndResolve(42, __func__)->Then(queue, __func__,
[queue] (int aResolveValue) -> void { EXPECT_EQ(aResolveValue, 42); queue->BeginShutdown(); },
@ -102,7 +102,7 @@ TEST(MozPromise, BasicResolve)
TEST(MozPromise, BasicReject)
{
AutoTaskQueue atq;
nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue();
nsRefPtr<MediaTaskQueue> queue = atq.Queue();
RunOnTaskQueue(queue, [queue] () -> void {
TestPromise::CreateAndReject(42.0, __func__)->Then(queue, __func__,
DO_FAIL,
@ -113,7 +113,7 @@ TEST(MozPromise, BasicReject)
TEST(MozPromise, AsyncResolve)
{
AutoTaskQueue atq;
nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue();
nsRefPtr<MediaTaskQueue> queue = atq.Queue();
RunOnTaskQueue(queue, [queue] () -> void {
nsRefPtr<TestPromise::Private> p = new TestPromise::Private(__func__);
@ -143,7 +143,7 @@ TEST(MozPromise, CompletionPromises)
{
bool invokedPass = false;
AutoTaskQueue atq;
nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue();
nsRefPtr<MediaTaskQueue> queue = atq.Queue();
RunOnTaskQueue(queue, [queue, &invokedPass] () -> void {
TestPromise::CreateAndResolve(40, __func__)
->Then(queue, __func__,
@ -174,7 +174,7 @@ TEST(MozPromise, CompletionPromises)
TEST(MozPromise, PromiseAllResolve)
{
AutoTaskQueue atq;
nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue();
nsRefPtr<MediaTaskQueue> queue = atq.Queue();
RunOnTaskQueue(queue, [queue] () -> void {
nsTArray<nsRefPtr<TestPromise>> promises;
@ -198,7 +198,7 @@ TEST(MozPromise, PromiseAllResolve)
TEST(MozPromise, PromiseAllReject)
{
AutoTaskQueue atq;
nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue();
nsRefPtr<MediaTaskQueue> queue = atq.Queue();
RunOnTaskQueue(queue, [queue] () -> void {
nsTArray<nsRefPtr<TestPromise>> promises;

View File

@ -163,7 +163,7 @@ MediaSourceReader::RequestAudioData()
case SOURCE_NEW:
GetAudioReader()->ResetDecode();
mAudioSeekRequest.Begin(GetAudioReader()->Seek(GetReaderAudioTime(mLastAudioTime), 0)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaSourceReader::CompleteAudioSeekAndDoRequest,
&MediaSourceReader::CompleteAudioSeekAndRejectPromise));
break;
@ -188,7 +188,7 @@ MediaSourceReader::RequestAudioData()
void MediaSourceReader::DoAudioRequest()
{
mAudioRequest.Begin(GetAudioReader()->RequestAudioData()
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaSourceReader::OnAudioDecoded,
&MediaSourceReader::OnAudioNotDecoded));
}
@ -211,7 +211,7 @@ MediaSourceReader::OnAudioDecoded(AudioData* aSample)
MSE_DEBUG("mTime=%lld < mTimeThreshold=%lld",
ourTime, mTimeThreshold);
mAudioRequest.Begin(GetAudioReader()->RequestAudioData()
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaSourceReader::OnAudioDecoded,
&MediaSourceReader::OnAudioNotDecoded));
return;
@ -281,7 +281,7 @@ MediaSourceReader::OnAudioNotDecoded(NotDecodedReason aReason)
if (result == SOURCE_NEW) {
GetAudioReader()->ResetDecode();
mAudioSeekRequest.Begin(GetAudioReader()->Seek(GetReaderAudioTime(mLastAudioTime), 0)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaSourceReader::CompleteAudioSeekAndDoRequest,
&MediaSourceReader::CompleteAudioSeekAndRejectPromise));
return;
@ -339,7 +339,7 @@ MediaSourceReader::RequestVideoData(bool aSkipToNextKeyframe,
case SOURCE_NEW:
GetVideoReader()->ResetDecode();
mVideoSeekRequest.Begin(GetVideoReader()->Seek(GetReaderVideoTime(mLastVideoTime), 0)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaSourceReader::CompleteVideoSeekAndDoRequest,
&MediaSourceReader::CompleteVideoSeekAndRejectPromise));
break;
@ -368,7 +368,7 @@ MediaSourceReader::DoVideoRequest()
mVideoRequest.Begin(GetVideoReader()->RequestVideoData(mDropVideoBeforeThreshold,
GetReaderVideoTime(mTimeThreshold),
mForceVideoDecodeAhead)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaSourceReader::OnVideoDecoded,
&MediaSourceReader::OnVideoNotDecoded));
}
@ -438,7 +438,7 @@ MediaSourceReader::OnVideoNotDecoded(NotDecodedReason aReason)
if (result == SOURCE_NEW) {
GetVideoReader()->ResetDecode();
mVideoSeekRequest.Begin(GetVideoReader()->Seek(GetReaderVideoTime(mLastVideoTime), 0)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaSourceReader::CompleteVideoSeekAndDoRequest,
&MediaSourceReader::CompleteVideoSeekAndRejectPromise));
return;
@ -509,7 +509,7 @@ MediaSourceReader::ContinueShutdown()
{
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
if (mTrackBuffers.Length()) {
mTrackBuffers[0]->Shutdown()->Then(TaskQueue(), __func__, this,
mTrackBuffers[0]->Shutdown()->Then(OwnerThread(), __func__, this,
&MediaSourceReader::ContinueShutdown,
&MediaSourceReader::ContinueShutdown);
mShutdownTrackBuffers.AppendElement(mTrackBuffers[0]);
@ -742,7 +742,7 @@ MediaSourceReader::CreateSubDecoder(const nsACString& aType, int64_t aTimestampO
// borrowing.
nsRefPtr<SourceBufferDecoder> decoder =
new SourceBufferDecoder(new SourceBufferResource(aType), mDecoder, aTimestampOffset);
nsRefPtr<MediaDecoderReader> reader(CreateReaderForType(aType, decoder, TaskQueue()));
nsRefPtr<MediaDecoderReader> reader(CreateReaderForType(aType, decoder, OwnerThread()));
if (!reader) {
return nullptr;
}
@ -829,7 +829,7 @@ MediaSourceReader::NotifyTimeRangesChanged()
//post a task to the decode queue to try to complete the pending seek.
RefPtr<nsIRunnable> task(NS_NewRunnableMethod(
this, &MediaSourceReader::AttemptSeek));
TaskQueue()->Dispatch(task.forget());
OwnerThread()->Dispatch(task.forget());
} else {
MaybeNotifyHaveData();
}
@ -946,7 +946,7 @@ MediaSourceReader::DoAudioSeek()
}
GetAudioReader()->ResetDecode();
mAudioSeekRequest.Begin(GetAudioReader()->Seek(GetReaderAudioTime(seekTime), 0)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaSourceReader::OnAudioSeekCompleted,
&MediaSourceReader::OnAudioSeekFailed));
MSE_DEBUG("reader=%p", GetAudioReader());
@ -1018,7 +1018,7 @@ MediaSourceReader::DoVideoSeek()
}
GetVideoReader()->ResetDecode();
mVideoSeekRequest.Begin(GetVideoReader()->Seek(GetReaderVideoTime(seekTime), 0)
->Then(TaskQueue(), __func__, this,
->Then(OwnerThread(), __func__, this,
&MediaSourceReader::OnVideoSeekCompleted,
&MediaSourceReader::OnVideoSeekFailed));
MSE_DEBUG("reader=%p", GetVideoReader());
@ -1220,7 +1220,7 @@ MediaSourceReader::Ended(bool aEnded)
// seek or wait
RefPtr<nsIRunnable> task(NS_NewRunnableMethod(
this, &MediaSourceReader::NotifyTimeRangesChanged));
TaskQueue()->Dispatch(task.forget());
OwnerThread()->Dispatch(task.forget());
}
}

View File

@ -115,7 +115,7 @@ TrackBuffer::Shutdown()
RefPtr<MediaTaskQueue> queue = mTaskQueue;
mTaskQueue = nullptr;
queue->BeginShutdown()
->Then(mParentDecoder->GetReader()->TaskQueue(), __func__, this,
->Then(mParentDecoder->GetReader()->OwnerThread(), __func__, this,
&TrackBuffer::ContinueShutdown, &TrackBuffer::ContinueShutdown);
return p;
@ -127,7 +127,7 @@ TrackBuffer::ContinueShutdown()
ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
if (mDecoders.Length()) {
mDecoders[0]->GetReader()->Shutdown()
->Then(mParentDecoder->GetReader()->TaskQueue(), __func__, this,
->Then(mParentDecoder->GetReader()->OwnerThread(), __func__, this,
&TrackBuffer::ContinueShutdown, &TrackBuffer::ContinueShutdown);
mShutdownDecoders.AppendElement(mDecoders[0]);
mDecoders.RemoveElementAt(0);
@ -267,10 +267,10 @@ TrackBuffer::BufferAppend()
nsRefPtr<TrackBuffer> self = this;
ProxyMediaCall(mParentDecoder->GetReader()->TaskQueue(), this, __func__,
ProxyMediaCall(mParentDecoder->GetReader()->OwnerThread(), this, __func__,
&TrackBuffer::UpdateBufferedRanges,
mLastAppendRange, /* aNotifyParent */ true)
->Then(mParentDecoder->GetReader()->TaskQueue(), __func__,
->Then(mParentDecoder->GetReader()->OwnerThread(), __func__,
[self] {
self->mInitializationPromise.ResolveIfExists(self->HasInitSegment(), __func__);
},
@ -348,7 +348,7 @@ TrackBuffer::NotifyTimeRangesChanged()
RefPtr<nsIRunnable> task =
NS_NewRunnableMethod(mParentDecoder->GetReader(),
&MediaSourceReader::NotifyTimeRangesChanged);
mParentDecoder->GetReader()->TaskQueue()->Dispatch(task.forget());
mParentDecoder->GetReader()->OwnerThread()->Dispatch(task.forget());
}
void
@ -363,7 +363,7 @@ TrackBuffer::NotifyReaderDataRemoved(MediaDecoderReader* aReader)
reader->NotifyDataRemoved();
self->UpdateBufferedRanges(Interval<int64_t>(), /* aNotifyParent */ false);
});
aReader->TaskQueue()->Dispatch(task.forget());
aReader->OwnerThread()->Dispatch(task.forget());
}
class DecoderSorter
@ -677,7 +677,7 @@ TrackBuffer::NewDecoder(TimeUnit aTimestampOffset)
mLastEndTimestamp.reset();
mLastTimestampOffset = aTimestampOffset;
decoder->SetTaskQueue(decoder->GetReader()->TaskQueue());
decoder->SetTaskQueue(decoder->GetReader()->OwnerThread());
return decoder.forget();
}
@ -693,7 +693,7 @@ TrackBuffer::QueueInitializeDecoder(SourceBufferDecoder* aDecoder)
&TrackBuffer::InitializeDecoder,
aDecoder);
// We need to initialize the reader on its own task queue
aDecoder->GetReader()->TaskQueue()->Dispatch(task.forget());
aDecoder->GetReader()->OwnerThread()->Dispatch(task.forget());
return true;
}
@ -794,7 +794,7 @@ TrackBuffer::InitializeDecoder(SourceBufferDecoder* aDecoder)
return;
}
mMetadataRequest.Begin(promise->Then(reader->TaskQueue(), __func__,
mMetadataRequest.Begin(promise->Then(reader->OwnerThread(), __func__,
recipient.get(),
&MetadataRecipient::OnMetadataRead,
&MetadataRecipient::OnMetadataNotRead));
@ -865,7 +865,7 @@ void
TrackBuffer::OnMetadataNotRead(ReadMetadataFailureReason aReason,
SourceBufferDecoder* aDecoder)
{
MOZ_ASSERT(aDecoder->GetReader()->TaskQueue()->IsCurrentThreadIn());
MOZ_ASSERT(aDecoder->GetReader()->OwnerThread()->IsCurrentThreadIn());
mParentDecoder->GetReentrantMonitor().AssertNotCurrentThreadIn();
ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
@ -937,10 +937,10 @@ TrackBuffer::CompleteInitializeDecoder(SourceBufferDecoder* aDecoder)
MSE_DEBUG("Reader %p activated",
aDecoder->GetReader());
nsRefPtr<TrackBuffer> self = this;
ProxyMediaCall(mParentDecoder->GetReader()->TaskQueue(), this, __func__,
ProxyMediaCall(mParentDecoder->GetReader()->OwnerThread(), this, __func__,
&TrackBuffer::UpdateBufferedRanges,
Interval<int64_t>(), /* aNotifyParent */ true)
->Then(mParentDecoder->GetReader()->TaskQueue(), __func__,
->Then(mParentDecoder->GetReader()->OwnerThread(), __func__,
[self] {
self->mInitializationPromise.ResolveIfExists(self->HasInitSegment(), __func__);
},
@ -1196,7 +1196,7 @@ TrackBuffer::RemoveDecoder(SourceBufferDecoder* aDecoder)
// Remove associated buffered range from our cache.
mReadersBuffered.erase(aDecoder);
}
aDecoder->GetReader()->TaskQueue()->Dispatch(task.forget());
aDecoder->GetReader()->OwnerThread()->Dispatch(task.forget());
}
nsRefPtr<TrackBuffer::RangeRemovalPromise>
@ -1269,10 +1269,10 @@ TrackBuffer::RangeRemoval(TimeUnit aStart, TimeUnit aEnd)
// Make sure our buffered ranges got updated before resolving promise.
nsRefPtr<TrackBuffer> self = this;
ProxyMediaCall(mParentDecoder->GetReader()->TaskQueue(), this, __func__,
ProxyMediaCall(mParentDecoder->GetReader()->OwnerThread(), this, __func__,
&TrackBuffer::UpdateBufferedRanges,
Interval<int64_t>(), /* aNotifyParent */ false)
->Then(mParentDecoder->GetReader()->TaskQueue(), __func__,
->Then(mParentDecoder->GetReader()->OwnerThread(), __func__,
[self] {
self->mRangeRemovalPromise.ResolveIfExists(true, __func__);
},

View File

@ -682,7 +682,7 @@ MediaCodecReader::AsyncReadMetadata()
nsRefPtr<MediaCodecReader> self = this;
mMediaResourceRequest.Begin(CreateMediaCodecs()
->Then(TaskQueue(), __func__,
->Then(OwnerThread(), __func__,
[self] (bool) -> void {
self->mMediaResourceRequest.Complete();
self->HandleResourceAllocated();

View File

@ -121,7 +121,7 @@ MediaOmxCommonDecoder::PauseStateMachine()
GetStateMachine(),
&MediaDecoderStateMachine::SetDormant,
true);
GetStateMachine()->TaskQueue()->Dispatch(event.forget());
GetStateMachine()->OwnerThread()->Dispatch(event.forget());
}
void
@ -150,7 +150,7 @@ MediaOmxCommonDecoder::ResumeStateMachine()
GetStateMachine(),
&MediaDecoderStateMachine::Seek,
target);
GetStateMachine()->TaskQueue()->Dispatch(event.forget());
GetStateMachine()->OwnerThread()->Dispatch(event.forget());
mNextState = mPlayState;
ChangeState(PLAY_STATE_LOADING);
@ -160,7 +160,7 @@ MediaOmxCommonDecoder::ResumeStateMachine()
GetStateMachine(),
&MediaDecoderStateMachine::SetDormant,
false);
GetStateMachine()->TaskQueue()->Dispatch(event.forget());
GetStateMachine()->OwnerThread()->Dispatch(event.forget());
UpdateLogicalPosition();
}

View File

@ -244,7 +244,7 @@ MediaOmxReader::AsyncReadMetadata()
nsRefPtr<MediaOmxReader> self = this;
mMediaResourceRequest.Begin(mOmxDecoder->AllocateMediaResources()
->Then(TaskQueue(), __func__,
->Then(OwnerThread(), __func__,
[self] (bool) -> void {
self->mMediaResourceRequest.Complete();
self->HandleResourceAllocated();
@ -539,7 +539,7 @@ MediaOmxReader::Seek(int64_t aTarget, int64_t aEndTime)
mVideoSeekTimeUs = aTarget;
nsRefPtr<MediaOmxReader> self = this;
mSeekRequest.Begin(DecodeToFirstVideoData()->Then(TaskQueue(), __func__, [self] (VideoData* v) {
mSeekRequest.Begin(DecodeToFirstVideoData()->Then(OwnerThread(), __func__, [self] (VideoData* v) {
self->mSeekRequest.Complete();
self->mAudioSeekTimeUs = v->mTime;
self->mSeekPromise.Resolve(self->mAudioSeekTimeUs, __func__);
@ -601,7 +601,7 @@ int64_t MediaOmxReader::ProcessCachedData(int64_t aOffset)
if (OnTaskQueue()) {
runnable->Run();
} else {
TaskQueue()->Dispatch(runnable.forget());
OwnerThread()->Dispatch(runnable.forget());
}
return resourceLength - aOffset - bufferLength;

View File

@ -260,7 +260,7 @@ RawReader::Seek(int64_t aTime, int64_t aEndTime)
MOZ_ASSERT(self->OnTaskQueue());
return self->mVideoQueue.Peek() &&
self->mVideoQueue.Peek()->GetEndTime() >= aTime;
})->Then(TaskQueue(), __func__, [self, p, aTime] () {
})->Then(OwnerThread(), __func__, [self, p, aTime] () {
while (self->mVideoQueue.GetSize() >= 2) {
nsRefPtr<VideoData> releaseMe = self->mVideoQueue.PopFront();
}

View File

@ -245,14 +245,14 @@ MediaDecodeTask::Decode()
{
MOZ_ASSERT(!NS_IsMainThread());
mBufferDecoder->BeginDecoding(mDecoderReader->TaskQueue());
mBufferDecoder->BeginDecoding(mDecoderReader->OwnerThread());
// Tell the decoder reader that we are not going to play the data directly,
// and that we should not reject files with more channels than the audio
// backend support.
mDecoderReader->SetIgnoreAudioOutputFormat();
mDecoderReader->AsyncReadMetadata()->Then(mDecoderReader->TaskQueue(), __func__, this,
mDecoderReader->AsyncReadMetadata()->Then(mDecoderReader->OwnerThread(), __func__, this,
&MediaDecodeTask::OnMetadataRead,
&MediaDecodeTask::OnMetadataNotRead);
}
@ -281,7 +281,7 @@ MediaDecodeTask::OnMetadataNotRead(ReadMetadataFailureReason aReason)
void
MediaDecodeTask::RequestSample()
{
mDecoderReader->RequestAudioData()->Then(mDecoderReader->TaskQueue(), __func__, this,
mDecoderReader->RequestAudioData()->Then(mDecoderReader->OwnerThread(), __func__, this,
&MediaDecodeTask::SampleDecoded,
&MediaDecodeTask::SampleNotDecoded);
}
@ -504,10 +504,10 @@ AsyncDecodeWebAudio(const char* aContentType, uint8_t* aBuffer,
NS_DispatchToMainThread(event);
} else {
// If we did this without a temporary:
// task->Reader()->TaskQueue()->Dispatch(task.forget())
// task->Reader()->OwnerThread()->Dispatch(task.forget())
// we might evaluate the task.forget() before calling Reader(). Enforce
// a non-crashy order-of-operations.
MediaTaskQueue* taskQueue = task->Reader()->TaskQueue();
MediaTaskQueue* taskQueue = task->Reader()->OwnerThread();
taskQueue->Dispatch(task.forget());
}
}