Commit c51f9c3b authored by crogers@google.com's avatar crogers@google.com

HRTFDatabaseLoader should not call WTF::waitForThreadCompletion() more than once

https://bugs.webkit.org/show_bug.cgi?id=67866

Reviewed by David Levin.

No new tests since this is difficult to test.
This is designed to fix existing webaudio layout test failures.

* platform/audio/HRTFDatabaseLoader.cpp:
(WebCore::HRTFDatabaseLoader::HRTFDatabaseLoader):
(WebCore::HRTFDatabaseLoader::~HRTFDatabaseLoader):
(WebCore::HRTFDatabaseLoader::loadAsynchronously):
(WebCore::HRTFDatabaseLoader::waitForLoaderThreadCompletion):
* platform/audio/HRTFDatabaseLoader.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@94893 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0fe41f35
2011-09-09 Chris Rogers <crogers@google.com>
HRTFDatabaseLoader should not call WTF::waitForThreadCompletion() more than once
https://bugs.webkit.org/show_bug.cgi?id=67866
Reviewed by David Levin.
No new tests since this is difficult to test.
This is designed to fix existing webaudio layout test failures.
* platform/audio/HRTFDatabaseLoader.cpp:
(WebCore::HRTFDatabaseLoader::HRTFDatabaseLoader):
(WebCore::HRTFDatabaseLoader::~HRTFDatabaseLoader):
(WebCore::HRTFDatabaseLoader::loadAsynchronously):
(WebCore::HRTFDatabaseLoader::waitForLoaderThreadCompletion):
* platform/audio/HRTFDatabaseLoader.h:
2011-09-09 Jessie Berlin <jberlin@apple.com>
Cookies are not available after turning off Private Browsing after the last window has been
......@@ -61,7 +61,6 @@ PassRefPtr<HRTFDatabaseLoader> HRTFDatabaseLoader::createAndLoadAsynchronouslyIf
HRTFDatabaseLoader::HRTFDatabaseLoader(double sampleRate)
: m_databaseLoaderThread(0)
, m_startedLoadingDatabase(false)
, m_databaseSampleRate(sampleRate)
{
ASSERT(isMainThread());
......@@ -71,12 +70,7 @@ HRTFDatabaseLoader::~HRTFDatabaseLoader()
{
ASSERT(isMainThread());
if (m_startedLoadingDatabase)
waitForThreadCompletion(m_databaseLoaderThread, 0);
m_startedLoadingDatabase = false;
m_databaseLoaderThread = 0;
waitForLoaderThreadCompletion();
m_hrtfDatabase.clear();
// Clear out singleton.
......@@ -107,10 +101,11 @@ void HRTFDatabaseLoader::load()
void HRTFDatabaseLoader::loadAsynchronously()
{
ASSERT(isMainThread());
MutexLocker locker(m_threadLock);
if (!m_hrtfDatabase.get() && !m_startedLoadingDatabase) {
if (!m_hrtfDatabase.get() && !m_databaseLoaderThread) {
// Start the asynchronous database loading process.
m_startedLoadingDatabase = true;
m_databaseLoaderThread = createThread(databaseLoaderEntry, this, "HRTF database loader");
}
}
......@@ -120,12 +115,14 @@ bool HRTFDatabaseLoader::isLoaded() const
return m_hrtfDatabase.get();
}
void HRTFDatabaseLoader::waitForLoaderThreadCompletion()
{
ASSERT(!isMainThread());
ASSERT(m_databaseLoaderThread);
waitForThreadCompletion(m_databaseLoaderThread, 0);
MutexLocker locker(m_threadLock);
// waitForThreadCompletion() should not be called twice for the same thread.
if (m_databaseLoaderThread)
waitForThreadCompletion(m_databaseLoaderThread, 0);
m_databaseLoaderThread = 0;
}
HRTFDatabase* HRTFDatabaseLoader::defaultHRTFDatabase()
......
......@@ -55,8 +55,7 @@ public:
// Returns true once the default database has been completely loaded.
bool isLoaded() const;
// May not be called on the main thread.
// This is so a different background thread may synchronize with the loader thread.
// waitForLoaderThreadCompletion() may be called more than once and is thread-safe.
void waitForLoaderThreadCompletion();
HRTFDatabase* database() { return m_hrtfDatabase.get(); }
......@@ -81,12 +80,14 @@ private:
static HRTFDatabaseLoader* s_loader; // singleton
OwnPtr<HRTFDatabase> m_hrtfDatabase;
// Holding a m_threadLock is required when accessing m_databaseLoaderThread.
Mutex m_threadLock;
ThreadIdentifier m_databaseLoaderThread;
bool m_startedLoadingDatabase;
double m_databaseSampleRate;
};
} // namespace WebCore
#endif // HRTFDatabaseLoader_h
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment