OLD | NEW |
1 library dart.dom.web_audio; | 1 library dart.dom.web_audio; |
2 | 2 |
3 import 'dart:async'; | 3 import 'dart:async'; |
4 import 'dart:collection'; | 4 import 'dart:collection'; |
5 import 'dart:html'; | 5 import 'dart:html'; |
6 import 'dart:html_common'; | 6 import 'dart:html_common'; |
7 import 'dart:_js_helper' show Creates, Returns, convertDartClosureToJS; | 7 import 'dart:_js_helper' show Creates, Returns, convertDartClosureToJS; |
8 import 'dart:_foreign_helper' show JS; | 8 import 'dart:_foreign_helper' show JS; |
9 // DO NOT EDIT - unless you are editing documentation as per: | 9 // DO NOT EDIT - unless you are editing documentation as per: |
10 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation | 10 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 * Get a Stream that fires events when AudioProcessingEvents occur. | 820 * Get a Stream that fires events when AudioProcessingEvents occur. |
821 * This particular stream is special in that it only allows one listener to a | 821 * This particular stream is special in that it only allows one listener to a |
822 * given stream. Converting the returned Stream [asBroadcast] will likely ruin | 822 * given stream. Converting the returned Stream [asBroadcast] will likely ruin |
823 * the soft-real-time properties which which these events are fired and can | 823 * the soft-real-time properties which which these events are fired and can |
824 * be processed. | 824 * be processed. |
825 */ | 825 */ |
826 Stream<AudioProcessingEvent> get onAudioProcess { | 826 Stream<AudioProcessingEvent> get onAudioProcess { |
827 if (_eventStream == null) { | 827 if (_eventStream == null) { |
828 var controller = new StreamController(); | 828 var controller = new StreamController(); |
829 var callback = (audioData) { | 829 var callback = (audioData) { |
830 if (controller.hasSubscribers) { | 830 if (controller.hasListener) { |
831 // This stream is a strange combination of broadcast and single | 831 // This stream is a strange combination of broadcast and single |
832 // subscriber streams. We only allow one listener, but if there is | 832 // subscriber streams. We only allow one listener, but if there is |
833 // no listener, we don't queue up events, we just drop them on the | 833 // no listener, we don't queue up events, we just drop them on the |
834 // floor. | 834 // floor. |
835 controller.add(audioData); | 835 controller.add(audioData); |
836 } | 836 } |
837 }; | 837 }; |
838 _setEventListener(callback); | 838 _setEventListener(callback); |
839 _eventStream = controller.stream; | 839 _eventStream = controller.stream; |
840 } | 840 } |
(...skipping 28 matching lines...) Expand all Loading... |
869 } | 869 } |
870 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 870 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
871 // for details. All rights reserved. Use of this source code is governed by a | 871 // for details. All rights reserved. Use of this source code is governed by a |
872 // BSD-style license that can be found in the LICENSE file. | 872 // BSD-style license that can be found in the LICENSE file. |
873 | 873 |
874 | 874 |
875 @DocsEditable | 875 @DocsEditable |
876 @DomName('WaveTable') | 876 @DomName('WaveTable') |
877 class WaveTable native "*WaveTable" { | 877 class WaveTable native "*WaveTable" { |
878 } | 878 } |
OLD | NEW |