Title: [151558] trunk/Source/WebCore
Revision
151558
Author
[email protected]
Date
2013-06-13 10:03:17 -0700 (Thu, 13 Jun 2013)

Log 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 <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (151557 => 151558)


--- trunk/Source/WebCore/ChangeLog	2013-06-13 17:02:36 UTC (rev 151557)
+++ trunk/Source/WebCore/ChangeLog	2013-06-13 17:03:17 UTC (rev 151558)
@@ -1,3 +1,23 @@
+2013-06-13  Praveen R Jadhav  <[email protected]>
+
+        Avoid unwanted thread hops in ScriptProcessorNode when 'onaudioprocess' listener is not set.
+        https://bugs.webkit.org/show_bug.cgi?id=117578.
+
+        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):
+
 2013-06-13  Max Vujovic  <[email protected]>
 
         [CSS Regions] -webkit-background-clip: text; does not clip the background in regions

Modified: trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp (151557 => 151558)


--- trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp	2013-06-13 17:02:36 UTC (rev 151557)
+++ trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp	2013-06-13 17:03:17 UTC (rev 151558)
@@ -80,6 +80,7 @@
     , m_numberOfInputChannels(numberOfInputChannels)
     , m_numberOfOutputChannels(numberOfOutputChannels)
     , m_internalInputBus(AudioBus::create(numberOfInputChannels, AudioNode::ProcessingSizeInFrames, false))
+    , m_hasAudioProcessListener(false)
 {
     // Regardless of the allowed buffer sizes, we still need to process at the granularity of the AudioNode.
     if (m_bufferSize < AudioNode::ProcessingSizeInFrames)
@@ -138,7 +139,11 @@
     // Additionally, there is a double-buffering for input and output which is exposed directly to _javascript_ (see inputBuffer and outputBuffer below).
     // This node is the producer for inputBuffer and the consumer for outputBuffer.
     // The _javascript_ code is the consumer of inputBuffer and the producer for outputBuffer.
-    
+
+    // Check if audioprocess listener is set.
+    if (!m_hasAudioProcessListener)
+        return;
+
     // Get input and output busses.
     AudioBus* inputBus = this->input(0)->bus();
     AudioBus* outputBus = this->output(0)->bus();
@@ -214,6 +219,12 @@
     }
 }
 
+void ScriptProcessorNode::setOnaudioprocess(PassRefPtr<EventListener> listener)
+{
+    m_hasAudioProcessListener = listener;
+    setAttributeEventListener(eventNames().audioprocessEvent, listener);
+}
+
 void ScriptProcessorNode::fireProcessEventDispatch(void* userData)
 {
     ScriptProcessorNode* jsAudioNode = static_cast<ScriptProcessorNode*>(userData);

Modified: trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.h (151557 => 151558)


--- trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.h	2013-06-13 17:02:36 UTC (rev 151557)
+++ trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.h	2013-06-13 17:03:17 UTC (rev 151558)
@@ -65,7 +65,8 @@
 
     size_t bufferSize() const { return m_bufferSize; }
 
-    DEFINE_ATTRIBUTE_EVENT_LISTENER(audioprocess);
+    EventListener* onaudioprocess() { return getAttributeEventListener(eventNames().audioprocessEvent); }
+    void setOnaudioprocess(PassRefPtr<EventListener>);
     
 private:
     virtual double tailTime() const OVERRIDE;
@@ -92,6 +93,7 @@
     unsigned m_numberOfOutputChannels;
 
     RefPtr<AudioBus> m_internalInputBus;
+    bool m_hasAudioProcessListener;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to