summaryrefslogtreecommitdiffstats
path: root/ipc/glue/UtilityAudioDecoderChild.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/glue/UtilityAudioDecoderChild.cpp')
-rw-r--r--ipc/glue/UtilityAudioDecoderChild.cpp54
1 files changed, 42 insertions, 12 deletions
diff --git a/ipc/glue/UtilityAudioDecoderChild.cpp b/ipc/glue/UtilityAudioDecoderChild.cpp
index 88124a1f8b..cc3560e05b 100644
--- a/ipc/glue/UtilityAudioDecoderChild.cpp
+++ b/ipc/glue/UtilityAudioDecoderChild.cpp
@@ -42,8 +42,8 @@ NS_IMETHODIMP UtilityAudioDecoderChildShutdownObserver::Observe(
NS_IMPL_ISUPPORTS(UtilityAudioDecoderChildShutdownObserver, nsIObserver);
-static EnumeratedArray<SandboxingKind, SandboxingKind::COUNT,
- StaticRefPtr<UtilityAudioDecoderChild>>
+static EnumeratedArray<SandboxingKind, StaticRefPtr<UtilityAudioDecoderChild>,
+ size_t(SandboxingKind::COUNT)>
sAudioDecoderChilds;
UtilityAudioDecoderChild::UtilityAudioDecoderChild(SandboxingKind aKind)
@@ -56,6 +56,40 @@ UtilityAudioDecoderChild::UtilityAudioDecoderChild(SandboxingKind aKind)
}
}
+nsresult UtilityAudioDecoderChild::BindToUtilityProcess(
+ RefPtr<UtilityProcessParent> aUtilityParent) {
+ Endpoint<PUtilityAudioDecoderChild> utilityAudioDecoderChildEnd;
+ Endpoint<PUtilityAudioDecoderParent> utilityAudioDecoderParentEnd;
+ nsresult rv = PUtilityAudioDecoder::CreateEndpoints(
+ aUtilityParent->OtherPid(), base::GetCurrentProcId(),
+ &utilityAudioDecoderParentEnd, &utilityAudioDecoderChildEnd);
+
+ if (NS_FAILED(rv)) {
+ MOZ_ASSERT(false, "Protocol endpoints failure");
+ return NS_ERROR_FAILURE;
+ }
+
+ nsTArray<gfx::GfxVarUpdate> updates;
+#ifdef MOZ_WMF_MEDIA_ENGINE
+ // Only MFCDM process needs gfxVars
+ if (mSandbox == SandboxingKind::MF_MEDIA_ENGINE_CDM) {
+ updates = gfx::gfxVars::FetchNonDefaultVars();
+ }
+#endif
+ if (!aUtilityParent->SendStartUtilityAudioDecoderService(
+ std::move(utilityAudioDecoderParentEnd), std::move(updates))) {
+ MOZ_ASSERT(false, "StartUtilityAudioDecoder service failure");
+ return NS_ERROR_FAILURE;
+ }
+
+ Bind(std::move(utilityAudioDecoderChildEnd));
+
+ PROFILER_MARKER_UNTYPED("UtilityAudioDecoderChild::BindToUtilityProcess", IPC,
+ MarkerOptions(MarkerTiming::IntervalUntilNowFrom(
+ mAudioDecoderChildStart)));
+ return NS_OK;
+}
+
void UtilityAudioDecoderChild::ActorDestroy(ActorDestroyReason aReason) {
MOZ_ASSERT(NS_IsMainThread());
#ifdef MOZ_WMF_MEDIA_ENGINE
@@ -110,15 +144,10 @@ mozilla::ipc::IPCResult
UtilityAudioDecoderChild::RecvCompleteCreatedVideoBridge() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mSandbox == SandboxingKind::MF_MEDIA_ENGINE_CDM);
- mHasCreatedVideoBridge = true;
+ mHasCreatedVideoBridge = State::Created;
return IPC_OK();
}
-bool UtilityAudioDecoderChild::HasCreatedVideoBridge() const {
- MOZ_ASSERT(NS_IsMainThread());
- return mHasCreatedVideoBridge;
-}
-
void UtilityAudioDecoderChild::OnVarChanged(const gfx::GfxVarUpdate& aVar) {
MOZ_ASSERT(mSandbox == SandboxingKind::MF_MEDIA_ENGINE_CDM);
SendUpdateVar(aVar);
@@ -127,7 +156,7 @@ void UtilityAudioDecoderChild::OnVarChanged(const gfx::GfxVarUpdate& aVar) {
void UtilityAudioDecoderChild::OnCompositorUnexpectedShutdown() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mSandbox == SandboxingKind::MF_MEDIA_ENGINE_CDM);
- mHasCreatedVideoBridge = false;
+ mHasCreatedVideoBridge = State::None;
CreateVideoBridge();
}
@@ -135,9 +164,11 @@ bool UtilityAudioDecoderChild::CreateVideoBridge() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mSandbox == SandboxingKind::MF_MEDIA_ENGINE_CDM);
- if (HasCreatedVideoBridge()) {
+ // Creating or already created, avoiding reinit a bridge.
+ if (mHasCreatedVideoBridge != State::None) {
return true;
}
+ mHasCreatedVideoBridge = State::Creating;
// Build content device data first; this ensure that the GPU process is fully
// ready.
@@ -170,11 +201,10 @@ bool UtilityAudioDecoderChild::CreateVideoBridge() {
return false;
}
- nsTArray<gfx::GfxVarUpdate> updates = gfx::gfxVars::FetchNonDefaultVars();
gpuManager->InitVideoBridge(
std::move(parentPipe),
layers::VideoBridgeSource::MFMediaEngineCDMProcess);
- SendInitVideoBridge(std::move(childPipe), updates, contentDeviceData);
+ SendInitVideoBridge(std::move(childPipe), contentDeviceData);
return true;
}
#endif