| Index: sdk/lib/web_audio/dartium/web_audio_dartium.dart
|
| diff --git a/sdk/lib/web_audio/dartium/web_audio_dartium.dart b/sdk/lib/web_audio/dartium/web_audio_dartium.dart
|
| index 59a43adfc045839e46f4e079245b7e4d7ec76eed..841d20a768750bbbb1109d87be6500e10eab7a32 100644
|
| --- a/sdk/lib/web_audio/dartium/web_audio_dartium.dart
|
| +++ b/sdk/lib/web_audio/dartium/web_audio_dartium.dart
|
| @@ -236,6 +236,9 @@ class AudioContext extends EventTarget {
|
| @DocsEditable
|
| static AudioContext _create() native "AudioContext_constructorCallback";
|
|
|
| + /// Checks if this type is supported on the current platform.
|
| + static bool get supported => true;
|
| +
|
| @DomName('AudioContext.activeSourceCount')
|
| @DocsEditable
|
| int get activeSourceCount native "AudioContext_activeSourceCount_Getter";
|
| @@ -1086,16 +1089,26 @@ class PannerNode extends AudioNode {
|
| void setVelocity(num x, num y, num z) native "PannerNode_setVelocity_Callback";
|
|
|
| }
|
| -// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -// WARNING: Do not edit - generated code.
|
| -
|
|
|
| -@DocsEditable
|
| @DomName('ScriptProcessorNode')
|
| -class ScriptProcessorNode extends AudioNode implements EventTarget {
|
| +class ScriptProcessorNode extends AudioNode {
|
| + Stream<AudioProcessingEvent> _eventStream;
|
| +
|
| + /**
|
| + * Get a Stream that fires events when AudioProcessingEvents occur.
|
| + * This particular stream is special in that it only allows one listener to a
|
| + * given stream. Subsequent calls to [listen] after the first call will throw
|
| + */
|
| + Stream<AudioProcessingEvent> get onAudioProcess {
|
| + if (_eventStream == null) {
|
| + _eventStream = new _AudioEventStream(this);
|
| + }
|
| + return _eventStream;
|
| + }
|
| ScriptProcessorNode.internal() : super.internal();
|
|
|
| @DomName('ScriptProcessorNode.bufferSize')
|
| @@ -1103,6 +1116,118 @@ class ScriptProcessorNode extends AudioNode implements EventTarget {
|
| int get bufferSize native "ScriptProcessorNode_bufferSize_Getter";
|
|
|
| }
|
| +
|
| +class _AudioEventStreamSubscription<AudioProcessingEvent> extends
|
| + StreamSubscription<AudioProcessingEvent> {
|
| + EventListener _callback;
|
| + ScriptProcessorNode _target;
|
| + bool _paused;
|
| +
|
| + _AudioEventStreamSubscription(this._target, this._callback) {
|
| + _paused = false;
|
| + _tryResume();
|
| + }
|
| +
|
| + void cancel() {
|
| + if (_callback != null) {
|
| + throw new StateError("Subscription has already been canceled.");
|
| + }
|
| + _unlisten();
|
| + }
|
| +
|
| + void onData(void callback(AudioProcessingEvent)) {
|
| + if (_callback != null) {
|
| + throw new StateError("Subscription has been canceled.");
|
| + }
|
| + _setCallback(callback);
|
| + }
|
| +
|
| + /// Has no effect.
|
| + void onError(void handleError(AsyncError error)) {}
|
| +
|
| + /// Has no effect.
|
| + void onDone(void handleDone()) {}
|
| +
|
| + void pause([Future resumeSignal]) {
|
| + if (_callback != null) {
|
| + throw new StateError("Subscription has been canceled.");
|
| + }
|
| + _unlisten();
|
| + _paused = true;
|
| +
|
| + if (resumeSignal != null) {
|
| + resumeSignal.whenComplete(() { _paused = false; resume(); });
|
| + }
|
| + }
|
| +
|
| + void resume() {
|
| + if (_callback != null) {
|
| + throw new StateError("Subscription has been canceled.");
|
| + }
|
| + if (!_paused) {
|
| + throw new StateError("Subscription is not paused.");
|
| + }
|
| + _tryResume();
|
| + }
|
| +
|
| + void _tryResume() {
|
| + if (_callback != null) {
|
| + _setCallback(_callback);
|
| + _callback = null;
|
| + }
|
| + }
|
| +
|
| + void _unlisten() {
|
| + if (_callback == null) {
|
| + var noop = (event) {};
|
| + // TODO(podivilov): Implement on Dartium.
|
| + _setCallback(noop);
|
| + }
|
| + }
|
| +
|
| + void _setCallback(callbackFunc) {
|
| + // TODO(podivilov): Implement on Dartium.
|
| + }
|
| +}
|
| +
|
| +/**
|
| + * Adapter for exposing DOM events as Dart streams.
|
| + */
|
| +class _AudioEventStream<AudioProcessingEvent>
|
| + extends Stream<AudioProcessingEvent> {
|
| + static Set _createdTargets = new Set();
|
| + ScriptProcessorNode _target;
|
| + StreamSubscription _streamSubscription;
|
| +
|
| + _AudioEventStream(target) {
|
| + if (_createdTargets.contains(target)) {
|
| + throw new ArgumentError('This ScriptProcessorNode already has an event '
|
| + 'stream associated with it. There can be only one listener per '
|
| + 'ScriptProcessorNode');
|
| + } else {
|
| + _target = target;
|
| + _createdTargets.add(_target);
|
| + }
|
| + }
|
| +
|
| + bool get isBroadcast => true;
|
| +
|
| + StreamSubscription<AudioProcessingEvent> listen(
|
| + void onData(AudioProcessingEvent event),
|
| + { void onError(AsyncError error),
|
| + void onDone(),
|
| + bool unsubscribeOnError}) {
|
| + if (_streamSubscription != null) {
|
| + throw new StateError('Only one listener is allowed for this particular '
|
| + 'stream.');
|
| + }
|
| + _streamSubscription =
|
| + new _AudioEventStreamSubscription<AudioProcessingEvent>(
|
| + this._target, onData);
|
| + return _streamSubscription;
|
| + }
|
| +}
|
| +
|
| // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|