Use GenericEventQueue rather than callOnMainThread to schedule events in AudioSchedul...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jan 2017 22:14:44 +0000 (22:14 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jan 2017 22:14:44 +0000 (22:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166983

Reviewed by Brent Fulgham.

* Modules/webaudio/AudioScheduledSourceNode.cpp:
(WebCore::AudioScheduledSourceNode::AudioScheduledSourceNode):
(WebCore::AudioScheduledSourceNode::finish):
* Modules/webaudio/AudioScheduledSourceNode.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210680 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp
Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.h

index eb4f3a7..ee4f905 100644 (file)
@@ -1,3 +1,15 @@
+2017-01-12  Jer Noble  <jer.noble@apple.com>
+
+        Use GenericEventQueue rather than callOnMainThread to schedule events in AudioScheduledSourceNode.
+        https://bugs.webkit.org/show_bug.cgi?id=166983
+
+        Reviewed by Brent Fulgham.
+
+        * Modules/webaudio/AudioScheduledSourceNode.cpp:
+        (WebCore::AudioScheduledSourceNode::AudioScheduledSourceNode):
+        (WebCore::AudioScheduledSourceNode::finish):
+        * Modules/webaudio/AudioScheduledSourceNode.h:
+
 2017-01-12  Youenn Fablet  <youenn@apple.com>
 
         OneDrive application crashes upon launch
index 7566aa2..f4c54d0 100644 (file)
@@ -47,6 +47,7 @@ const double AudioScheduledSourceNode::UnknownTime = -1;
 AudioScheduledSourceNode::AudioScheduledSourceNode(AudioContext& context, float sampleRate)
     : AudioNode(context, sampleRate)
     , m_endTime(UnknownTime)
+    , m_eventQueue(*this)
 {
 }
 
@@ -166,11 +167,8 @@ void AudioScheduledSourceNode::finish()
         context().decrementActiveSourceCount();
     }
 
-    if (m_hasEndedListener) {
-        callOnMainThread([this] {
-            dispatchEvent(Event::create(eventNames().endedEvent, false, false));
-        });
-    }
+    if (m_hasEndedListener)
+        m_eventQueue.enqueueEvent(Event::create(eventNames().endedEvent, false, false));
 }
 
 bool AudioScheduledSourceNode::addEventListener(const AtomicString& eventType, Ref<EventListener>&& listener, const AddEventListenerOptions& options)
index f6a1b2c..59ab915 100644 (file)
@@ -29,6 +29,7 @@
 #pragma once
 
 #include "AudioNode.h"
+#include "GenericEventQueue.h"
 
 namespace WebCore {
 
@@ -83,6 +84,7 @@ protected:
     double m_endTime; // in seconds
 
     bool m_hasEndedListener { false };
+    GenericEventQueue m_eventQueue;
 
     static const double UnknownTime;