зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1206576 - Dispatch some MDSM functions to hide its internal thread model. r=jya.
This commit is contained in:
Родитель
9fd579e930
Коммит
5d35a74e15
|
@ -217,13 +217,7 @@ void MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity)
|
|||
if (mIsDormant) {
|
||||
DECODER_LOG("UpdateDormantState() entering DORMANT state");
|
||||
// enter dormant state
|
||||
RefPtr<nsRunnable> event =
|
||||
NS_NewRunnableMethodWithArg<bool>(
|
||||
mDecoderStateMachine,
|
||||
&MediaDecoderStateMachine::SetDormant,
|
||||
true);
|
||||
mDecoderStateMachine->OwnerThread()->Dispatch(event.forget());
|
||||
|
||||
mDecoderStateMachine->DispatchSetDormant(true);
|
||||
if (IsEnded()) {
|
||||
mWasEndedWhenEnteredDormant = true;
|
||||
}
|
||||
|
@ -232,13 +226,7 @@ void MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity)
|
|||
} else {
|
||||
DECODER_LOG("UpdateDormantState() leaving DORMANT state");
|
||||
// exit dormant state
|
||||
// trigger to state machine.
|
||||
RefPtr<nsRunnable> event =
|
||||
NS_NewRunnableMethodWithArg<bool>(
|
||||
mDecoderStateMachine,
|
||||
&MediaDecoderStateMachine::SetDormant,
|
||||
false);
|
||||
mDecoderStateMachine->OwnerThread()->Dispatch(event.forget());
|
||||
mDecoderStateMachine->DispatchSetDormant(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -618,9 +606,8 @@ void MediaDecoder::CallSeek(const SeekTarget& aTarget)
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mSeekRequest.DisconnectIfExists();
|
||||
mSeekRequest.Begin(InvokeAsync(mDecoderStateMachine->OwnerThread(),
|
||||
mDecoderStateMachine.get(), __func__,
|
||||
&MediaDecoderStateMachine::Seek, aTarget)
|
||||
mSeekRequest.Begin(
|
||||
mDecoderStateMachine->InvokeSeek(aTarget)
|
||||
->Then(AbstractThread::MainThread(), __func__, this,
|
||||
&MediaDecoder::OnSeekResolved, &MediaDecoder::OnSeekRejected));
|
||||
}
|
||||
|
@ -1311,10 +1298,7 @@ void
|
|||
MediaDecoder::NotifyWaitingForResourcesStatusChanged()
|
||||
{
|
||||
if (mDecoderStateMachine) {
|
||||
RefPtr<nsRunnable> task =
|
||||
NS_NewRunnableMethod(mDecoderStateMachine,
|
||||
&MediaDecoderStateMachine::NotifyWaitingForResourcesStatusChanged);
|
||||
mDecoderStateMachine->OwnerThread()->Dispatch(task.forget());
|
||||
mDecoderStateMachine->DispatchWaitingForResourcesStatusChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1234,7 +1234,16 @@ void MediaDecoderStateMachine::RecomputeDuration()
|
|||
mDuration = Some(duration);
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::SetDormant(bool aDormant)
|
||||
void
|
||||
MediaDecoderStateMachine::DispatchSetDormant(bool aDormant)
|
||||
{
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethodWithArg<bool>(
|
||||
this, &MediaDecoderStateMachine::SetDormant, aDormant);
|
||||
OwnerThread()->Dispatch(r.forget());
|
||||
}
|
||||
|
||||
void
|
||||
MediaDecoderStateMachine::SetDormant(bool aDormant)
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
|
@ -1382,7 +1391,16 @@ void MediaDecoderStateMachine::StartDecoding()
|
|||
ScheduleStateMachine();
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::NotifyWaitingForResourcesStatusChanged()
|
||||
void
|
||||
MediaDecoderStateMachine::DispatchWaitingForResourcesStatusChanged()
|
||||
{
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod(
|
||||
this, &MediaDecoderStateMachine::NotifyWaitingForResourcesStatusChanged);
|
||||
OwnerThread()->Dispatch(r.forget());
|
||||
}
|
||||
|
||||
void
|
||||
MediaDecoderStateMachine::NotifyWaitingForResourcesStatusChanged()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
|
@ -1512,6 +1530,13 @@ MediaDecoderStateMachine::Seek(SeekTarget aTarget)
|
|||
return mPendingSeek.mPromise.Ensure(__func__);
|
||||
}
|
||||
|
||||
nsRefPtr<MediaDecoder::SeekPromise>
|
||||
MediaDecoderStateMachine::InvokeSeek(SeekTarget aTarget)
|
||||
{
|
||||
return InvokeAsync(OwnerThread(), this, __func__,
|
||||
&MediaDecoderStateMachine::Seek, aTarget);
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::StopMediaSink()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
|
|
|
@ -156,7 +156,7 @@ public:
|
|||
void RemoveOutputStream(MediaStream* aStream);
|
||||
|
||||
// Set/Unset dormant state.
|
||||
void SetDormant(bool aDormant);
|
||||
void DispatchSetDormant(bool aDormant);
|
||||
|
||||
TimedMetadataEventSource& TimedMetadataEvent() {
|
||||
return mMetadataManager.TimedMetadataEvent();
|
||||
|
@ -168,11 +168,17 @@ private:
|
|||
// constructor immediately after the task queue is created.
|
||||
void InitializationTask();
|
||||
|
||||
void SetDormant(bool aDormant);
|
||||
|
||||
void SetAudioCaptured(bool aCaptured);
|
||||
|
||||
void Shutdown();
|
||||
public:
|
||||
void NotifyWaitingForResourcesStatusChanged();
|
||||
|
||||
nsRefPtr<MediaDecoder::SeekPromise> Seek(SeekTarget aTarget);
|
||||
|
||||
void Shutdown();
|
||||
|
||||
public:
|
||||
void DispatchShutdown();
|
||||
|
||||
void FinishShutdown();
|
||||
|
@ -186,8 +192,7 @@ public:
|
|||
bool OnTaskQueue() const;
|
||||
|
||||
// Seeks to the decoder to aTarget asynchronously.
|
||||
// Must be called on the state machine thread.
|
||||
nsRefPtr<MediaDecoder::SeekPromise> Seek(SeekTarget aTarget);
|
||||
nsRefPtr<MediaDecoder::SeekPromise> InvokeSeek(SeekTarget aTarget);
|
||||
|
||||
// Clear the flag indicating that a playback position change event
|
||||
// is currently queued. This is called from the main thread and must
|
||||
|
@ -341,7 +346,7 @@ public:
|
|||
|
||||
// Called when the reader may have acquired the hardware resources required
|
||||
// to begin decoding.
|
||||
void NotifyWaitingForResourcesStatusChanged();
|
||||
void DispatchWaitingForResourcesStatusChanged();
|
||||
|
||||
// Notifies the state machine that should minimize the number of samples
|
||||
// decoded we preroll, until playback starts. The first time playback starts
|
||||
|
|
|
@ -116,12 +116,7 @@ MediaOmxCommonDecoder::PauseStateMachine()
|
|||
return;
|
||||
}
|
||||
// enter dormant state
|
||||
RefPtr<nsRunnable> event =
|
||||
NS_NewRunnableMethodWithArg<bool>(
|
||||
GetStateMachine(),
|
||||
&MediaDecoderStateMachine::SetDormant,
|
||||
true);
|
||||
GetStateMachine()->OwnerThread()->Dispatch(event.forget());
|
||||
GetStateMachine()->DispatchSetDormant(true);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -145,22 +140,12 @@ MediaOmxCommonDecoder::ResumeStateMachine()
|
|||
SeekTarget::Accurate,
|
||||
MediaDecoderEventVisibility::Suppressed);
|
||||
// Call Seek of MediaDecoderStateMachine to suppress seek events.
|
||||
RefPtr<nsRunnable> event =
|
||||
NS_NewRunnableMethodWithArg<SeekTarget>(
|
||||
GetStateMachine(),
|
||||
&MediaDecoderStateMachine::Seek,
|
||||
target);
|
||||
GetStateMachine()->OwnerThread()->Dispatch(event.forget());
|
||||
GetStateMachine()->InvokeSeek(target);
|
||||
|
||||
mNextState = mPlayState;
|
||||
ChangeState(PLAY_STATE_LOADING);
|
||||
// exit dormant state
|
||||
event =
|
||||
NS_NewRunnableMethodWithArg<bool>(
|
||||
GetStateMachine(),
|
||||
&MediaDecoderStateMachine::SetDormant,
|
||||
false);
|
||||
GetStateMachine()->OwnerThread()->Dispatch(event.forget());
|
||||
GetStateMachine()->DispatchSetDormant(false);
|
||||
UpdateLogicalPosition();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче