| 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 namespace WebCore { | 39 namespace WebCore { |
| 40 | 40 |
| 41 // Singleton | 41 // Singleton |
| 42 HRTFDatabaseLoader::LoaderMap* HRTFDatabaseLoader::s_loaderMap = 0; | 42 HRTFDatabaseLoader::LoaderMap* HRTFDatabaseLoader::s_loaderMap = 0; |
| 43 | 43 |
| 44 PassRefPtr<HRTFDatabaseLoader> HRTFDatabaseLoader::createAndLoadAsynchronouslyIf
Necessary(float sampleRate) | 44 PassRefPtr<HRTFDatabaseLoader> HRTFDatabaseLoader::createAndLoadAsynchronouslyIf
Necessary(float sampleRate) |
| 45 { | 45 { |
| 46 ASSERT(isMainThread()); | 46 ASSERT(isMainThread()); |
| 47 | 47 |
| 48 RefPtr<HRTFDatabaseLoader> loader; | |
| 49 | |
| 50 if (!s_loaderMap) | 48 if (!s_loaderMap) |
| 51 s_loaderMap = adoptPtr(new LoaderMap()).leakPtr(); | 49 s_loaderMap = adoptPtr(new LoaderMap()).leakPtr(); |
| 52 | 50 |
| 53 loader = s_loaderMap->get(sampleRate); | 51 RefPtr<HRTFDatabaseLoader> loader = s_loaderMap->get(sampleRate); |
| 54 if (loader) { | 52 if (loader) { |
| 55 ASSERT(sampleRate == loader->databaseSampleRate()); | 53 ASSERT(sampleRate == loader->databaseSampleRate()); |
| 56 return loader; | 54 return loader; |
| 57 } | 55 } |
| 58 | 56 |
| 59 loader = adoptRef(new HRTFDatabaseLoader(sampleRate)); | 57 loader = adoptRef(new HRTFDatabaseLoader(sampleRate)); |
| 60 s_loaderMap->add(sampleRate, loader.get()); | 58 s_loaderMap->add(sampleRate, loader.get()); |
| 61 | 59 |
| 62 loader->loadAsynchronously(); | 60 loader->loadAsynchronously(); |
| 63 | 61 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 109 |
| 112 void HRTFDatabaseLoader::waitForLoaderThreadCompletion() | 110 void HRTFDatabaseLoader::waitForLoaderThreadCompletion() |
| 113 { | 111 { |
| 114 MutexLocker locker(m_threadLock); | 112 MutexLocker locker(m_threadLock); |
| 115 m_databaseLoaderThread.clear(); | 113 m_databaseLoaderThread.clear(); |
| 116 } | 114 } |
| 117 | 115 |
| 118 } // namespace WebCore | 116 } // namespace WebCore |
| 119 | 117 |
| 120 #endif // ENABLE(WEB_AUDIO) | 118 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |