зеркало из 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:
Родитель
f1cd4ddc78
Коммит
a7619dfaf8
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче