зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 5 changesets (bug 1650996, bug 1649974) for hazard failures CLOSED TREE
Backed out changeset de5e55b59a31 (bug 1650996) Backed out changeset 35faa46f46f1 (bug 1650996) Backed out changeset 6f779a3875a8 (bug 1650996) Backed out changeset fac1e5a07a6c (bug 1649974) Backed out changeset 3c5157a9e872 (bug 1649974)
This commit is contained in:
Родитель
a94d673341
Коммит
0867b964e2
|
@ -65,6 +65,7 @@ ProxyResolution
|
|||
RemoteLzyStream
|
||||
RWLockTester
|
||||
RacingServMan
|
||||
RemVidChild
|
||||
Sandbox Testing
|
||||
SaveScripts
|
||||
Socket Thread
|
||||
|
|
|
@ -5,11 +5,13 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "GpuDecoderModule.h"
|
||||
|
||||
#include "RemoteDecoderManagerChild.h"
|
||||
#include "RemoteMediaDataDecoder.h"
|
||||
#include "RemoteVideoDecoder.h"
|
||||
#include "base/thread.h"
|
||||
#include "mozilla/layers/SynchronousTask.h"
|
||||
#include "mozilla/StaticPrefs_media.h"
|
||||
#include "mozilla/SyncRunnable.h"
|
||||
#include "RemoteVideoDecoder.h"
|
||||
#include "RemoteDecoderManagerChild.h"
|
||||
|
||||
#include "RemoteMediaDataDecoder.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -48,20 +50,19 @@ already_AddRefed<MediaDataDecoder> GpuDecoderModule::CreateVideoDecoder(
|
|||
}
|
||||
|
||||
RefPtr<GpuRemoteVideoDecoderChild> child = new GpuRemoteVideoDecoderChild();
|
||||
SynchronousTask task("InitIPDL");
|
||||
MediaResult result(NS_OK);
|
||||
RefPtr<Runnable> task = NS_NewRunnableFunction(
|
||||
"dom::GpuDecoderModule::CreateVideoDecoder", [&]() {
|
||||
result = child->InitIPDL(
|
||||
aParams.VideoConfig(), aParams.mRate.mValue, aParams.mOptions,
|
||||
aParams.mKnowsCompositor->GetTextureFactoryIdentifier());
|
||||
if (NS_FAILED(result)) {
|
||||
// Release GpuRemoteVideoDecoderChild here, while we're on
|
||||
// manager thread. Don't just let the RefPtr go out of scope.
|
||||
child = nullptr;
|
||||
}
|
||||
});
|
||||
SyncRunnable::DispatchToThread(RemoteDecoderManagerChild::GetManagerThread(),
|
||||
task);
|
||||
RemoteDecoderManagerChild::GetManagerThread()->Dispatch(
|
||||
NS_NewRunnableFunction(
|
||||
"dom::GpuDecoderModule::CreateVideoDecoder",
|
||||
[&, child]() {
|
||||
AutoCompleteTask complete(&task);
|
||||
result = child->InitIPDL(
|
||||
aParams.VideoConfig(), aParams.mRate.mValue, aParams.mOptions,
|
||||
aParams.mKnowsCompositor->GetTextureFactoryIdentifier());
|
||||
}),
|
||||
NS_DISPATCH_NORMAL);
|
||||
task.Wait();
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
if (aParams.mError) {
|
||||
|
|
|
@ -254,7 +254,7 @@ MediaDataDecoder::ConversionRequired RemoteDecoderChild::NeedsConversion()
|
|||
}
|
||||
|
||||
void RemoteDecoderChild::AssertOnManagerThread() const {
|
||||
MOZ_ASSERT(mThread->IsOnCurrentThread());
|
||||
MOZ_ASSERT(NS_GetCurrentThread() == mThread);
|
||||
}
|
||||
|
||||
RemoteDecoderManagerChild* RemoteDecoderChild::GetManager() {
|
||||
|
|
|
@ -55,7 +55,7 @@ class RemoteDecoderChild : public PRemoteDecoderChild,
|
|||
MediaDataDecoder::DecodedData mDecodedData;
|
||||
|
||||
private:
|
||||
const nsCOMPtr<nsISerialEventTarget> mThread;
|
||||
RefPtr<nsIThread> mThread;
|
||||
|
||||
MozPromiseHolder<MediaDataDecoder::InitPromise> mInitPromise;
|
||||
MozPromiseRequestHolder<PRemoteDecoderChild::InitPromise> mInitPromiseRequest;
|
||||
|
|
|
@ -5,14 +5,15 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "RemoteDecoderManagerChild.h"
|
||||
|
||||
#include "base/task.h"
|
||||
|
||||
#include "RemoteDecoderChild.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/DataSurfaceHelpers.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
#include "mozilla/layers/ISurfaceAllocator.h"
|
||||
#include "mozilla/layers/SynchronousTask.h"
|
||||
#include "mozilla/gfx/DataSurfaceHelpers.h"
|
||||
#include "mozilla/layers/ISurfaceAllocator.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -20,7 +21,7 @@ using namespace layers;
|
|||
using namespace gfx;
|
||||
|
||||
// Only modified on the main-thread
|
||||
StaticRefPtr<TaskQueue> sRemoteDecoderManagerChildThread;
|
||||
StaticRefPtr<nsIThread> sRemoteDecoderManagerChildThread;
|
||||
|
||||
// Only accessed from sRemoteDecoderManagerChildThread
|
||||
static StaticRefPtr<RemoteDecoderManagerChild>
|
||||
|
@ -35,12 +36,10 @@ void RemoteDecoderManagerChild::InitializeThread() {
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!sRemoteDecoderManagerChildThread) {
|
||||
// We can't use a MediaThreadType::PLAYBACK as the GpuDecoderModule and
|
||||
// RemoteDecoderModule runs on it and dispatch synchronous tasks to the
|
||||
// manager thread, should more than 4 concurrent videos being instantiated
|
||||
// at the same time, we could end up in a deadlock.
|
||||
sRemoteDecoderManagerChildThread = new TaskQueue(
|
||||
GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER), "RemVidChild");
|
||||
RefPtr<nsIThread> childThread;
|
||||
nsresult rv = NS_NewNamedThread("RemVidChild", getter_AddRefs(childThread));
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
sRemoteDecoderManagerChildThread = childThread;
|
||||
|
||||
sRecreateTasks = MakeUnique<nsTArray<RefPtr<Runnable>>>();
|
||||
}
|
||||
|
@ -50,18 +49,20 @@ void RemoteDecoderManagerChild::InitializeThread() {
|
|||
void RemoteDecoderManagerChild::InitForRDDProcess(
|
||||
Endpoint<PRemoteDecoderManagerChild>&& aVideoManager) {
|
||||
InitializeThread();
|
||||
MOZ_ALWAYS_SUCCEEDS(sRemoteDecoderManagerChildThread->Dispatch(
|
||||
sRemoteDecoderManagerChildThread->Dispatch(
|
||||
NewRunnableFunction("InitForContentRunnable", &OpenForRDDProcess,
|
||||
std::move(aVideoManager))));
|
||||
std::move(aVideoManager)),
|
||||
NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
/* static */
|
||||
void RemoteDecoderManagerChild::InitForGPUProcess(
|
||||
Endpoint<PRemoteDecoderManagerChild>&& aVideoManager) {
|
||||
InitializeThread();
|
||||
MOZ_ALWAYS_SUCCEEDS(sRemoteDecoderManagerChildThread->Dispatch(
|
||||
sRemoteDecoderManagerChildThread->Dispatch(
|
||||
NewRunnableFunction("InitForContentRunnable", &OpenForGPUProcess,
|
||||
std::move(aVideoManager))));
|
||||
std::move(aVideoManager)),
|
||||
NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -69,23 +70,24 @@ void RemoteDecoderManagerChild::Shutdown() {
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (sRemoteDecoderManagerChildThread) {
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
sRemoteDecoderManagerChildThread->Dispatch(NS_NewRunnableFunction(
|
||||
"dom::RemoteDecoderManagerChild::Shutdown", []() {
|
||||
sRemoteDecoderManagerChildThread->Dispatch(
|
||||
NS_NewRunnableFunction(
|
||||
"dom::RemoteDecoderManagerChild::Shutdown",
|
||||
[]() {
|
||||
if (sRemoteDecoderManagerChildForRDDProcess &&
|
||||
sRemoteDecoderManagerChildForRDDProcess->CanSend()) {
|
||||
sRemoteDecoderManagerChildForRDDProcess->Close();
|
||||
sRemoteDecoderManagerChildForRDDProcess = nullptr;
|
||||
}
|
||||
sRemoteDecoderManagerChildForRDDProcess = nullptr;
|
||||
if (sRemoteDecoderManagerChildForGPUProcess &&
|
||||
sRemoteDecoderManagerChildForGPUProcess->CanSend()) {
|
||||
sRemoteDecoderManagerChildForGPUProcess->Close();
|
||||
sRemoteDecoderManagerChildForGPUProcess = nullptr;
|
||||
}
|
||||
sRemoteDecoderManagerChildForGPUProcess = nullptr;
|
||||
})));
|
||||
}),
|
||||
NS_DISPATCH_NORMAL);
|
||||
|
||||
sRemoteDecoderManagerChildThread->BeginShutdown();
|
||||
sRemoteDecoderManagerChildThread->AwaitShutdownAndIdle();
|
||||
sRemoteDecoderManagerChildThread->Shutdown();
|
||||
sRemoteDecoderManagerChildThread = nullptr;
|
||||
|
||||
sRecreateTasks = nullptr;
|
||||
|
@ -94,7 +96,7 @@ void RemoteDecoderManagerChild::Shutdown() {
|
|||
|
||||
void RemoteDecoderManagerChild::RunWhenGPUProcessRecreated(
|
||||
already_AddRefed<Runnable> aTask) {
|
||||
MOZ_ASSERT(GetManagerThread() && GetManagerThread()->IsOnCurrentThread());
|
||||
MOZ_ASSERT(NS_GetCurrentThread() == GetManagerThread());
|
||||
|
||||
// If we've already been recreated, then run the task immediately.
|
||||
if (GetGPUProcessSingleton() && GetGPUProcessSingleton() != this &&
|
||||
|
@ -108,18 +110,18 @@ void RemoteDecoderManagerChild::RunWhenGPUProcessRecreated(
|
|||
|
||||
/* static */
|
||||
RemoteDecoderManagerChild* RemoteDecoderManagerChild::GetRDDProcessSingleton() {
|
||||
MOZ_ASSERT(GetManagerThread() && GetManagerThread()->IsOnCurrentThread());
|
||||
MOZ_ASSERT(NS_GetCurrentThread() == GetManagerThread());
|
||||
return sRemoteDecoderManagerChildForRDDProcess;
|
||||
}
|
||||
|
||||
/* static */
|
||||
RemoteDecoderManagerChild* RemoteDecoderManagerChild::GetGPUProcessSingleton() {
|
||||
MOZ_ASSERT(GetManagerThread() && GetManagerThread()->IsOnCurrentThread());
|
||||
MOZ_ASSERT(NS_GetCurrentThread() == GetManagerThread());
|
||||
return sRemoteDecoderManagerChildForGPUProcess;
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsISerialEventTarget* RemoteDecoderManagerChild::GetManagerThread() {
|
||||
nsIThread* RemoteDecoderManagerChild::GetManagerThread() {
|
||||
return sRemoteDecoderManagerChildThread;
|
||||
}
|
||||
|
||||
|
@ -149,15 +151,15 @@ RemoteDecoderManagerChild::RemoteDecoderManagerChild(
|
|||
|
||||
void RemoteDecoderManagerChild::OpenForRDDProcess(
|
||||
Endpoint<PRemoteDecoderManagerChild>&& aEndpoint) {
|
||||
MOZ_ASSERT(GetManagerThread() && GetManagerThread()->IsOnCurrentThread());
|
||||
MOZ_ASSERT(NS_GetCurrentThread() == GetManagerThread());
|
||||
// Only create RemoteDecoderManagerChild, bind new endpoint and init
|
||||
// ipdl if:
|
||||
// 1) haven't init'd sRemoteDecoderManagerChild
|
||||
// or
|
||||
// 2) if ActorDestroy was called meaning the other end of the ipc channel was
|
||||
// torn down
|
||||
// 2) if ActorDestroy was called (mCanSend is false) meaning the other
|
||||
// end of the ipc channel was torn down
|
||||
if (sRemoteDecoderManagerChildForRDDProcess &&
|
||||
sRemoteDecoderManagerChildForRDDProcess->CanSend()) {
|
||||
sRemoteDecoderManagerChildForRDDProcess->mCanSend) {
|
||||
return;
|
||||
}
|
||||
sRemoteDecoderManagerChildForRDDProcess = nullptr;
|
||||
|
@ -191,23 +193,34 @@ void RemoteDecoderManagerChild::OpenForGPUProcess(
|
|||
}
|
||||
|
||||
void RemoteDecoderManagerChild::InitIPDL() {
|
||||
mCanSend = true;
|
||||
mIPDLSelfRef = this;
|
||||
}
|
||||
|
||||
void RemoteDecoderManagerChild::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
mCanSend = false;
|
||||
}
|
||||
|
||||
void RemoteDecoderManagerChild::ActorDealloc() { mIPDLSelfRef = nullptr; }
|
||||
|
||||
bool RemoteDecoderManagerChild::CanSend() {
|
||||
MOZ_ASSERT(NS_GetCurrentThread() == GetManagerThread());
|
||||
return mCanSend;
|
||||
}
|
||||
|
||||
bool RemoteDecoderManagerChild::DeallocShmem(mozilla::ipc::Shmem& aShmem) {
|
||||
if (!sRemoteDecoderManagerChildThread->IsOnCurrentThread()) {
|
||||
if (NS_GetCurrentThread() != sRemoteDecoderManagerChildThread) {
|
||||
RefPtr<RemoteDecoderManagerChild> self = this;
|
||||
mozilla::ipc::Shmem shmem = aShmem;
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
sRemoteDecoderManagerChildThread->Dispatch(NS_NewRunnableFunction(
|
||||
"RemoteDecoderManagerChild::DeallocShmem", [self, shmem]() {
|
||||
if (self->CanSend()) {
|
||||
mozilla::ipc::Shmem shmemCopy = shmem;
|
||||
self->DeallocShmem(shmemCopy);
|
||||
}
|
||||
})));
|
||||
sRemoteDecoderManagerChildThread->Dispatch(
|
||||
NS_NewRunnableFunction("RemoteDecoderManagerChild::DeallocShmem",
|
||||
[self, shmem]() {
|
||||
if (self->CanSend()) {
|
||||
mozilla::ipc::Shmem shmemCopy = shmem;
|
||||
self->DeallocShmem(shmemCopy);
|
||||
}
|
||||
}),
|
||||
NS_DISPATCH_NORMAL);
|
||||
return true;
|
||||
}
|
||||
return PRemoteDecoderManagerChild::DeallocShmem(aShmem);
|
||||
|
@ -239,12 +252,14 @@ already_AddRefed<SourceSurface> RemoteDecoderManagerChild::Readback(
|
|||
RefPtr<RemoteDecoderManagerChild> ref = this;
|
||||
SurfaceDescriptor sd;
|
||||
if (NS_FAILED(sRemoteDecoderManagerChildThread->Dispatch(
|
||||
NS_NewRunnableFunction("RemoteDecoderManagerChild::Readback", [&]() {
|
||||
AutoCompleteTask complete(&task);
|
||||
if (ref->CanSend()) {
|
||||
ref->SendReadback(aSD, &sd);
|
||||
}
|
||||
})))) {
|
||||
NS_NewRunnableFunction("RemoteDecoderManagerChild::Readback",
|
||||
[&]() {
|
||||
AutoCompleteTask complete(&task);
|
||||
if (ref->CanSend()) {
|
||||
ref->SendReadback(aSD, &sd);
|
||||
}
|
||||
}),
|
||||
NS_DISPATCH_NORMAL))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -273,14 +288,15 @@ void RemoteDecoderManagerChild::DeallocateSurfaceDescriptor(
|
|||
const SurfaceDescriptorGPUVideo& aSD) {
|
||||
RefPtr<RemoteDecoderManagerChild> ref = this;
|
||||
SurfaceDescriptorGPUVideo sd = std::move(aSD);
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
sRemoteDecoderManagerChildThread->Dispatch(NS_NewRunnableFunction(
|
||||
sRemoteDecoderManagerChildThread->Dispatch(
|
||||
NS_NewRunnableFunction(
|
||||
"RemoteDecoderManagerChild::DeallocateSurfaceDescriptor",
|
||||
[ref, sd]() {
|
||||
if (ref->CanSend()) {
|
||||
ref->SendDeallocateSurfaceDescriptorGPUVideo(sd);
|
||||
}
|
||||
})));
|
||||
}),
|
||||
NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
void RemoteDecoderManagerChild::HandleFatalError(const char* aMsg) const {
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef include_dom_media_ipc_RemoteDecoderManagerChild_h
|
||||
#define include_dom_media_ipc_RemoteDecoderManagerChild_h
|
||||
#include "GPUVideoImage.h"
|
||||
#include "mozilla/PRemoteDecoderManagerChild.h"
|
||||
#include "mozilla/layers/VideoBridgeUtils.h"
|
||||
#include "GPUVideoImage.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -25,7 +25,7 @@ class RemoteDecoderManagerChild final
|
|||
static RemoteDecoderManagerChild* GetGPUProcessSingleton();
|
||||
|
||||
// Can be called from any thread.
|
||||
static nsISerialEventTarget* GetManagerThread();
|
||||
static nsIThread* GetManagerThread();
|
||||
|
||||
// Can be called from any thread, dispatches the request to the IPDL thread
|
||||
// internally and will be ignored if the IPDL actor has been destroyed.
|
||||
|
@ -51,7 +51,6 @@ class RemoteDecoderManagerChild final
|
|||
bool DeallocShmem(mozilla::ipc::Shmem& aShmem) override;
|
||||
|
||||
// Main thread only
|
||||
static void InitializeThread();
|
||||
static void InitForRDDProcess(
|
||||
Endpoint<PRemoteDecoderManagerChild>&& aVideoManager);
|
||||
static void InitForGPUProcess(
|
||||
|
@ -64,11 +63,13 @@ class RemoteDecoderManagerChild final
|
|||
// called from the manager thread.
|
||||
void RunWhenGPUProcessRecreated(already_AddRefed<Runnable> aTask);
|
||||
|
||||
bool CanSend();
|
||||
layers::VideoBridgeSource GetSource() const { return mSource; }
|
||||
|
||||
protected:
|
||||
void InitIPDL();
|
||||
|
||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
void ActorDealloc() override;
|
||||
|
||||
void HandleFatalError(const char* aMsg) const override;
|
||||
|
@ -81,6 +82,9 @@ class RemoteDecoderManagerChild final
|
|||
bool DeallocPRemoteDecoderChild(PRemoteDecoderChild* actor);
|
||||
|
||||
private:
|
||||
// Main thread only
|
||||
static void InitializeThread();
|
||||
|
||||
explicit RemoteDecoderManagerChild(layers::VideoBridgeSource aSource);
|
||||
~RemoteDecoderManagerChild() = default;
|
||||
|
||||
|
@ -93,6 +97,9 @@ class RemoteDecoderManagerChild final
|
|||
|
||||
// The associated source of this decoder manager
|
||||
layers::VideoBridgeSource mSource;
|
||||
|
||||
// Should only ever be accessed on the manager thread.
|
||||
bool mCanSend = false;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -9,13 +9,14 @@
|
|||
# include <objbase.h>
|
||||
#endif
|
||||
|
||||
#include "ImageContainer.h"
|
||||
#include "RemoteAudioDecoder.h"
|
||||
#include "RemoteVideoDecoder.h"
|
||||
#include "VideoUtils.h" // for MediaThreadType
|
||||
#include "mozilla/SyncRunnable.h"
|
||||
#include "mozilla/layers/ImageDataSerializer.h"
|
||||
|
||||
#include "ImageContainer.h"
|
||||
#include "mozilla/layers/VideoBridgeChild.h"
|
||||
#include "mozilla/layers/ImageDataSerializer.h"
|
||||
#include "mozilla/SyncRunnable.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -28,7 +29,7 @@ using namespace ipc;
|
|||
using namespace layers;
|
||||
using namespace gfx;
|
||||
|
||||
StaticRefPtr<TaskQueue> sRemoteDecoderManagerParentThread;
|
||||
StaticRefPtr<nsISerialEventTarget> sRemoteDecoderManagerParentThread;
|
||||
|
||||
SurfaceDescriptorGPUVideo RemoteDecoderManagerParent::StoreImage(
|
||||
Image* aImage, TextureClient* aTexture) {
|
||||
|
@ -71,13 +72,19 @@ bool RemoteDecoderManagerParent::StartupThreads() {
|
|||
return false;
|
||||
}
|
||||
|
||||
sRemoteDecoderManagerParentThread = new TaskQueue(
|
||||
GetMediaThreadPool(MediaThreadType::PLAYBACK), "RemVidParent");
|
||||
nsCOMPtr<nsISerialEventTarget> managerThread;
|
||||
nsresult rv = NS_CreateBackgroundTaskQueue("RemVidParent",
|
||||
getter_AddRefs(managerThread));
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
sRemoteDecoderManagerParentThread = managerThread;
|
||||
if (XRE_IsGPUProcess()) {
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
sRemoteDecoderManagerParentThread->Dispatch(NS_NewRunnableFunction(
|
||||
sRemoteDecoderManagerParentThread->Dispatch(
|
||||
NS_NewRunnableFunction(
|
||||
"RemoteDecoderManagerParent::StartupThreads",
|
||||
[]() { layers::VideoBridgeChild::StartupForGPUProcess(); })));
|
||||
[]() { layers::VideoBridgeChild::StartupForGPUProcess(); }),
|
||||
NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
auto* obs = new RemoteDecoderManagerThreadShutdownObserver();
|
||||
|
@ -86,14 +93,16 @@ bool RemoteDecoderManagerParent::StartupThreads() {
|
|||
}
|
||||
|
||||
void RemoteDecoderManagerParent::ShutdownThreads() {
|
||||
sRemoteDecoderManagerParentThread->BeginShutdown();
|
||||
sRemoteDecoderManagerParentThread->AwaitShutdownAndIdle();
|
||||
sRemoteDecoderManagerParentThread = nullptr;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void RemoteDecoderManagerParent::ShutdownVideoBridge() {
|
||||
if (sRemoteDecoderManagerParentThread) {
|
||||
if (sRemoteDecoderManagerParentThread->IsOnCurrentThread()) {
|
||||
VideoBridgeChild::Shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<Runnable> task = NS_NewRunnableFunction(
|
||||
"RemoteDecoderManagerParent::ShutdownVideoBridge",
|
||||
[]() { VideoBridgeChild::Shutdown(); });
|
||||
|
@ -122,8 +131,8 @@ bool RemoteDecoderManagerParent::CreateForContent(
|
|||
NewRunnableMethod<Endpoint<PRemoteDecoderManagerParent>&&>(
|
||||
"dom::RemoteDecoderManagerParent::Open", parent,
|
||||
&RemoteDecoderManagerParent::Open, std::move(aEndpoint));
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
sRemoteDecoderManagerParentThread->Dispatch(task.forget()));
|
||||
sRemoteDecoderManagerParentThread->Dispatch(task.forget(),
|
||||
NS_DISPATCH_NORMAL);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -141,8 +150,8 @@ bool RemoteDecoderManagerParent::CreateVideoBridgeToOtherProcess(
|
|||
RefPtr<Runnable> task =
|
||||
NewRunnableFunction("gfx::VideoBridgeChild::Open",
|
||||
&VideoBridgeChild::Open, std::move(aEndpoint));
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
sRemoteDecoderManagerParentThread->Dispatch(task.forget()));
|
||||
sRemoteDecoderManagerParentThread->Dispatch(task.forget(),
|
||||
NS_DISPATCH_NORMAL);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,23 +5,23 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "RemoteDecoderModule.h"
|
||||
|
||||
#include "mozilla/StaticPrefs_media.h"
|
||||
#include "mozilla/SyncRunnable.h"
|
||||
#include "base/thread.h"
|
||||
#include "mozilla/dom/ContentChild.h" // for launching RDD w/ ContentChild
|
||||
#include "mozilla/layers/SynchronousTask.h"
|
||||
#include "mozilla/StaticPrefs_media.h"
|
||||
#include "mozilla/SyncRunnable.h"
|
||||
|
||||
#ifdef MOZ_AV1
|
||||
# include "AOMDecoder.h"
|
||||
#endif
|
||||
#include "OpusDecoder.h"
|
||||
#include "RemoteAudioDecoder.h"
|
||||
#include "RemoteDecoderManagerChild.h"
|
||||
#include "RemoteMediaDataDecoder.h"
|
||||
#include "RemoteVideoDecoder.h"
|
||||
#include "OpusDecoder.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "VorbisDecoder.h"
|
||||
#include "WAVDecoder.h"
|
||||
#include "nsIXULRuntime.h" // for BrowserTabsRemoteAutostart
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -32,17 +32,7 @@ using namespace layers;
|
|||
StaticMutex RemoteDecoderModule::sLaunchMonitor;
|
||||
|
||||
RemoteDecoderModule::RemoteDecoderModule()
|
||||
: mManagerThread(RemoteDecoderManagerChild::GetManagerThread()) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mManagerThread);
|
||||
}
|
||||
|
||||
/* static */
|
||||
void RemoteDecoderModule::Init() {
|
||||
if (!BrowserTabsRemoteAutostart()) {
|
||||
return;
|
||||
}
|
||||
RemoteDecoderManagerChild::InitializeThread();
|
||||
}
|
||||
: mManagerThread(RemoteDecoderManagerChild::GetManagerThread()) {}
|
||||
|
||||
bool RemoteDecoderModule::SupportsMimeType(
|
||||
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
|
@ -77,7 +67,7 @@ bool RemoteDecoderModule::SupportsMimeType(
|
|||
return supports;
|
||||
}
|
||||
|
||||
void RemoteDecoderModule::LaunchRDDProcessIfNeeded() const {
|
||||
void RemoteDecoderModule::LaunchRDDProcessIfNeeded() {
|
||||
if (!XRE_IsContentProcess()) {
|
||||
return;
|
||||
}
|
||||
|
@ -98,17 +88,20 @@ void RemoteDecoderModule::LaunchRDDProcessIfNeeded() const {
|
|||
// LaunchRDDProcess which will launch RDD if necessary, and setup the
|
||||
// IPC connections between *this* content process and the RDD process.
|
||||
bool needsLaunch = true;
|
||||
RefPtr<Runnable> task = NS_NewRunnableFunction(
|
||||
"RemoteDecoderModule::LaunchRDDProcessIfNeeded-CheckSend", [&]() {
|
||||
if (RemoteDecoderManagerChild::GetRDDProcessSingleton()) {
|
||||
needsLaunch =
|
||||
!RemoteDecoderManagerChild::GetRDDProcessSingleton()->CanSend();
|
||||
}
|
||||
});
|
||||
SyncRunnable::DispatchToThread(mManagerThread, task);
|
||||
if (mManagerThread) {
|
||||
RefPtr<Runnable> task = NS_NewRunnableFunction(
|
||||
"RemoteDecoderModule::LaunchRDDProcessIfNeeded-CheckSend", [&]() {
|
||||
if (RemoteDecoderManagerChild::GetRDDProcessSingleton()) {
|
||||
needsLaunch =
|
||||
!RemoteDecoderManagerChild::GetRDDProcessSingleton()->CanSend();
|
||||
}
|
||||
});
|
||||
SyncRunnable::DispatchToThread(mManagerThread, task);
|
||||
}
|
||||
|
||||
if (needsLaunch) {
|
||||
ContentChild::GetSingleton()->LaunchRDDProcess();
|
||||
mManagerThread = RemoteDecoderManagerChild::GetManagerThread();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,6 +109,10 @@ already_AddRefed<MediaDataDecoder> RemoteDecoderModule::CreateAudioDecoder(
|
|||
const CreateDecoderParams& aParams) {
|
||||
LaunchRDDProcessIfNeeded();
|
||||
|
||||
if (!mManagerThread) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// OpusDataDecoder will check this option to provide the same info
|
||||
// that IsDefaultPlaybackDeviceMono provides. We want to avoid calls
|
||||
// to IsDefaultPlaybackDeviceMono on RDD because initializing audio
|
||||
|
@ -162,6 +159,10 @@ already_AddRefed<MediaDataDecoder> RemoteDecoderModule::CreateVideoDecoder(
|
|||
const CreateDecoderParams& aParams) {
|
||||
LaunchRDDProcessIfNeeded();
|
||||
|
||||
if (!mManagerThread) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<RemoteVideoDecoderChild> child = new RemoteVideoDecoderChild();
|
||||
MediaResult result(NS_OK);
|
||||
// We can use child as a ref here because this is a sync dispatch. In
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#ifndef include_dom_media_ipc_RemoteDecoderModule_h
|
||||
#define include_dom_media_ipc_RemoteDecoderModule_h
|
||||
#include "PlatformDecoderModule.h"
|
||||
|
||||
#include "mozilla/StaticMutex.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -16,8 +17,6 @@ namespace mozilla {
|
|||
// (RemoteVideoDecoderParent) on the RDD process.
|
||||
class RemoteDecoderModule : public PlatformDecoderModule {
|
||||
public:
|
||||
static void Init();
|
||||
|
||||
RemoteDecoderModule();
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType,
|
||||
|
@ -30,10 +29,10 @@ class RemoteDecoderModule : public PlatformDecoderModule {
|
|||
const CreateDecoderParams& aParams) override;
|
||||
|
||||
protected:
|
||||
void LaunchRDDProcessIfNeeded() const;
|
||||
void LaunchRDDProcessIfNeeded();
|
||||
|
||||
private:
|
||||
const nsCOMPtr<nsISerialEventTarget> mManagerThread;
|
||||
RefPtr<nsIThread> mManagerThread;
|
||||
static StaticMutex sLaunchMonitor;
|
||||
};
|
||||
|
||||
|
|
|
@ -72,7 +72,6 @@ class PDMFactoryImpl final {
|
|||
#ifdef MOZ_FFMPEG
|
||||
FFmpegRuntimeLinker::Init();
|
||||
#endif
|
||||
RemoteDecoderModule::Init();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -98,12 +98,12 @@
|
|||
// on a single thread. The following macros implement assertions for
|
||||
// checking these conditions.
|
||||
//
|
||||
// We re-use XPCOM's nsAutoOwningEventTarget checks when they are available.
|
||||
// This has the advantage that it works with cooperative thread pools.
|
||||
// We re-use XPCOM's nsAutoOwningThread checks when they are available. This has
|
||||
// the advantage that it works with cooperative thread pools.
|
||||
|
||||
# define MOZ_WEAKPTR_DECLARE_THREAD_SAFETY_CHECK \
|
||||
/* Will be none if mPtr = nullptr. */ \
|
||||
Maybe<nsAutoOwningEventTarget> _owningThread;
|
||||
Maybe<nsAutoOwningThread> _owningThread;
|
||||
# define MOZ_WEAKPTR_INIT_THREAD_SAFETY_CHECK() \
|
||||
do { \
|
||||
if (p) { \
|
||||
|
|
Загрузка…
Ссылка в новой задаче