Bug 1163458: Part2. Remove sync dispatch from apple's initialization. r=cpearce

This commit is contained in:
Jean-Yves Avenard 2015-05-18 15:42:32 +10:00
parent 24b8523293
commit 5468f54705
2 changed files with 1 additions and 68 deletions

View File

@ -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;
}

View File

@ -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;