Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix to compatible with new Stream2 with .push() #5

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/decoder.js
Expand Up @@ -67,6 +67,7 @@ Decoder.prototype.packetin = Decoder.prototype.write;
Decoder.prototype._transform = function (packet, output, fn) { Decoder.prototype._transform = function (packet, output, fn) {
debug('_transform()'); debug('_transform()');


var self = this;
var r; var r;
if (this._headerCount > 0) { if (this._headerCount > 0) {
debug('headerin', this._headerCount); debug('headerin', this._headerCount);
Expand Down Expand Up @@ -125,14 +126,14 @@ Decoder.prototype._transform = function (packet, output, fn) {
var b = binding.vorbis_synthesis_pcmout(vd, channels); var b = binding.vorbis_synthesis_pcmout(vd, channels);
if (0 === b) { if (0 === b) {
debug('need more "vorbis_block" data...'); debug('need more "vorbis_block" data...');
if (eos) output(null); // emit "end" if (eos) self.push(null); // emit "end"
fn(); fn();
} else if (b < 0) { } else if (b < 0) {
// some other error... // some other error...
fn(new Error('vorbis_synthesis_pcmout() failed: ' + b)); fn(new Error('vorbis_synthesis_pcmout() failed: ' + b));
} else { } else {
debug('got PCM data (%d bytes)', b.length); debug('got PCM data (%d bytes)', b.length);
output(b); self.push(b);


// try to get more data out // try to get more data out
pcmout(); pcmout();
Expand Down
10 changes: 5 additions & 5 deletions lib/encoder.js
Expand Up @@ -166,12 +166,12 @@ Encoder.prototype._writeHeader = function (output, fn) {
op_comments.replace(); op_comments.replace();
op_code.replace(); op_code.replace();


output(op_header); // automatically gets placed in its own `ogg_page` this.push(op_header); // automatically gets placed in its own `ogg_page`
output(op_comments); this.push(op_comments);


// specify that a page flush() call is required after this 3rd packet // specify that a page flush() call is required after this 3rd packet
op_code.flush = true; op_code.flush = true;
output(op_code); this.push(op_code);


// don't call this function again // don't call this function again
this._headerWritten = true; this._headerWritten = true;
Expand Down Expand Up @@ -274,7 +274,7 @@ Encoder.prototype._flushpacket = function (output, fn) {
// got a packet, output it // got a packet, output it
// the consumer should call `pageout()` after this packet // the consumer should call `pageout()` after this packet
packet.pageout = true; packet.pageout = true;
output(packet); self.push(packet);


// attempt to get another `ogg_packet`... // attempt to get another `ogg_packet`...
self._flushpacket(output, fn); self._flushpacket(output, fn);
Expand Down Expand Up @@ -395,4 +395,4 @@ Encoder.prototype._pipe = function (source) {
debug('_pipe()'); debug('_pipe()');
this._format(source); this._format(source);
source.once('format', this._format.bind(this)); source.once('format', this._format.bind(this));
}; };
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -20,7 +20,7 @@
"bindings": "*", "bindings": "*",
"debug": "*", "debug": "*",
"ogg": "*", "ogg": "*",
"readable-stream": "0" "readable-stream": "1.0.x"
}, },
"devDependencies": { "devDependencies": {
"mocha": "*" "mocha": "*"
Expand Down