Changeset 94893 in webkit


Ignore:
Timestamp:
Sep 9, 2011 5:59:43 PM (13 years ago)
Author:
crogers@google.com
Message:

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:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r94892 r94893  
     12011-09-09  Chris Rogers  <crogers@google.com>
     2
     3        HRTFDatabaseLoader should not call WTF::waitForThreadCompletion() more than once
     4        https://bugs.webkit.org/show_bug.cgi?id=67866
     5
     6        Reviewed by David Levin.
     7
     8        No new tests since this is difficult to test.
     9        This is designed to fix existing webaudio layout test failures.
     10
     11        * platform/audio/HRTFDatabaseLoader.cpp:
     12        (WebCore::HRTFDatabaseLoader::HRTFDatabaseLoader):
     13        (WebCore::HRTFDatabaseLoader::~HRTFDatabaseLoader):
     14        (WebCore::HRTFDatabaseLoader::loadAsynchronously):
     15        (WebCore::HRTFDatabaseLoader::waitForLoaderThreadCompletion):
     16        * platform/audio/HRTFDatabaseLoader.h:
     17
    1182011-09-09  Jessie Berlin  <jberlin@apple.com>
    219
  • trunk/Source/WebCore/platform/audio/HRTFDatabaseLoader.cpp

    r92068 r94893  
    6262HRTFDatabaseLoader::HRTFDatabaseLoader(double sampleRate)
    6363    : m_databaseLoaderThread(0)
    64     , m_startedLoadingDatabase(false)
    6564    , m_databaseSampleRate(sampleRate)
    6665{
     
    7271    ASSERT(isMainThread());
    7372
    74     if (m_startedLoadingDatabase)
    75         waitForThreadCompletion(m_databaseLoaderThread, 0);
    76    
    77     m_startedLoadingDatabase = false;
    78     m_databaseLoaderThread = 0;
    79    
     73    waitForLoaderThreadCompletion();
    8074    m_hrtfDatabase.clear();
    8175   
     
    108102{
    109103    ASSERT(isMainThread());
     104
     105    MutexLocker locker(m_threadLock);
    110106   
    111     if (!m_hrtfDatabase.get() && !m_startedLoadingDatabase) {
     107    if (!m_hrtfDatabase.get() && !m_databaseLoaderThread) {
    112108        // Start the asynchronous database loading process.
    113         m_startedLoadingDatabase = true;
    114109        m_databaseLoaderThread = createThread(databaseLoaderEntry, this, "HRTF database loader");
    115110    }
     
    121116}
    122117
    123 
    124118void HRTFDatabaseLoader::waitForLoaderThreadCompletion()
    125119{
    126     ASSERT(!isMainThread());
    127     ASSERT(m_databaseLoaderThread);
    128     waitForThreadCompletion(m_databaseLoaderThread, 0);   
     120    MutexLocker locker(m_threadLock);
     121   
     122    // waitForThreadCompletion() should not be called twice for the same thread.
     123    if (m_databaseLoaderThread)
     124        waitForThreadCompletion(m_databaseLoaderThread, 0);
     125    m_databaseLoaderThread = 0;
    129126}
    130127
  • trunk/Source/WebCore/platform/audio/HRTFDatabaseLoader.h

    r90839 r94893  
    5656    bool isLoaded() const;
    5757
    58     // May not be called on the main thread.
    59     // This is so a different background thread may synchronize with the loader thread.
     58    // waitForLoaderThreadCompletion() may be called more than once and is thread-safe.
    6059    void waitForLoaderThreadCompletion();
    6160   
     
    8281    static HRTFDatabaseLoader* s_loader; // singleton
    8382    OwnPtr<HRTFDatabase> m_hrtfDatabase;
     83
     84    // Holding a m_threadLock is required when accessing m_databaseLoaderThread.
     85    Mutex m_threadLock;
    8486    ThreadIdentifier m_databaseLoaderThread;
    85     bool m_startedLoadingDatabase;
     87
    8688    double m_databaseSampleRate;   
    8789};
    88 
    8990
    9091} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.