зеркало из https://github.com/mozilla/gecko-dev.git
Bug 923517 - AudioDestinationNode should work as an EventTarget, r=ehsan
This commit is contained in:
Родитель
08f65cf2a9
Коммит
68bf49d79c
|
@ -71,19 +71,20 @@ AudioContext::AudioContext(nsPIDOMWindow* aWindow,
|
|||
uint32_t aLength,
|
||||
float aSampleRate)
|
||||
: mSampleRate(aIsOffline ? aSampleRate : IdealAudioRate())
|
||||
, mDestination(new AudioDestinationNode(MOZ_THIS_IN_INITIALIZER_LIST(),
|
||||
aIsOffline, aNumberOfChannels,
|
||||
aLength, aSampleRate))
|
||||
, mNumberOfChannels(aNumberOfChannels)
|
||||
, mIsOffline(aIsOffline)
|
||||
, mIsStarted(!aIsOffline)
|
||||
, mIsShutDown(false)
|
||||
{
|
||||
// Actually play audio
|
||||
mDestination->Stream()->AddAudioOutput(&gWebAudioOutputKey);
|
||||
nsDOMEventTargetHelper::BindToOwner(aWindow);
|
||||
aWindow->AddAudioContext(this);
|
||||
SetIsDOMBinding();
|
||||
|
||||
// Note: AudioDestinationNode needs an AudioContext that must already be
|
||||
// bound to the window.
|
||||
mDestination = new AudioDestinationNode(this, aIsOffline, aNumberOfChannels,
|
||||
aLength, aSampleRate);
|
||||
mDestination->Stream()->AddAudioOutput(&gWebAudioOutputKey);
|
||||
}
|
||||
|
||||
AudioContext::~AudioContext()
|
||||
|
|
|
@ -109,3 +109,4 @@ support-files =
|
|||
[test_waveShaper.html]
|
||||
[test_waveShaperNoCurve.html]
|
||||
[test_waveShaperZeroLengthCurve.html]
|
||||
[test_audioDestinationNode.html]
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test AudioDestinationNode as EventTarget</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="webaudio.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();
|
||||
|
||||
var ac = new AudioContext()
|
||||
ac.destination.addEventListener("foo", function() {
|
||||
ok(true, "Event received!");
|
||||
SimpleTest.finish();
|
||||
}, false);
|
||||
ac.destination.dispatchEvent(new CustomEvent("foo"));
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
Загрузка…
Ссылка в новой задаче