From d5b9a341b8fc83017590d4a435bee27c5a106c66 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Tue, 17 May 2022 00:13:54 -0500 Subject: [DOM:Media] Revert Bug 1212323 Parts 2 and 3 where supportsHardwareH264Decoding() uses a promise if MP4 Hardware Acceleration to about:support This concern was largely Mac-specific but I did leave Part 1 intact because the Mozilla Bug makes a good point that some systems may always software render a 64x64 video (specifically apple but other implementations could adopt this nonsense as well). Personally I want accelerated video.. damn it! The real question is.. Why was the promise never resolving in the first place? Is it fall out from killing DOM Promise? It used jsval but who the hell knows or even cares.. It works and can once again be queried without jumping through god damned hoops. --- dom/media/fmp4/MP4Decoder.cpp | 56 +++++++------------------------------------ 1 file changed, 8 insertions(+), 48 deletions(-) (limited to 'dom/media/fmp4/MP4Decoder.cpp') diff --git a/dom/media/fmp4/MP4Decoder.cpp b/dom/media/fmp4/MP4Decoder.cpp index 9b0886e74..c0c954198 100644 --- a/dom/media/fmp4/MP4Decoder.cpp +++ b/dom/media/fmp4/MP4Decoder.cpp @@ -248,58 +248,18 @@ CreateTestH264Decoder(layers::KnowsCompositor* aKnowsCompositor, return decoder.forget(); } -/* static */ already_AddRefed -MP4Decoder::IsVideoAccelerated(layers::KnowsCompositor* aKnowsCompositor, nsIGlobalObject* aParent) +/* static */ bool +MP4Decoder::IsVideoAccelerated(layers::KnowsCompositor* aKnowsCompositor, nsACString& aFailureReason) { - MOZ_ASSERT(NS_IsMainThread()); - - ErrorResult rv; - RefPtr promise; - promise = dom::Promise::Create(aParent, rv); - if (rv.Failed()) { - rv.SuppressException(); - return nullptr; - } - - RefPtr taskQueue = - new TaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER)); VideoInfo config; - RefPtr decoder(CreateTestH264Decoder(aKnowsCompositor, config, taskQueue)); + RefPtr decoder(CreateTestH264Decoder(aKnowsCompositor, config, nullptr)); if (!decoder) { - taskQueue->BeginShutdown(); - taskQueue->AwaitShutdownAndIdle(); - promise->MaybeResolve(NS_LITERAL_STRING("No; Failed to create H264 decoder")); - return promise.forget(); + aFailureReason.AssignLiteral("Failed to create H264 decoder"); + return false; } - - decoder->Init() - ->Then(AbstractThread::MainThread(), __func__, - [promise, decoder, taskQueue] (TrackInfo::TrackType aTrack) { - nsCString failureReason; - bool ok = decoder->IsHardwareAccelerated(failureReason); - nsAutoString result; - if (ok) { - result.AssignLiteral("Yes"); - } else { - result.AssignLiteral("No"); - } - if (failureReason.Length()) { - result.AppendLiteral("; "); - AppendUTF8toUTF16(failureReason, result); - } - decoder->Shutdown(); - taskQueue->BeginShutdown(); - taskQueue->AwaitShutdownAndIdle(); - promise->MaybeResolve(result); - }, - [promise, decoder, taskQueue] (MediaResult aError) { - decoder->Shutdown(); - taskQueue->BeginShutdown(); - taskQueue->AwaitShutdownAndIdle(); - promise->MaybeResolve(NS_LITERAL_STRING("No; Failed to initialize H264 decoder")); - }); - - return promise.forget(); + bool result = decoder->IsHardwareAccelerated(aFailureReason); + decoder->Shutdown(); + return result; } void -- cgit v1.2.3