OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 float databaseSampleRate() const { return m_databaseSampleRate; } | 63 float databaseSampleRate() const { return m_databaseSampleRate; } |
64 | 64 |
65 // Called in asynchronous loading thread. | 65 // Called in asynchronous loading thread. |
66 void load(); | 66 void load(); |
67 | 67 |
68 // defaultHRTFDatabase() gives access to the loaded database. | 68 // defaultHRTFDatabase() gives access to the loaded database. |
69 // This can be called from any thread, but it is the callers responsibilty t
o call this while the context (and thus HRTFDatabaseLoader) | 69 // This can be called from any thread, but it is the callers responsibilty t
o call this while the context (and thus HRTFDatabaseLoader) |
70 // is still alive. Otherwise this will return 0. | 70 // is still alive. Otherwise this will return 0. |
71 static HRTFDatabase* defaultHRTFDatabase(); | 71 static HRTFDatabase* defaultHRTFDatabase(); |
72 | 72 |
73 void reportMemoryUsage(MemoryObjectInfo*) const; | |
74 | |
75 private: | 73 private: |
76 // Both constructor and destructor must be called from the main thread. | 74 // Both constructor and destructor must be called from the main thread. |
77 explicit HRTFDatabaseLoader(float sampleRate); | 75 explicit HRTFDatabaseLoader(float sampleRate); |
78 | 76 |
79 // If it hasn't already been loaded, creates a new thread and initiates asyn
chronous loading of the default database. | 77 // If it hasn't already been loaded, creates a new thread and initiates asyn
chronous loading of the default database. |
80 // This must be called from the main thread. | 78 // This must be called from the main thread. |
81 void loadAsynchronously(); | 79 void loadAsynchronously(); |
82 | 80 |
83 static HRTFDatabaseLoader* s_loader; // singleton | 81 static HRTFDatabaseLoader* s_loader; // singleton |
84 OwnPtr<HRTFDatabase> m_hrtfDatabase; | 82 OwnPtr<HRTFDatabase> m_hrtfDatabase; |
85 | 83 |
86 // Holding a m_threadLock is required when accessing m_databaseLoaderThread. | 84 // Holding a m_threadLock is required when accessing m_databaseLoaderThread. |
87 Mutex m_threadLock; | 85 Mutex m_threadLock; |
88 ThreadIdentifier m_databaseLoaderThread; | 86 ThreadIdentifier m_databaseLoaderThread; |
89 | 87 |
90 float m_databaseSampleRate; | 88 float m_databaseSampleRate; |
91 }; | 89 }; |
92 | 90 |
93 } // namespace WebCore | 91 } // namespace WebCore |
94 | 92 |
95 #endif // HRTFDatabaseLoader_h | 93 #endif // HRTFDatabaseLoader_h |
OLD | NEW |