Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: sdk/lib/web_audio/dart2js/web_audio_dart2js.dart

Issue 11510013: Making ScriptProcessorNode not an EventTarget. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/web_audio/dartium/web_audio_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/web_audio/dart2js/web_audio_dart2js.dart
diff --git a/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart b/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart
index 13d8b3645d7625c5fcef55be734e8ccd5602da34..890206960df9096fb37c24ccfabaebd6517c422d 100644
--- a/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart
+++ b/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart
@@ -4,7 +4,7 @@ import 'dart:async';
import 'dart:collection';
import 'dart:html';
import 'dart:html_common';
-import 'dart:_js_helper' show Creates, Returns;
+import 'dart:_js_helper' show Creates, Returns, convertDartClosureToJS;
import 'dart:_foreign_helper' show JS;
// DO NOT EDIT - unless you are editing documentation as per:
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
@@ -184,6 +184,9 @@ class AudioContext extends EventTarget native "*AudioContext" {
@DocsEditable
static const EventStreamProvider<Event> completeEvent = const EventStreamProvider<Event>('complete');
+ /// Checks if this type is supported on the current platform.
+ static bool get supported => JS('bool', '!!(window.AudioContext || window.webkitAudioContext)');
+
@DomName('AudioContext.activeSourceCount')
@DocsEditable
final int activeSourceCount;
@@ -813,18 +816,46 @@ class PannerNode extends AudioNode native "*PannerNode" {
@DocsEditable
void setVelocity(num x, num y, num z) native;
}
-// 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.
-@DocsEditable
@DomName('ScriptProcessorNode')
-class ScriptProcessorNode extends AudioNode implements EventTarget native "*ScriptProcessorNode" {
+class ScriptProcessorNode extends AudioNode native "*ScriptProcessorNode" {
+ 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. Converting the returned Stream [asBroadcast] will likely ruin
+ * the soft-real-time properties which which these events are fired and can
+ * be processed.
+ */
+ Stream<AudioProcessingEvent> get onAudioProcess {
+ if (_eventStream == null) {
+ var controller = new StreamController();
+ var callback = (audioData) {
+ if (controller.hasSubscribers) {
+ // This stream is a strange combination of broadcast and single
+ // subscriber streams. We only allow one listener, but if there is
+ // no listener, we don't queue up events, we just drop them on the
+ // floor.
+ controller.add(audioData);
+ }
+ };
+ JS('void', '#.onaudioprocess = #', this,
+ convertDartClosureToJS(callback, 1));
+
+ _eventStream = controller.stream;
+ }
+ return _eventStream;
+ }
@DomName('ScriptProcessorNode.bufferSize')
@DocsEditable
final int bufferSize;
+
}
// 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
« no previous file with comments | « no previous file | sdk/lib/web_audio/dartium/web_audio_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698