fix some stuff

This commit is contained in:
Amish Shah
2016-10-24 20:13:44 +01:00
parent 5749eb6bb0
commit 1a5ce878a1
6 changed files with 34 additions and 11 deletions

View File

@@ -7,9 +7,36 @@ class PCMConversionProcess extends EventEmitter {
constructor(process) {
super();
this.process = process;
this.input = null;
this.process.on('error', e => this.emit('error', e));
}
setInput(stream) {
this.input = stream;
stream.pipe(this.process.stdin, { end: false });
this.input.on('error', e => this.emit('error', e));
}
destroy() {
this.emit('debug', 'destroying a ffmpeg process:');
if (this.input && this.input.unpipe && this.process.stdin) {
this.input.unpipe(this.process.stdin);
this.emit('unpiped the user input stream from the process input stream');
}
if (this.process.stdin) {
this.process.stdin.end();
this.emit('ended the process stdin');
}
if (this.process.stdin.destroy) {
this.process.stdin.destroy();
this.emit('destroyed the process stdin');
}
if (this.process.kill) {
this.process.kill();
this.emit('killed the process');
}
}
}
class FfmpegConverterEngine extends ConverterEngine {