Changeset 142687 in webkit


Ignore:
Timestamp:
Feb 12, 2013 4:10:45 PM (11 years ago)
Author:
Raymond Toy
Message:

Synchronize setting of panner node model and processing
https://bugs.webkit.org/show_bug.cgi?id=109599

Reviewed by Chris Rogers.

No new tests.

  • Modules/webaudio/PannerNode.cpp:

(WebCore::PannerNode::process):
(WebCore::PannerNode::setPanningModel):

  • Modules/webaudio/PannerNode.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142685 r142687  
     12013-02-12  Raymond Toy  <rtoy@google.com>
     2
     3        Synchronize setting of panner node model and processing
     4        https://bugs.webkit.org/show_bug.cgi?id=109599
     5
     6        Reviewed by Chris Rogers.
     7
     8        No new tests.
     9
     10        * Modules/webaudio/PannerNode.cpp:
     11        (WebCore::PannerNode::process):
     12        (WebCore::PannerNode::setPanningModel):
     13        * Modules/webaudio/PannerNode.h:
     14
    1152013-02-12  Dean Jackson  <dino@apple.com>
    216
  • trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp

    r138849 r142687  
    105105    }
    106106
    107     // Apply the panning effect.
    108     double azimuth;
    109     double elevation;
    110     getAzimuthElevation(&azimuth, &elevation);
    111     m_panner->pan(azimuth, elevation, source, destination, framesToProcess);
    112 
    113     // Get the distance and cone gain.
    114     double totalGain = distanceConeGain();
    115 
    116     // Snap to desired gain at the beginning.
    117     if (m_lastGain == -1.0)
    118         m_lastGain = totalGain;
     107    // The audio thread can't block on this lock, so we call tryLock() instead.
     108    MutexTryLocker tryLocker(m_pannerLock);
     109    if (tryLocker.locked()) {
     110        // Apply the panning effect.
     111        double azimuth;
     112        double elevation;
     113        getAzimuthElevation(&azimuth, &elevation);
     114        m_panner->pan(azimuth, elevation, source, destination, framesToProcess);
     115
     116        // Get the distance and cone gain.
     117        double totalGain = distanceConeGain();
     118
     119        // Snap to desired gain at the beginning.
     120        if (m_lastGain == -1.0)
     121            m_lastGain = totalGain;
    119122       
    120     // Apply gain in-place with de-zippering.
    121     destination->copyWithGainFrom(*destination, &m_lastGain, totalGain);
     123        // Apply gain in-place with de-zippering.
     124        destination->copyWithGainFrom(*destination, &m_lastGain, totalGain);
     125    } else {
     126        // Too bad - The tryLock() failed. We must be in the middle of changing the panner.
     127        destination->zero();
     128    }
    122129}
    123130
     
    186193    case HRTF:
    187194        if (!m_panner.get() || model != m_panningModel) {
     195            // This synchronizes with process().
     196            MutexLocker processLocker(m_pannerLock);
     197           
    188198            OwnPtr<Panner> newPanner = Panner::create(model, sampleRate());
    189199            m_panner = newPanner.release();
  • trunk/Source/WebCore/Modules/webaudio/PannerNode.h

    r141867 r142687  
    155155
    156156    unsigned m_connectionCount;
     157
     158    // Synchronize process() and setPanningModel() which can change the panner.
     159    mutable Mutex m_pannerLock;
    157160};
    158161
Note: See TracChangeset for help on using the changeset viewer.