#include "modules/webaudio/AudioScheduledSourceNode.h"
-#include "bindings/v8/ExceptionState.h"
+#include "bindings/core/v8/ExceptionState.h"
+#include "core/dom/CrossThreadTask.h"
#include "core/dom/ExceptionCode.h"
#include "modules/EventModules.h"
#include "modules/webaudio/AudioContext.h"
#include "platform/audio/AudioUtilities.h"
-#include <algorithm>
#include "wtf/MathExtras.h"
+#include <algorithm>
-using namespace std;
+namespace blink {
-namespace WebCore {
+#if !ENABLE(OILPAN)
+// We need a dedicated specialization for AudioScheduledSourceNode because it
+// doesn't inherit from RefCounted.
+template<> struct CrossThreadCopierBase<false, false, false, PassRefPtr<AudioScheduledSourceNode> > : public CrossThreadCopierPassThrough<PassRefPtr<AudioScheduledSourceNode> > {
+};
+#endif
const double AudioScheduledSourceNode::UnknownTime = -1;
}
quantumFrameOffset = startFrame > quantumStartFrame ? startFrame - quantumStartFrame : 0;
- quantumFrameOffset = min(quantumFrameOffset, quantumFrameSize); // clamp to valid range
+ quantumFrameOffset = std::min(quantumFrameOffset, quantumFrameSize); // clamp to valid range
nonSilentFramesToProcess = quantumFrameSize - quantumFrameOffset;
if (!nonSilentFramesToProcess) {
// stop() can be called more than once, with the last call to stop taking effect, unless the
// source has already stopped due to earlier calls to stop. No exceptions are thrown in any
// case.
- when = max(0.0, when);
+ when = std::max(0.0, when);
m_endTime = when;
}
}
m_playbackState = FINISHED_STATE;
}
- if (m_hasEndedListener) {
- // |task| will keep the AudioScheduledSourceNode alive until the listener has been handled.
- OwnPtr<NotifyEndedTask> task = adoptPtr(new NotifyEndedTask(this));
- callOnMainThread(&AudioScheduledSourceNode::notifyEndedDispatch, task.leakPtr());
+ if (m_hasEndedListener && context()->executionContext()) {
+ context()->executionContext()->postTask(createCrossThreadTask(&AudioScheduledSourceNode::notifyEnded, PassRefPtrWillBeRawPtr<AudioScheduledSourceNode>(this)));
}
}
-void AudioScheduledSourceNode::notifyEndedDispatch(void* userData)
-{
- OwnPtr<NotifyEndedTask> task = adoptPtr(static_cast<NotifyEndedTask*>(userData));
-
- task->notifyEnded();
-}
-
-AudioScheduledSourceNode::NotifyEndedTask::NotifyEndedTask(PassRefPtr<AudioScheduledSourceNode> sourceNode)
- : m_scheduledNode(sourceNode)
-{
-}
-
-void AudioScheduledSourceNode::NotifyEndedTask::notifyEnded()
+void AudioScheduledSourceNode::notifyEnded()
{
- RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::ended);
- event->setTarget(m_scheduledNode.get());
- m_scheduledNode->dispatchEvent(event.get());
+ dispatchEvent(Event::create(EventTypeNames::ended));
}
-} // namespace WebCore
+} // namespace blink
#endif // ENABLE(WEB_AUDIO)