Skip to content
Browse files

decoder: update to readable-stream v1 API

  • Loading branch information...
1 parent 11422ea commit fe1006ab3fbbfb7c2c47e779c4b659746288e26d @TooTallNate committed Nov 9, 2013
Showing with 12 additions and 4 deletions.
  1. +11 −3 lib/decoder.js
  2. +1 −1 package.json
View
14 lib/decoder.js
@@ -68,6 +68,7 @@ Decoder.prototype._transform = function (packet, output, fn) {
debug('_transform()');
var r;
+ var self = this;
if (this._headerCount > 0) {
debug('headerin', this._headerCount);
// still decoding the header...
@@ -125,14 +126,21 @@ 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"
- fn();
+ if (eos) {
+ if (self.push) self.push(null); // emit "end"
+ else output(null); // XXX: compat with old Transform API... remove...
+ fn();
+ } else {
+ 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);
+
+ if (self.push) self.push(b);
+ else output(b); // XXX: compat with old Transform API... remove...
// try to get more data out
pcmout();
View
2 package.json
@@ -20,7 +20,7 @@
"bindings": "*",
"debug": "*",
"ogg": "*",
- "readable-stream": "0"
+ "readable-stream": "1"
},
"devDependencies": {
"mocha": "*"

0 comments on commit fe1006a

Please sign in to comment.
Something went wrong with that request. Please try again.