Skip to content

Commit

Permalink
Merge pull request ConnorChristie#2 from chawson/master
Browse files Browse the repository at this point in the history
Fix mixer._read recursive never stops causing process to hang
  • Loading branch information
Connor Christie authored Apr 1, 2019
2 parents f5d17ef + 46923de commit f706994
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/mixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export class Mixer extends Readable {

protected readSample;
protected writeSample;
protected needReadable: boolean = true;

private static INPUT_IDLE_TIMEOUT = 250;
private _timer:any = null

constructor(args: MixerArguments) {
super(args);
Expand Down Expand Up @@ -76,8 +78,9 @@ export class Mixer extends Readable {
});

this.push(mixedBuffer);
} else {
setImmediate(this._read.bind(this));
} else if(this.needReadable) {
clearImmediate(this._timer)
this._timer = setImmediate(this._read.bind(this));
}

this.clearBuffers();
Expand Down Expand Up @@ -130,6 +133,10 @@ export class Mixer extends Readable {
this.inputs = [];
}

public close(){
this.needReadable = false
}

/**
* Gets the max number of samples from all inputs
*/
Expand Down

0 comments on commit f706994

Please sign in to comment.