Skip to content

Commit

Permalink
Merge remote-tracking branch 'arunoda/stream2-fix'
Browse files Browse the repository at this point in the history
Conflicts:
	package.json

Closes #13.
  • Loading branch information
TooTallNate committed Aug 28, 2013
2 parents 6fc6c8b + 8cdf0dc commit b69e926
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ inherits(Decoder, Transform);
* @api private
*/

Decoder.prototype._transform = function (chunk, write, done) {
Decoder.prototype._transform = function (chunk, encoding, done) {
debug('_transform(): (%d bytes)', chunk.length);
var out, mh, self;
self = this;
Expand Down Expand Up @@ -135,7 +135,7 @@ Decoder.prototype._transform = function (chunk, write, done) {
}

if (self.push) self.push(out);
else write(out); // XXX: compat for old Transform API... remove at some point
else self.push(out); // XXX: compat for old Transform API... remove at some point
}
if (ret == MPG123_DONE) {
debug('done');
Expand Down
11 changes: 7 additions & 4 deletions lib/encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ Encoder.prototype._init = function () {
* @api private
*/

Encoder.prototype._transform = function (chunk, write, done) {
Encoder.prototype._transform = function (chunk, encoding, done) {
debug('_transform (%d bytes)', chunk.length);

var self = this;
if (!this._initCalled) {
try { this._init(); } catch (e) { return done(e); }
this._initCalled = true;
Expand Down Expand Up @@ -188,7 +189,7 @@ Encoder.prototype._transform = function (chunk, write, done) {
} else if (bytesWritten > 0) {
output = output.slice(0, bytesWritten);
debug('writing %d MP3 bytes', output.length);
write(output);
self.push(output);
done();
} else { // bytesWritten == 0
done();
Expand All @@ -200,8 +201,10 @@ Encoder.prototype._transform = function (chunk, write, done) {
* Calls `lame_encode_flush_nogap()` on the thread pool.
*/

Encoder.prototype._flush = function (write, done) {
Encoder.prototype._flush = function (done) {
debug('_flush');

var self = this;
var estimated_size = 7200; // value specified in lame.h
var output = new Buffer(estimated_size);

Expand All @@ -226,7 +229,7 @@ Encoder.prototype._flush = function (write, done) {
done(err);
} else if (bytesWritten > 0) {
output = output.slice(0, bytesWritten);
write(output);
self.push(output);
done();
} else { // bytesWritten == 0
done();
Expand Down

0 comments on commit b69e926

Please sign in to comment.