Changeset 151558 in webkit


Ignore:
Timestamp:
Jun 13, 2013 10:03:17 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Avoid unwanted thread hops in ScriptProcessorNode when 'onaudioprocess' listener is not set.
https://bugs.webkit.org/show_bug.cgi?id=117578.

Patch by Praveen R Jadhav <praveen.j@samsung.com> on 2013-06-13
Reviewed by Darin Adler.

ScriptProcessorNode process operation continues to dispatch AudioProcessingEvent
even though 'onaudioprocess' listener is not set. This results in unwanted thread hops.
Code is optimized to dispatch AudioProcessingEvent only if the listener is set.

No new tests, already covered by existing tests.

  • Modules/webaudio/ScriptProcessorNode.cpp:

(WebCore::ScriptProcessorNode::ScriptProcessorNode):
(WebCore::ScriptProcessorNode::process):
(WebCore::ScriptProcessorNode::setOnaudioprocess):

  • Modules/webaudio/ScriptProcessorNode.h:

(WebCore::ScriptProcessorNode::onaudioprocess):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r151555 r151558  
     12013-06-13  Praveen R Jadhav  <praveen.j@samsung.com>
     2
     3        Avoid unwanted thread hops in ScriptProcessorNode when 'onaudioprocess' listener is not set.
     4        https://bugs.webkit.org/show_bug.cgi?id=117578.
     5
     6        Reviewed by Darin Adler.
     7
     8        ScriptProcessorNode process operation continues to dispatch AudioProcessingEvent
     9        even though 'onaudioprocess' listener is not set. This results in unwanted thread hops.
     10        Code is optimized to dispatch AudioProcessingEvent only if the listener is set.
     11
     12        No new tests, already covered by existing tests.
     13
     14        * Modules/webaudio/ScriptProcessorNode.cpp:
     15        (WebCore::ScriptProcessorNode::ScriptProcessorNode):
     16        (WebCore::ScriptProcessorNode::process):
     17        (WebCore::ScriptProcessorNode::setOnaudioprocess):
     18        * Modules/webaudio/ScriptProcessorNode.h:
     19        (WebCore::ScriptProcessorNode::onaudioprocess):
     20
    1212013-06-13  Max Vujovic  <mvujovic@adobe.com>
    222
  • trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp

    r150810 r151558  
    8181    , m_numberOfOutputChannels(numberOfOutputChannels)
    8282    , m_internalInputBus(AudioBus::create(numberOfInputChannels, AudioNode::ProcessingSizeInFrames, false))
     83    , m_hasAudioProcessListener(false)
    8384{
    8485    // Regardless of the allowed buffer sizes, we still need to process at the granularity of the AudioNode.
     
    139140    // This node is the producer for inputBuffer and the consumer for outputBuffer.
    140141    // The JavaScript code is the consumer of inputBuffer and the producer for outputBuffer.
    141    
     142
     143    // Check if audioprocess listener is set.
     144    if (!m_hasAudioProcessListener)
     145        return;
     146
    142147    // Get input and output busses.
    143148    AudioBus* inputBus = this->input(0)->bus();
     
    215220}
    216221
     222void ScriptProcessorNode::setOnaudioprocess(PassRefPtr<EventListener> listener)
     223{
     224    m_hasAudioProcessListener = listener;
     225    setAttributeEventListener(eventNames().audioprocessEvent, listener);
     226}
     227
    217228void ScriptProcessorNode::fireProcessEventDispatch(void* userData)
    218229{
  • trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.h

    r150810 r151558  
    6666    size_t bufferSize() const { return m_bufferSize; }
    6767
    68     DEFINE_ATTRIBUTE_EVENT_LISTENER(audioprocess);
     68    EventListener* onaudioprocess() { return getAttributeEventListener(eventNames().audioprocessEvent); }
     69    void setOnaudioprocess(PassRefPtr<EventListener>);
    6970   
    7071private:
     
    9394
    9495    RefPtr<AudioBus> m_internalInputBus;
     96    bool m_hasAudioProcessListener;
    9597};
    9698
Note: See TracChangeset for help on using the changeset viewer.