3776313e65
Introduces NULLASSERT token and NNBD condition to allow code to conditionally compile with NNBD. Change-Id: Ib71e439f32c793e69b66c328cd7c9900358d886e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134045 Commit-Queue: Srujan Gaddam <srujzs@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
69 lines
2.3 KiB
Plaintext
69 lines
2.3 KiB
Plaintext
// 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.
|
|
|
|
part of web_audio;
|
|
|
|
$(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
|
|
$!MEMBERS
|
|
factory AudioContext() => JS('AudioContext',
|
|
'new (window.AudioContext || window.webkitAudioContext)()');
|
|
|
|
GainNode createGain() {
|
|
if (JS('bool', '#.createGain !== undefined', this)) {
|
|
return JS('GainNode', '#.createGain()', this);
|
|
} else {
|
|
return JS('GainNode', '#.createGainNode()', this);
|
|
}
|
|
}
|
|
|
|
ScriptProcessorNode createScriptProcessor([int$NULLABLE bufferSize,
|
|
int$NULLABLE numberOfInputChannels,
|
|
int$NULLABLE numberOfOutputChannels]) {
|
|
var function = JS(
|
|
'=Object',
|
|
'#.createScriptProcessor || '
|
|
'#.createJavaScriptNode',
|
|
this,
|
|
this);
|
|
if (numberOfOutputChannels != null) {
|
|
return JS('ScriptProcessorNode', '#.call(#, #, #, #)', function, this,
|
|
bufferSize, numberOfInputChannels, numberOfOutputChannels);
|
|
} else if (numberOfInputChannels != null) {
|
|
return JS('ScriptProcessorNode', '#.call(#, #, #)', function, this,
|
|
bufferSize, numberOfInputChannels);
|
|
} else if (bufferSize != null) {
|
|
return JS(
|
|
'ScriptProcessorNode', '#.call(#, #)', function, this, bufferSize);
|
|
} else {
|
|
return JS(
|
|
'ScriptProcessorNode', '#.call(#)', function, this);
|
|
}
|
|
}
|
|
|
|
@JSName('decodeAudioData')
|
|
Future$#NULLSAFECAST(<AudioBuffer>) _decodeAudioData(ByteBuffer audioData,
|
|
[DecodeSuccessCallback$NULLABLE successCallback,
|
|
DecodeErrorCallback$NULLABLE errorCallback]) native;
|
|
|
|
Future<AudioBuffer> decodeAudioData(ByteBuffer audioData,
|
|
[DecodeSuccessCallback$NULLABLE successCallback,
|
|
DecodeErrorCallback$NULLABLE errorCallback]) {
|
|
if (successCallback != null && errorCallback != null) {
|
|
return _decodeAudioData(audioData, successCallback, errorCallback);
|
|
}
|
|
|
|
var completer = new Completer<AudioBuffer>();
|
|
_decodeAudioData(audioData, (value) {
|
|
completer.complete(value);
|
|
}, (error) {
|
|
if (error == null) {
|
|
completer.completeError('');
|
|
} else {
|
|
completer.completeError(error);
|
|
}
|
|
});
|
|
return completer.future;
|
|
}
|
|
}
|