зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1324568 - Implement AudioScheduledSourceNode, r=padenot
This commit is contained in:
Родитель
de7438cf52
Коммит
60364b27c9
|
@ -22,13 +22,15 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(AudioBufferSourceNode, AudioNode, mBuffer, mPlaybackRate, mDetune)
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(AudioBufferSourceNode,
|
||||
AudioScheduledSourceNode, mBuffer,
|
||||
mPlaybackRate, mDetune)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(AudioBufferSourceNode)
|
||||
NS_INTERFACE_MAP_END_INHERITING(AudioNode)
|
||||
NS_INTERFACE_MAP_END_INHERITING(AudioScheduledSourceNode)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(AudioBufferSourceNode, AudioNode)
|
||||
NS_IMPL_RELEASE_INHERITED(AudioBufferSourceNode, AudioNode)
|
||||
NS_IMPL_ADDREF_INHERITED(AudioBufferSourceNode, AudioScheduledSourceNode)
|
||||
NS_IMPL_RELEASE_INHERITED(AudioBufferSourceNode, AudioScheduledSourceNode)
|
||||
|
||||
/**
|
||||
* Media-thread playback engine for AudioBufferSourceNode.
|
||||
|
@ -588,7 +590,7 @@ public:
|
|||
};
|
||||
|
||||
AudioBufferSourceNode::AudioBufferSourceNode(AudioContext* aContext)
|
||||
: AudioNode(aContext,
|
||||
: AudioScheduledSourceNode(aContext,
|
||||
2,
|
||||
ChannelCountMode::Max,
|
||||
ChannelInterpretation::Speakers)
|
||||
|
@ -711,6 +713,12 @@ AudioBufferSourceNode::Start(double aWhen, double aOffset,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
AudioBufferSourceNode::Start(double aWhen, ErrorResult& aRv)
|
||||
{
|
||||
Start(aWhen, 0 /* offset */, Optional<double>(), aRv);
|
||||
}
|
||||
|
||||
void
|
||||
AudioBufferSourceNode::SendBufferParameterToStream(JSContext* aCx)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#ifndef AudioBufferSourceNode_h_
|
||||
#define AudioBufferSourceNode_h_
|
||||
|
||||
#include "AudioNode.h"
|
||||
#include "AudioScheduledSourceNode.h"
|
||||
#include "AudioBuffer.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -16,7 +16,7 @@ namespace dom {
|
|||
struct AudioBufferSourceOptions;
|
||||
class AudioParam;
|
||||
|
||||
class AudioBufferSourceNode final : public AudioNode
|
||||
class AudioBufferSourceNode final : public AudioScheduledSourceNode
|
||||
, public MainThreadMediaStreamListener
|
||||
{
|
||||
public:
|
||||
|
@ -35,7 +35,8 @@ public:
|
|||
return this;
|
||||
}
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioBufferSourceNode, AudioNode)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioBufferSourceNode,
|
||||
AudioScheduledSourceNode)
|
||||
|
||||
static already_AddRefed<AudioBufferSourceNode>
|
||||
Constructor(const GlobalObject& aGlobal, AudioContext& aAudioContext,
|
||||
|
@ -48,7 +49,9 @@ public:
|
|||
|
||||
void Start(double aWhen, double aOffset,
|
||||
const Optional<double>& aDuration, ErrorResult& aRv);
|
||||
void Stop(double aWhen, ErrorResult& aRv);
|
||||
|
||||
void Start(double aWhen, ErrorResult& aRv) override;
|
||||
void Stop(double aWhen, ErrorResult& aRv) override;
|
||||
|
||||
AudioBuffer* GetBuffer(JSContext* aCx) const
|
||||
{
|
||||
|
@ -97,8 +100,6 @@ public:
|
|||
}
|
||||
void SendDopplerShiftToStream(double aDopplerShift);
|
||||
|
||||
IMPL_EVENT_HANDLER(ended)
|
||||
|
||||
void NotifyMainThreadStreamFinished() override;
|
||||
|
||||
const char* NodeType() const override
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "AudioScheduledSourceNode.h"
|
||||
#include "mozilla/dom/AudioScheduledSourceNodeBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
AudioScheduledSourceNode::AudioScheduledSourceNode(AudioContext* aContext,
|
||||
uint32_t aChannelCount,
|
||||
ChannelCountMode aChannelCountMode,
|
||||
ChannelInterpretation aChannelInterpretation)
|
||||
: AudioNode(aContext, aChannelCount, aChannelCountMode,
|
||||
aChannelInterpretation)
|
||||
{}
|
||||
|
||||
JSObject*
|
||||
AudioScheduledSourceNode::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return AudioScheduledSourceNodeBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
} // dom namespace
|
||||
} // mozilla namespace
|
|
@ -0,0 +1,40 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef AudioScheduledSourceNode_h_
|
||||
#define AudioScheduledSourceNode_h_
|
||||
|
||||
#include "AudioNode.h"
|
||||
#include "mozilla/dom/AudioScheduledSourceNodeBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class AudioContext;
|
||||
|
||||
class AudioScheduledSourceNode : public AudioNode
|
||||
{
|
||||
public:
|
||||
JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
virtual void Start(double aWhen, ErrorResult& aRv) = 0;
|
||||
virtual void Stop(double aWhen, ErrorResult& aRv) = 0;
|
||||
|
||||
IMPL_EVENT_HANDLER(ended)
|
||||
|
||||
protected:
|
||||
AudioScheduledSourceNode(AudioContext* aContext,
|
||||
uint32_t aChannelCount,
|
||||
ChannelCountMode aChannelCountMode,
|
||||
ChannelInterpretation aChannelInterpretation);
|
||||
virtual ~AudioScheduledSourceNode() = default;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
|
@ -12,14 +12,14 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(ConstantSourceNode, AudioNode,
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(ConstantSourceNode, AudioScheduledSourceNode,
|
||||
mOffset)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ConstantSourceNode)
|
||||
NS_INTERFACE_MAP_END_INHERITING(AudioNode)
|
||||
NS_INTERFACE_MAP_END_INHERITING(AudioScheduledSourceNode)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(ConstantSourceNode, AudioNode)
|
||||
NS_IMPL_RELEASE_INHERITED(ConstantSourceNode, AudioNode)
|
||||
NS_IMPL_ADDREF_INHERITED(ConstantSourceNode, AudioScheduledSourceNode)
|
||||
NS_IMPL_RELEASE_INHERITED(ConstantSourceNode, AudioScheduledSourceNode)
|
||||
|
||||
class ConstantSourceNodeEngine final : public AudioNodeEngine
|
||||
{
|
||||
|
@ -142,7 +142,7 @@ public:
|
|||
};
|
||||
|
||||
ConstantSourceNode::ConstantSourceNode(AudioContext* aContext)
|
||||
: AudioNode(aContext,
|
||||
: AudioScheduledSourceNode(aContext,
|
||||
1,
|
||||
ChannelCountMode::Max,
|
||||
ChannelInterpretation::Speakers)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#ifndef ConstantSourceNode_h_
|
||||
#define ConstantSourceNode_h_
|
||||
|
||||
#include "AudioNode.h"
|
||||
#include "AudioScheduledSourceNode.h"
|
||||
#include "AudioParam.h"
|
||||
#include "mozilla/dom/ConstantSourceNodeBinding.h"
|
||||
|
||||
|
@ -16,14 +16,14 @@ namespace dom {
|
|||
|
||||
class AudioContext;
|
||||
|
||||
class ConstantSourceNode final : public AudioNode,
|
||||
public MainThreadMediaStreamListener
|
||||
class ConstantSourceNode final : public AudioScheduledSourceNode
|
||||
, public MainThreadMediaStreamListener
|
||||
{
|
||||
public:
|
||||
explicit ConstantSourceNode(AudioContext* aContext);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ConstantSourceNode, AudioNode)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ConstantSourceNode, AudioScheduledSourceNode)
|
||||
|
||||
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
|
@ -45,10 +45,8 @@ public:
|
|||
return mOffset;
|
||||
}
|
||||
|
||||
void Start(double aWhen, ErrorResult& rv);
|
||||
void Stop(double aWhen, ErrorResult& rv);
|
||||
|
||||
IMPL_EVENT_HANDLER(ended)
|
||||
void Start(double aWhen, ErrorResult& rv) override;
|
||||
void Stop(double aWhen, ErrorResult& rv) override;
|
||||
|
||||
void NotifyMainThreadStreamFinished() override;
|
||||
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(OscillatorNode, AudioNode,
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(OscillatorNode, AudioScheduledSourceNode,
|
||||
mPeriodicWave, mFrequency, mDetune)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(OscillatorNode)
|
||||
NS_INTERFACE_MAP_END_INHERITING(AudioNode)
|
||||
NS_INTERFACE_MAP_END_INHERITING(AudioScheduledSourceNode)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(OscillatorNode, AudioNode)
|
||||
NS_IMPL_RELEASE_INHERITED(OscillatorNode, AudioNode)
|
||||
NS_IMPL_ADDREF_INHERITED(OscillatorNode, AudioScheduledSourceNode)
|
||||
NS_IMPL_RELEASE_INHERITED(OscillatorNode, AudioScheduledSourceNode)
|
||||
|
||||
class OscillatorNodeEngine final : public AudioNodeEngine
|
||||
{
|
||||
|
@ -408,7 +408,7 @@ public:
|
|||
};
|
||||
|
||||
OscillatorNode::OscillatorNode(AudioContext* aContext)
|
||||
: AudioNode(aContext,
|
||||
: AudioScheduledSourceNode(aContext,
|
||||
2,
|
||||
ChannelCountMode::Max,
|
||||
ChannelInterpretation::Speakers)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#ifndef OscillatorNode_h_
|
||||
#define OscillatorNode_h_
|
||||
|
||||
#include "AudioNode.h"
|
||||
#include "AudioScheduledSourceNode.h"
|
||||
#include "AudioParam.h"
|
||||
#include "PeriodicWave.h"
|
||||
#include "mozilla/dom/OscillatorNodeBinding.h"
|
||||
|
@ -18,8 +18,8 @@ namespace dom {
|
|||
class AudioContext;
|
||||
struct OscillatorOptions;
|
||||
|
||||
class OscillatorNode final : public AudioNode,
|
||||
public MainThreadMediaStreamListener
|
||||
class OscillatorNode final : public AudioScheduledSourceNode
|
||||
, public MainThreadMediaStreamListener
|
||||
{
|
||||
public:
|
||||
static already_AddRefed<OscillatorNode>
|
||||
|
@ -27,7 +27,7 @@ public:
|
|||
ErrorResult& aRv);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(OscillatorNode, AudioNode)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(OscillatorNode, AudioScheduledSourceNode)
|
||||
|
||||
static already_AddRefed<OscillatorNode>
|
||||
Constructor(const GlobalObject& aGlobal, AudioContext& aAudioContext,
|
||||
|
@ -70,8 +70,9 @@ public:
|
|||
return mDetune;
|
||||
}
|
||||
|
||||
void Start(double aWhen, ErrorResult& aRv);
|
||||
void Stop(double aWhen, ErrorResult& aRv);
|
||||
void Start(double aWhen, ErrorResult& aRv) override;
|
||||
void Stop(double aWhen, ErrorResult& aRv) override;
|
||||
|
||||
void SetPeriodicWave(PeriodicWave& aPeriodicWave)
|
||||
{
|
||||
mPeriodicWave = &aPeriodicWave;
|
||||
|
@ -80,8 +81,6 @@ public:
|
|||
SendTypeToStream();
|
||||
}
|
||||
|
||||
IMPL_EVENT_HANDLER(ended)
|
||||
|
||||
void NotifyMainThreadStreamFinished() override;
|
||||
|
||||
const char* NodeType() const override
|
||||
|
|
|
@ -54,6 +54,7 @@ EXPORTS.mozilla.dom += [
|
|||
'AudioNode.h',
|
||||
'AudioParam.h',
|
||||
'AudioProcessingEvent.h',
|
||||
'AudioScheduledSourceNode.h',
|
||||
'BiquadFilterNode.h',
|
||||
'ChannelMergerNode.h',
|
||||
'ChannelSplitterNode.h',
|
||||
|
@ -89,6 +90,7 @@ UNIFIED_SOURCES += [
|
|||
'AudioNodeStream.cpp',
|
||||
'AudioParam.cpp',
|
||||
'AudioProcessingEvent.cpp',
|
||||
'AudioScheduledSourceNode.cpp',
|
||||
'BiquadFilterNode.cpp',
|
||||
'BufferDecoder.cpp',
|
||||
'ChannelMergerNode.cpp',
|
||||
|
|
|
@ -154,6 +154,8 @@ var interfaceNamesInGlobalScope =
|
|||
"AudioParam",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"AudioProcessingEvent",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"AudioScheduledSourceNode",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"AudioStreamTrack",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
|
|
|
@ -21,7 +21,7 @@ dictionary AudioBufferSourceOptions {
|
|||
|
||||
[Pref="dom.webaudio.enabled",
|
||||
Constructor(BaseAudioContext context, optional AudioBufferSourceOptions options)]
|
||||
interface AudioBufferSourceNode : AudioNode {
|
||||
interface AudioBufferSourceNode : AudioScheduledSourceNode {
|
||||
|
||||
attribute AudioBuffer? buffer;
|
||||
|
||||
|
@ -35,10 +35,6 @@ interface AudioBufferSourceNode : AudioNode {
|
|||
[Throws, UnsafeInPrerendering]
|
||||
void start(optional double when = 0, optional double grainOffset = 0,
|
||||
optional double grainDuration);
|
||||
[Throws, UnsafeInPrerendering]
|
||||
void stop(optional double when = 0);
|
||||
|
||||
attribute EventHandler onended;
|
||||
};
|
||||
|
||||
// Mozilla extensions
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://webaudio.github.io/web-audio-api/#idl-def-AudioScheduledSourceNode
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
interface AudioScheduledSourceNode : AudioNode {
|
||||
attribute EventHandler onended;
|
||||
[Throws, UnsafeInPrerendering]
|
||||
void start (optional double when = 0);
|
||||
|
||||
[Throws, UnsafeInPrerendering]
|
||||
void stop (optional double when = 0);
|
||||
};
|
|
@ -16,11 +16,6 @@ dictionary ConstantSourceOptions {
|
|||
|
||||
[Pref="dom.webaudio.enabled",
|
||||
Constructor(BaseAudioContext context, optional ConstantSourceOptions options)]
|
||||
interface ConstantSourceNode : AudioNode {
|
||||
interface ConstantSourceNode : AudioScheduledSourceNode {
|
||||
readonly attribute AudioParam offset;
|
||||
attribute EventHandler onended;
|
||||
[Throws, UnsafeInPrerendering]
|
||||
void start (optional double when = 0);
|
||||
[Throws, UnsafeInPrerendering]
|
||||
void stop (optional double when = 0);
|
||||
};
|
||||
|
|
|
@ -27,7 +27,7 @@ dictionary OscillatorOptions : AudioNodeOptions {
|
|||
|
||||
[Pref="dom.webaudio.enabled",
|
||||
Constructor(BaseAudioContext context, optional OscillatorOptions options)]
|
||||
interface OscillatorNode : AudioNode {
|
||||
interface OscillatorNode : AudioScheduledSourceNode {
|
||||
|
||||
[SetterThrows]
|
||||
attribute OscillatorType type;
|
||||
|
@ -35,14 +35,7 @@ interface OscillatorNode : AudioNode {
|
|||
readonly attribute AudioParam frequency; // in Hertz
|
||||
readonly attribute AudioParam detune; // in Cents
|
||||
|
||||
[Throws, UnsafeInPrerendering]
|
||||
void start(optional double when = 0);
|
||||
[Throws, UnsafeInPrerendering]
|
||||
void stop(optional double when = 0);
|
||||
void setPeriodicWave(PeriodicWave periodicWave);
|
||||
|
||||
attribute EventHandler onended;
|
||||
|
||||
};
|
||||
|
||||
// Mozilla extensions
|
||||
|
|
|
@ -41,6 +41,7 @@ WEBIDL_FILES = [
|
|||
'AudioNode.webidl',
|
||||
'AudioParam.webidl',
|
||||
'AudioProcessingEvent.webidl',
|
||||
'AudioScheduledSourceNode.webidl',
|
||||
'AudioStreamTrack.webidl',
|
||||
'AudioTrack.webidl',
|
||||
'AudioTrackList.webidl',
|
||||
|
|
Загрузка…
Ссылка в новой задаче