|
@@ -145,25 +145,20 @@ export class FlacAdapter extends RecordingAdapter {
|
145
|
145
|
/**
|
146
|
146
|
* Replaces the current microphone MediaStream.
|
147
|
147
|
*
|
148
|
|
- * @param {*} micDeviceId - New microphone ID.
|
|
148
|
+ * @param {string} micDeviceId - New microphone ID.
|
149
|
149
|
* @returns {Promise}
|
150
|
150
|
*/
|
151
|
151
|
_replaceMic(micDeviceId) {
|
152
|
152
|
if (this._audioContext && this._audioProcessingNode) {
|
153
|
|
- return new Promise((resolve, reject) => {
|
154
|
|
- this._getAudioStream(micDeviceId).then(newStream => {
|
155
|
|
- const newSource = this._audioContext
|
156
|
|
- .createMediaStreamSource(newStream);
|
157
|
|
-
|
158
|
|
- this._audioSource.disconnect();
|
159
|
|
- newSource.connect(this._audioProcessingNode);
|
160
|
|
- this._stream = newStream;
|
161
|
|
- this._audioSource = newSource;
|
162
|
|
- resolve();
|
163
|
|
- })
|
164
|
|
- .catch(() => {
|
165
|
|
- reject();
|
166
|
|
- });
|
|
153
|
+ return this._getAudioStream(micDeviceId).then(newStream => {
|
|
154
|
+ const newSource = this._audioContext
|
|
155
|
+ .createMediaStreamSource(newStream);
|
|
156
|
+
|
|
157
|
+ this._audioSource.disconnect();
|
|
158
|
+ newSource.connect(this._audioProcessingNode);
|
|
159
|
+ this._stream = newStream;
|
|
160
|
+ this._audioSource = newSource;
|
|
161
|
+
|
167
|
162
|
});
|
168
|
163
|
}
|
169
|
164
|
|
|
@@ -221,7 +216,7 @@ export class FlacAdapter extends RecordingAdapter {
|
221
|
216
|
});
|
222
|
217
|
});
|
223
|
218
|
|
224
|
|
- const callbackInitAudioContext = (resolve, reject) => {
|
|
219
|
+ const callbackInitAudioContext = () =>
|
225
|
220
|
this._getAudioStream(micDeviceId)
|
226
|
221
|
.then(stream => {
|
227
|
222
|
this._stream = stream;
|
|
@@ -244,19 +239,18 @@ export class FlacAdapter extends RecordingAdapter {
|
244
|
239
|
});
|
245
|
240
|
};
|
246
|
241
|
logger.debug('AudioContext is set up.');
|
247
|
|
- resolve();
|
248
|
242
|
})
|
249
|
243
|
.catch(err => {
|
250
|
244
|
logger.error(`Error calling getUserMedia(): ${err}`);
|
251
|
|
- reject();
|
|
245
|
+
|
|
246
|
+ return Promise.reject(err);
|
252
|
247
|
});
|
253
|
|
- };
|
254
|
248
|
|
255
|
249
|
// Because Promise constructor immediately executes the executor
|
256
|
250
|
// function. This is undesirable, we want callbackInitAudioContext to be
|
257
|
251
|
// executed only **after** promiseInitWorker is resolved.
|
258
|
252
|
return promiseInitWorker
|
259
|
|
- .then(() => new Promise(callbackInitAudioContext));
|
|
253
|
+ .then(callbackInitAudioContext);
|
260
|
254
|
}
|
261
|
255
|
|
262
|
256
|
/**
|