speechrecorderng 2.24.1 → 2.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1047,17 +1047,45 @@ class AudioCapture {
1047
1047
  this._opened = false;
1048
1048
  }
1049
1049
  audioBuffer() {
1050
- var frameLen = 0;
1051
- var ch0Data = this.data[0];
1052
- for (var ch0Chk of ch0Data) {
1050
+ let frameLen = 0;
1051
+ let ch0Data = this.data[0];
1052
+ for (let ch0Chk of ch0Data) {
1053
1053
  frameLen += ch0Chk.length;
1054
1054
  }
1055
- var ab = this.context.createBuffer(this.channelCount, frameLen, this.context.sampleRate);
1056
- for (var ch = 0; ch < this.channelCount; ch++) {
1057
- var chD = ab.getChannelData(ch);
1058
- var pos = 0;
1059
- for (var chChk of this.data[ch]) {
1060
- var bufLen = chChk.length;
1055
+ let ab;
1056
+ try {
1057
+ ab = this.context.createBuffer(this.channelCount, frameLen, this.context.sampleRate);
1058
+ }
1059
+ catch (err) {
1060
+ if (err instanceof DOMException) {
1061
+ if (err.name === 'NotSupportedError') {
1062
+ if (frameLen == 0) {
1063
+ // Empty buffers are not supported by Chromium
1064
+ // Create dummy buffer with one sample
1065
+ ab = this.context.createBuffer(this.channelCount, 1, this.context.sampleRate);
1066
+ }
1067
+ else {
1068
+ throw err;
1069
+ }
1070
+ }
1071
+ else {
1072
+ throw err;
1073
+ }
1074
+ }
1075
+ else if (err instanceof RangeError) {
1076
+ // Out of memory
1077
+ // TODO What to do ??
1078
+ throw err;
1079
+ }
1080
+ else {
1081
+ throw err;
1082
+ }
1083
+ }
1084
+ for (let ch = 0; ch < this.channelCount; ch++) {
1085
+ let chD = ab.getChannelData(ch);
1086
+ let pos = 0;
1087
+ for (let chChk of this.data[ch]) {
1088
+ let bufLen = chChk.length;
1061
1089
  chD.set(chChk, pos);
1062
1090
  pos += bufLen;
1063
1091
  }
@@ -11886,7 +11914,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
11886
11914
  }]
11887
11915
  }] });
11888
11916
 
11889
- const VERSION = '2.24.1';
11917
+ const VERSION = '2.24.2';
11890
11918
 
11891
11919
  /*
11892
11920
  * Public API Surface of speechrecorderng