diff --git a/packages/node-medley/src/index.ts b/packages/node-medley/src/index.ts index 8fbf43cb..8c66771f 100644 --- a/packages/node-medley/src/index.ts +++ b/packages/node-medley/src/index.ts @@ -49,8 +49,10 @@ Medley.prototype.requestAudioStream = async function(options: RequestAudioOption const streamId = result.id; const sampleRate = Number(options.sampleRate) ?? 44100; - let buffering = Number(options.buffering) ?? (sampleRate * 0.01); - const bufferSize = Number(options.bufferSize) ?? (sampleRate * 0.25); + const defaultBuffering = sampleRate * 0.01; + const defaultBufferSize = sampleRate * 0.25; + let buffering = Number(options.buffering ?? defaultBuffering); + const bufferSize = Number(options.bufferSize ?? defaultBufferSize); if (buffering < 1) { throw new Error('buffering cannot be less than 1'); @@ -104,7 +106,7 @@ Medley.prototype.requestAudioStream = async function(options: RequestAudioOption ...result, update: (newOptions) => { if (newOptions.buffering) { - const newBuffering = Number(newOptions.buffering) ?? (sampleRate * 0.01); + const newBuffering = Number(newOptions.buffering ?? defaultBuffering); if (newBuffering < 1) { throw new Error('buffering cannot be less than 1');