From db34eaf3b5e25457ccfe46af97faf8cfc5e90944 Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Tue, 9 Apr 2013 21:53:20 +0530 Subject: [PATCH] fix to compatible with new Stream2 with .push in ._transform() --- lib/decoder.js | 5 +++-- lib/encoder.js | 10 +++++----- package.json | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/decoder.js b/lib/decoder.js index 0dd0a1a..a4b075e 100644 --- a/lib/decoder.js +++ b/lib/decoder.js @@ -67,6 +67,7 @@ Decoder.prototype.packetin = Decoder.prototype.write; Decoder.prototype._transform = function (packet, output, fn) { debug('_transform()'); + var self = this; var r; if (this._headerCount > 0) { debug('headerin', this._headerCount); @@ -125,14 +126,14 @@ Decoder.prototype._transform = function (packet, output, fn) { var b = binding.vorbis_synthesis_pcmout(vd, channels); if (0 === b) { debug('need more "vorbis_block" data...'); - if (eos) output(null); // emit "end" + if (eos) self.push(null); // emit "end" fn(); } else if (b < 0) { // some other error... fn(new Error('vorbis_synthesis_pcmout() failed: ' + b)); } else { debug('got PCM data (%d bytes)', b.length); - output(b); + self.push(b); // try to get more data out pcmout(); diff --git a/lib/encoder.js b/lib/encoder.js index 38f2b11..641ce2d 100644 --- a/lib/encoder.js +++ b/lib/encoder.js @@ -166,12 +166,12 @@ Encoder.prototype._writeHeader = function (output, fn) { op_comments.replace(); op_code.replace(); - output(op_header); // automatically gets placed in its own `ogg_page` - output(op_comments); + this.push(op_header); // automatically gets placed in its own `ogg_page` + this.push(op_comments); // specify that a page flush() call is required after this 3rd packet op_code.flush = true; - output(op_code); + this.push(op_code); // don't call this function again this._headerWritten = true; @@ -274,7 +274,7 @@ Encoder.prototype._flushpacket = function (output, fn) { // got a packet, output it // the consumer should call `pageout()` after this packet packet.pageout = true; - output(packet); + self.push(packet); // attempt to get another `ogg_packet`... self._flushpacket(output, fn); @@ -395,4 +395,4 @@ Encoder.prototype._pipe = function (source) { debug('_pipe()'); this._format(source); source.once('format', this._format.bind(this)); -}; +}; \ No newline at end of file diff --git a/package.json b/package.json index ed06225..d782423 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "bindings": "*", "debug": "*", "ogg": "*", - "readable-stream": "0" + "readable-stream": "1.0.x" }, "devDependencies": { "mocha": "*"