Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(881)

Unified Diff: Source/core/platform/audio/HRTFDatabaseLoader.h

Issue 14636011: Support multiple HRTFDatabases for different sample-rates (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add ASSERT(isMainThread()) Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/platform/audio/HRTFDatabaseLoader.h
diff --git a/Source/core/platform/audio/HRTFDatabaseLoader.h b/Source/core/platform/audio/HRTFDatabaseLoader.h
index 4562db7665e52b54512937aaab2486f5484cf62d..701ddb35862383c6ddd2bba5a7309310fd33c4b2 100644
--- a/Source/core/platform/audio/HRTFDatabaseLoader.h
+++ b/Source/core/platform/audio/HRTFDatabaseLoader.h
@@ -30,10 +30,11 @@
#define HRTFDatabaseLoader_h
#include "core/platform/audio/HRTFDatabase.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/Threading.h>
+#include "wtf/HashMap.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/Threading.h"
namespace WebCore {
@@ -41,14 +42,12 @@ namespace WebCore {
class HRTFDatabaseLoader : public RefCounted<HRTFDatabaseLoader> {
public:
- // Lazily creates the singleton HRTFDatabaseLoader (if not already created) and starts loading asynchronously (when created the first time).
- // Returns the singleton HRTFDatabaseLoader.
+ // Lazily creates a HRTFDatabaseLoader (if not already created) for the given sample-rate
+ // and starts loading asynchronously (when created the first time).
+ // Returns the HRTFDatabaseLoader.
// Must be called from the main thread.
static PassRefPtr<HRTFDatabaseLoader> createAndLoadAsynchronouslyIfNecessary(float sampleRate);
- // Returns the singleton HRTFDatabaseLoader.
- static HRTFDatabaseLoader* loader() { return s_loader; }
-
// Both constructor and destructor must be called from the main thread.
~HRTFDatabaseLoader();
@@ -65,13 +64,16 @@ public:
// Called in asynchronous loading thread.
void load();
- // defaultHRTFDatabase() gives access to the loaded database.
- // This can be called from any thread, but it is the callers responsibilty to call this while the context (and thus HRTFDatabaseLoader)
- // is still alive. Otherwise this will return 0.
- static HRTFDatabase* defaultHRTFDatabase();
-
void reportMemoryUsage(MemoryObjectInfo*) const;
+ // Map from sample-rate to loader.
+ class LoaderMap : public HashMap<double, HRTFDatabaseLoader*> {
+ public:
+ void reportMemoryUsage(MemoryObjectInfo*) const;
+ };
+
+ static HRTFDatabaseLoader::LoaderMap* loaderMap() { return s_loaderMap; }
+
private:
// Both constructor and destructor must be called from the main thread.
explicit HRTFDatabaseLoader(float sampleRate);
@@ -80,7 +82,9 @@ private:
// This must be called from the main thread.
void loadAsynchronously();
- static HRTFDatabaseLoader* s_loader; // singleton
+ // Keeps track of loaders on a per-sample-rate basis.
+ static LoaderMap* s_loaderMap; // singleton
+
OwnPtr<HRTFDatabase> m_hrtfDatabase;
// Holding a m_threadLock is required when accessing m_databaseLoaderThread.
« no previous file with comments | « Source/core/platform/PlatformMemoryInstrumentation.cpp ('k') | Source/core/platform/audio/HRTFDatabaseLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698