зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1650996 - P2. Always initialise the RemoteDecoderChild manager thread. r=mjf
This allows to simplify the lifetime management off the RemoteDecoderModule's mManagerThread member. Differential Revision: https://phabricator.services.mozilla.com/D82502
This commit is contained in:
Родитель
788bbafac7
Коммит
a3e2ecf7c4
|
@ -55,7 +55,7 @@ class RemoteDecoderChild : public PRemoteDecoderChild,
|
|||
MediaDataDecoder::DecodedData mDecodedData;
|
||||
|
||||
private:
|
||||
RefPtr<nsIThread> mThread;
|
||||
const RefPtr<nsIThread> mThread;
|
||||
|
||||
MozPromiseHolder<MediaDataDecoder::InitPromise> mInitPromise;
|
||||
MozPromiseRequestHolder<PRemoteDecoderChild::InitPromise> mInitPromiseRequest;
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
@ -51,6 +51,7 @@ 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(
|
||||
|
@ -80,9 +81,6 @@ class RemoteDecoderManagerChild final
|
|||
bool DeallocPRemoteDecoderChild(PRemoteDecoderChild* actor);
|
||||
|
||||
private:
|
||||
// Main thread only
|
||||
static void InitializeThread();
|
||||
|
||||
explicit RemoteDecoderManagerChild(layers::VideoBridgeSource aSource);
|
||||
~RemoteDecoderManagerChild() = default;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "VideoUtils.h"
|
||||
#include "VorbisDecoder.h"
|
||||
#include "WAVDecoder.h"
|
||||
#include "nsIXULRuntime.h" // for BrowserTabsRemoteAutostart
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -32,7 +33,17 @@ using namespace layers;
|
|||
StaticMutex RemoteDecoderModule::sLaunchMonitor;
|
||||
|
||||
RemoteDecoderModule::RemoteDecoderModule()
|
||||
: mManagerThread(RemoteDecoderManagerChild::GetManagerThread()) {}
|
||||
: mManagerThread(RemoteDecoderManagerChild::GetManagerThread()) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mManagerThread);
|
||||
}
|
||||
|
||||
/* static */
|
||||
void RemoteDecoderModule::Init() {
|
||||
if (!BrowserTabsRemoteAutostart()) {
|
||||
return;
|
||||
}
|
||||
RemoteDecoderManagerChild::InitializeThread();
|
||||
}
|
||||
|
||||
bool RemoteDecoderModule::SupportsMimeType(
|
||||
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
|
@ -67,7 +78,7 @@ bool RemoteDecoderModule::SupportsMimeType(
|
|||
return supports;
|
||||
}
|
||||
|
||||
void RemoteDecoderModule::LaunchRDDProcessIfNeeded() {
|
||||
void RemoteDecoderModule::LaunchRDDProcessIfNeeded() const {
|
||||
if (!XRE_IsContentProcess()) {
|
||||
return;
|
||||
}
|
||||
|
@ -88,20 +99,17 @@ void RemoteDecoderModule::LaunchRDDProcessIfNeeded() {
|
|||
// LaunchRDDProcess which will launch RDD if necessary, and setup the
|
||||
// IPC connections between *this* content process and the RDD process.
|
||||
bool needsLaunch = true;
|
||||
if (mManagerThread) {
|
||||
RefPtr<Runnable> task = NS_NewRunnableFunction(
|
||||
"RemoteDecoderModule::LaunchRDDProcessIfNeeded-CheckSend", [&]() {
|
||||
if (RemoteDecoderManagerChild::GetRDDProcessSingleton()) {
|
||||
needsLaunch =
|
||||
!RemoteDecoderManagerChild::GetRDDProcessSingleton()->CanSend();
|
||||
}
|
||||
});
|
||||
SyncRunnable::DispatchToThread(mManagerThread, task);
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,10 +117,6 @@ 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
|
||||
|
@ -159,10 +163,6 @@ 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,7 +6,6 @@
|
|||
#ifndef include_dom_media_ipc_RemoteDecoderModule_h
|
||||
#define include_dom_media_ipc_RemoteDecoderModule_h
|
||||
#include "PlatformDecoderModule.h"
|
||||
|
||||
#include "mozilla/StaticMutex.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -17,6 +16,8 @@ namespace mozilla {
|
|||
// (RemoteVideoDecoderParent) on the RDD process.
|
||||
class RemoteDecoderModule : public PlatformDecoderModule {
|
||||
public:
|
||||
static void Init();
|
||||
|
||||
RemoteDecoderModule();
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType,
|
||||
|
@ -29,10 +30,10 @@ class RemoteDecoderModule : public PlatformDecoderModule {
|
|||
const CreateDecoderParams& aParams) override;
|
||||
|
||||
protected:
|
||||
void LaunchRDDProcessIfNeeded();
|
||||
void LaunchRDDProcessIfNeeded() const;
|
||||
|
||||
private:
|
||||
RefPtr<nsIThread> mManagerThread;
|
||||
const nsCOMPtr<nsISerialEventTarget> mManagerThread;
|
||||
static StaticMutex sLaunchMonitor;
|
||||
};
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ class PDMFactoryImpl final {
|
|||
#ifdef MOZ_FFMPEG
|
||||
FFmpegRuntimeLinker::Init();
|
||||
#endif
|
||||
RemoteDecoderModule::Init();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче