Remove sync dispatch from apple's initialization

It will now do just like what it does on all the other platforms: link on first use.
This commit is contained in:
trav90
2016-11-15 15:30:22 -06:00
committed by roytam1
parent 538539f5c3
commit b4302296bc
2 changed files with 1 additions and 58 deletions
@@ -33,46 +33,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());
NS_DispatchToMainThread(task);
}
/* static */
@@ -100,35 +66,16 @@ 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;
}
nsRefPtr<nsIRunnable> task(new LinkTask());
NS_DispatchToMainThread(task, NS_DISPATCH_SYNC);
return NS_OK;
}