summaryrefslogtreecommitdiff
path: root/dom/media/fmp4
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2022-05-17 00:13:54 -0500
committerMatt A. Tobin <email@mattatobin.com>2022-05-17 00:14:28 -0500
commitd5b9a341b8fc83017590d4a435bee27c5a106c66 (patch)
tree25151a190a3a9407c2e4ac00701b8ffb8961b086 /dom/media/fmp4
parentd4ee07aad33c1e6817f558c46e849a7f0143bda2 (diff)
downloadaura-central-d5b9a341b8fc83017590d4a435bee27c5a106c66.tar.gz
[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.
Diffstat (limited to 'dom/media/fmp4')
-rw-r--r--dom/media/fmp4/MP4Decoder.cpp56
-rw-r--r--dom/media/fmp4/MP4Decoder.h3
2 files changed, 9 insertions, 50 deletions
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<dom::Promise>
-MP4Decoder::IsVideoAccelerated(layers::KnowsCompositor* aKnowsCompositor, nsIGlobalObject* aParent)
+/* static */ bool
+MP4Decoder::IsVideoAccelerated(layers::KnowsCompositor* aKnowsCompositor, nsACString& aFailureReason)
{
- MOZ_ASSERT(NS_IsMainThread());
-
- ErrorResult rv;
- RefPtr<dom::Promise> promise;
- promise = dom::Promise::Create(aParent, rv);
- if (rv.Failed()) {
- rv.SuppressException();
- return nullptr;
- }
-
- RefPtr<TaskQueue> taskQueue =
- new TaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER));
VideoInfo config;
- RefPtr<MediaDataDecoder> decoder(CreateTestH264Decoder(aKnowsCompositor, config, taskQueue));
+ RefPtr<MediaDataDecoder> 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
diff --git a/dom/media/fmp4/MP4Decoder.h b/dom/media/fmp4/MP4Decoder.h
index ad5fba7b5..def4b4f99 100644
--- a/dom/media/fmp4/MP4Decoder.h
+++ b/dom/media/fmp4/MP4Decoder.h
@@ -48,8 +48,7 @@ public:
// Returns true if the MP4 backend is preffed on.
static bool IsEnabled();
- static already_AddRefed<dom::Promise>
- IsVideoAccelerated(layers::KnowsCompositor* aKnowsCompositor, nsIGlobalObject* aParent);
+ static bool IsVideoAccelerated(layers::KnowsCompositor* aKnowsCompositor, nsACString& aFailureReason);
void GetMozDebugReaderData(nsAString& aString) override;