Skip to content

Commit

Permalink
fix(node-medley): where bufferSize and buffering options were inc…
Browse files Browse the repository at this point in the history
…orrecly calculated
  • Loading branch information
vittee committed Jun 2, 2024
1 parent f38e9f9 commit f37279e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/node-medley/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit f37279e

Please sign in to comment.