зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1163458: Part2. Remove sync dispatch from apple's initialization. r=cpearce
This commit is contained in:
Родитель
998eafdaa3
Коммит
6416c761ce
|
@ -31,50 +31,12 @@ bool AppleDecoderModule::sIsVTHWAvailable = false;
|
|||
bool AppleDecoderModule::sIsVDAAvailable = false;
|
||||
bool AppleDecoderModule::sForceVDA = false;
|
||||
|
||||
class LinkTask : public nsRunnable {
|
||||
public:
|
||||
NS_IMETHOD Run() override {
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
|
||||
MOZ_ASSERT(AppleDecoderModule::sInitialized);
|
||||
if (AppleDecoderModule::sIsVDAAvailable) {
|
||||
AppleVDALinker::Link();
|
||||
}
|
||||
if (AppleDecoderModule::sIsVTAvailable) {
|
||||
AppleVTLinker::Link();
|
||||
AppleCMLinker::Link();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
class UnlinkTask : public nsRunnable {
|
||||
public:
|
||||
NS_IMETHOD Run() override {
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
|
||||
MOZ_ASSERT(AppleDecoderModule::sInitialized);
|
||||
if (AppleDecoderModule::sIsVDAAvailable) {
|
||||
AppleVDALinker::Unlink();
|
||||
}
|
||||
if (AppleDecoderModule::sIsVTAvailable) {
|
||||
AppleVTLinker::Unlink();
|
||||
AppleCMLinker::Unlink();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
AppleDecoderModule::AppleDecoderModule()
|
||||
{
|
||||
}
|
||||
|
||||
AppleDecoderModule::~AppleDecoderModule()
|
||||
{
|
||||
nsCOMPtr<nsIRunnable> task(new UnlinkTask());
|
||||
if (!NS_IsMainThread()) {
|
||||
NS_DispatchToMainThread(task);
|
||||
} else {
|
||||
task->Run();
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -102,40 +64,15 @@ AppleDecoderModule::Init()
|
|||
|
||||
sIsVTHWAvailable = AppleVTLinker::skPropEnableHWAccel != nullptr;
|
||||
|
||||
if (sIsVDAAvailable) {
|
||||
AppleVDALinker::Unlink();
|
||||
}
|
||||
if (sIsVTAvailable) {
|
||||
AppleVTLinker::Unlink();
|
||||
AppleCMLinker::Unlink();
|
||||
}
|
||||
sInitialized = true;
|
||||
}
|
||||
|
||||
class InitTask : public nsRunnable {
|
||||
public:
|
||||
NS_IMETHOD Run() override {
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
|
||||
AppleDecoderModule::Init();
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
nsresult
|
||||
AppleDecoderModule::Startup()
|
||||
{
|
||||
if (!sIsVDAAvailable && !sIsVTAvailable) {
|
||||
if (!sInitialized || (!sIsVDAAvailable && !sIsVTAvailable)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Note: We can be called on the main thread from MP4Decoder::CanHandleMediaType().
|
||||
nsCOMPtr<nsIRunnable> task(new LinkTask());
|
||||
if (!NS_IsMainThread()) {
|
||||
NS_DispatchToMainThread(task, NS_DISPATCH_SYNC);
|
||||
} else {
|
||||
task->Run();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,10 +40,6 @@ public:
|
|||
static void Init();
|
||||
|
||||
private:
|
||||
friend class InitTask;
|
||||
friend class LinkTask;
|
||||
friend class UnlinkTask;
|
||||
|
||||
static bool sInitialized;
|
||||
static bool sIsVTAvailable;
|
||||
static bool sIsVTHWAvailable;
|
||||
|
|
Загрузка…
Ссылка в новой задаче