mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 807533 - Implement DelayNode; r=bzbarsky
--HG-- extra : rebase_source : 36bb70c9f4b9c86fc1564447a34153d92fe7f347
This commit is contained in:
parent
463e083c2e
commit
41f9f14161
@ -13,6 +13,7 @@
|
||||
#include "AudioBufferSourceNode.h"
|
||||
#include "AudioBuffer.h"
|
||||
#include "GainNode.h"
|
||||
#include "DelayNode.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -94,6 +95,13 @@ AudioContext::CreateGain()
|
||||
return gainNode.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DelayNode>
|
||||
AudioContext::CreateDelay(float aMaxDelayTime)
|
||||
{
|
||||
nsRefPtr<DelayNode> delayNode = new DelayNode(this, aMaxDelayTime);
|
||||
return delayNode.forget();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ class AudioDestinationNode;
|
||||
class AudioBufferSourceNode;
|
||||
class AudioBuffer;
|
||||
class GainNode;
|
||||
class DelayNode;
|
||||
|
||||
class AudioContext MOZ_FINAL : public nsWrapperCache,
|
||||
public EnableWebAudioCheck
|
||||
@ -65,6 +66,9 @@ public:
|
||||
already_AddRefed<GainNode>
|
||||
CreateGain();
|
||||
|
||||
already_AddRefed<DelayNode>
|
||||
CreateDelay(float aMaxDelayTime);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDOMWindow> mWindow;
|
||||
nsRefPtr<AudioDestinationNode> mDestination;
|
||||
|
42
content/media/webaudio/DelayNode.cpp
Normal file
42
content/media/webaudio/DelayNode.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
/* -*- 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 "DelayNode.h"
|
||||
#include "mozilla/dom/DelayNodeBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(DelayNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DelayNode, AudioNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDelay)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DelayNode, AudioNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_PTR(tmp->mDelay, AudioParam, "delay value")
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DelayNode)
|
||||
NS_INTERFACE_MAP_END_INHERITING(AudioNode)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(DelayNode, AudioNode)
|
||||
NS_IMPL_RELEASE_INHERITED(DelayNode, AudioNode)
|
||||
|
||||
DelayNode::DelayNode(AudioContext* aContext, float aMaxDelay)
|
||||
: AudioNode(aContext)
|
||||
, mDelay(new AudioParam(aContext, 0.0f, 0.0f, aMaxDelay))
|
||||
{
|
||||
}
|
||||
|
||||
JSObject*
|
||||
DelayNode::WrapObject(JSContext* aCx, JSObject* aScope,
|
||||
bool* aTriedToWrap)
|
||||
{
|
||||
return DelayNodeBinding::Wrap(aCx, aScope, this, aTriedToWrap);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
51
content/media/webaudio/DelayNode.h
Normal file
51
content/media/webaudio/DelayNode.h
Normal file
@ -0,0 +1,51 @@
|
||||
/* -*- 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 DelayNode_h_
|
||||
#define DelayNode_h_
|
||||
|
||||
#include "AudioNode.h"
|
||||
#include "AudioParam.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class AudioContext;
|
||||
|
||||
class DelayNode : public AudioNode
|
||||
{
|
||||
public:
|
||||
DelayNode(AudioContext* aContext, float aMaxDelay);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DelayNode, AudioNode)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope,
|
||||
bool* aTriedToWrap);
|
||||
|
||||
virtual uint32_t MaxNumberOfInputs() const MOZ_FINAL MOZ_OVERRIDE
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
virtual uint32_t MaxNumberOfOutputs() const MOZ_FINAL MOZ_OVERRIDE
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
AudioParam* DelayTime() const
|
||||
{
|
||||
return mDelay;
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<AudioParam> mDelay;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -22,6 +22,7 @@ CPPSRCS := \
|
||||
AudioNode.cpp \
|
||||
AudioParam.cpp \
|
||||
AudioSourceNode.cpp \
|
||||
DelayNode.cpp \
|
||||
EnableWebAudioCheck.cpp \
|
||||
GainNode.cpp \
|
||||
$(NULL)
|
||||
@ -34,6 +35,7 @@ EXPORTS_mozilla/dom := \
|
||||
AudioNode.h \
|
||||
AudioParam.h \
|
||||
AudioSourceNode.h \
|
||||
DelayNode.h \
|
||||
GainNode.h \
|
||||
$(NULL)
|
||||
|
||||
|
@ -14,6 +14,7 @@ MOCHITEST_FILES := \
|
||||
test_AudioBuffer.html \
|
||||
test_AudioContext.html \
|
||||
test_badConnect.html \
|
||||
test_delayNode.html \
|
||||
test_gainNode.html \
|
||||
test_singleSourceDest.html \
|
||||
$(NULL)
|
||||
|
69
content/media/webaudio/test/test_delayNode.html
Normal file
69
content/media/webaudio/test/test_delayNode.html
Normal file
@ -0,0 +1,69 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test DelayNode</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(function() {
|
||||
SpecialPowers.setBoolPref("media.webaudio.enabled", true);
|
||||
|
||||
var context = new mozAudioContext();
|
||||
var buffer = context.createBuffer(1, 2048, 44100);
|
||||
for (var i = 0; i < 2048; ++i) {
|
||||
buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / 44100);
|
||||
}
|
||||
|
||||
var destination = context.destination;
|
||||
|
||||
var source = context.createBufferSource();
|
||||
|
||||
var delay = context.createDelay();
|
||||
|
||||
source.buffer = buffer;
|
||||
|
||||
source.connect(delay);
|
||||
delay.connect(destination);
|
||||
|
||||
ok(delay.delayTime, "The audioparam member must exist");
|
||||
is(delay.delayTime.value, 0, "Correct initial value");
|
||||
is(delay.delayTime.defaultValue, 0, "Correct default value");
|
||||
is(delay.delayTime.minValue, 0, "Correct min value");
|
||||
is(delay.delayTime.maxValue, 1.0, "Correct max value");
|
||||
delay.delayTime.value = 0.5;
|
||||
is(delay.delayTime.value, 0.5, "Correct initial value");
|
||||
is(delay.delayTime.defaultValue, 0, "Correct default value");
|
||||
is(delay.delayTime.minValue, 0, "Correct min value");
|
||||
is(delay.delayTime.maxValue, 1.0, "Correct max value");
|
||||
|
||||
var delay2 = context.createDelay(2);
|
||||
is(delay2.delayTime.value, 0, "Correct initial value");
|
||||
is(delay2.delayTime.defaultValue, 0, "Correct default value");
|
||||
is(delay2.delayTime.minValue, 0, "Correct min value");
|
||||
is(delay2.delayTime.maxValue, 2.0, "Correct max value");
|
||||
delay2.delayTime.value = 0.5;
|
||||
is(delay2.delayTime.value, 0.5, "Correct initial value");
|
||||
is(delay2.delayTime.defaultValue, 0, "Correct default value");
|
||||
is(delay2.delayTime.minValue, 0, "Correct min value");
|
||||
is(delay2.delayTime.maxValue, 2.0, "Correct max value");
|
||||
|
||||
source.start(0);
|
||||
SimpleTest.executeSoon(function() {
|
||||
source.stop(0);
|
||||
source.disconnect();
|
||||
delay.disconnect();
|
||||
|
||||
SpecialPowers.clearUserPref("media.webaudio.enabled");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -140,6 +140,11 @@ DOMInterfaces = {
|
||||
'nativeType': 'nsICSSDeclaration'
|
||||
},
|
||||
|
||||
'DelayNode': [
|
||||
{
|
||||
'resultNotAddRefed': [ 'delayTime' ],
|
||||
}],
|
||||
|
||||
'Document': [
|
||||
{
|
||||
'nativeType': 'nsIDocument',
|
||||
|
@ -27,6 +27,8 @@ interface mozAudioContext {
|
||||
|
||||
[Creator]
|
||||
GainNode createGain();
|
||||
[Creator]
|
||||
DelayNode createDelay(optional float maxDelayTime = 1);
|
||||
|
||||
};
|
||||
|
||||
|
19
dom/webidl/DelayNode.webidl
Normal file
19
dom/webidl/DelayNode.webidl
Normal file
@ -0,0 +1,19 @@
|
||||
/* -*- 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://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
[PrefControlled]
|
||||
interface DelayNode : AudioNode {
|
||||
|
||||
readonly attribute AudioParam delayTime;
|
||||
|
||||
};
|
||||
|
@ -20,6 +20,7 @@ webidl_files = \
|
||||
CanvasRenderingContext2D.webidl \
|
||||
ClientRectList.webidl \
|
||||
CSSStyleDeclaration.webidl \
|
||||
DelayNode.webidl \
|
||||
DOMImplementation.webidl \
|
||||
DOMTokenList.webidl \
|
||||
DOMSettableTokenList.webidl \
|
||||
|
Loading…
Reference in New Issue
Block a user