diff options
author | Moonchild <moonchild@palemoon.org> | 2020-09-23 02:10:26 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-09-23 02:10:26 +0000 |
commit | f5e5b5c32e9439973a430b7cc0159d754b53dba6 (patch) | |
tree | fe44eb96502fa25d05e58df2d5644ce2f6dd7fae /dom | |
parent | aecdb28300020cb4c900f83931fc0942b25695af (diff) | |
download | UXP-f5e5b5c32e9439973a430b7cc0159d754b53dba6.tar UXP-f5e5b5c32e9439973a430b7cc0159d754b53dba6.tar.gz UXP-f5e5b5c32e9439973a430b7cc0159d754b53dba6.tar.lz UXP-f5e5b5c32e9439973a430b7cc0159d754b53dba6.tar.xz UXP-f5e5b5c32e9439973a430b7cc0159d754b53dba6.zip |
[webaudio] Keep track of whether the HRTF database has already been loaded.
This DiD measure ensures that our async HRTF database loading is completed
before we actually try to use it. If not done, database() simply returns null.
Diffstat (limited to 'dom')
-rw-r--r-- | dom/media/webaudio/blink/HRTFDatabaseLoader.cpp | 3 | ||||
-rw-r--r-- | dom/media/webaudio/blink/HRTFDatabaseLoader.h | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/dom/media/webaudio/blink/HRTFDatabaseLoader.cpp b/dom/media/webaudio/blink/HRTFDatabaseLoader.cpp index 090e1b217..96c53b1cd 100644 --- a/dom/media/webaudio/blink/HRTFDatabaseLoader.cpp +++ b/dom/media/webaudio/blink/HRTFDatabaseLoader.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2020 M. Straver. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -72,6 +73,7 @@ HRTFDatabaseLoader::HRTFDatabaseLoader(float sampleRate) , m_threadLock("HRTFDatabaseLoader") , m_databaseLoaderThread(nullptr) , m_databaseSampleRate(sampleRate) + , m_databaseLoaded(false) { MOZ_ASSERT(NS_IsMainThread()); } @@ -164,6 +166,7 @@ void HRTFDatabaseLoader::load() MOZ_ASSERT(!m_hrtfDatabase.get(), "Called twice"); // Load the default HRTF database. m_hrtfDatabase = HRTFDatabase::create(m_databaseSampleRate); + m_databaseLoaded = true; // Notifies the main thread of completion. See loadAsynchronously(). Release(); } diff --git a/dom/media/webaudio/blink/HRTFDatabaseLoader.h b/dom/media/webaudio/blink/HRTFDatabaseLoader.h index 50a875b18..4dfbd4fc8 100644 --- a/dom/media/webaudio/blink/HRTFDatabaseLoader.h +++ b/dom/media/webaudio/blink/HRTFDatabaseLoader.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2020 M. Straver. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -85,7 +86,12 @@ public: // on any thread except m_databaseLoaderThread. void waitForLoaderThreadCompletion(); - HRTFDatabase* database() { return m_hrtfDatabase.get(); } + HRTFDatabase* database() { + if (!m_databaseLoaded) { + return nullptr; + } + return m_hrtfDatabase.get(); + } float databaseSampleRate() const { return m_databaseSampleRate; } @@ -141,6 +147,7 @@ private: PRThread* m_databaseLoaderThread; float m_databaseSampleRate; + mozilla::Atomic<bool> m_databaseLoaded; }; } // namespace WebCore |