mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-23 21:52:45 -05:00
fix: ensure callback is called exactly once in StreamPositioner and WebMOpusMuxer
This commit is contained in:
1 parent
6e1722b723
commit
5129ee5ecc
2 files changed
+12
-12
No files matched your search
@@ -162,17 +162,15 @@ export class StreamPositioner extends Transform {
|
||||
|
||||
/** @param {Buffer} chunk @param {string} _enc @param {Function} cb @protected */
|
||||
_transform(chunk, _enc, cb) {
|
||||
let error = null;
|
||||
try {
|
||||
if (this._done) {
|
||||
this.push(chunk);
|
||||
return cb();
|
||||
}
|
||||
if (this._kind === "ogg") this._feedOgg(chunk);
|
||||
if (this._done) this.push(chunk);
|
||||
else if (this._kind === "ogg") this._feedOgg(chunk);
|
||||
else this._feedWebm(chunk);
|
||||
cb();
|
||||
} catch (err) {
|
||||
cb(err);
|
||||
error = err;
|
||||
}
|
||||
cb(error);
|
||||
}
|
||||
|
||||
/** @param {Function} cb @protected */
|
||||
|
||||
@@ -252,26 +252,28 @@ export class WebMOpusMuxer extends Transform {
|
||||
* @protected
|
||||
*/
|
||||
_transform(packet, _encoding, callback) {
|
||||
let error = null;
|
||||
try {
|
||||
if (Buffer.isBuffer(packet) && packet.length > 0) {
|
||||
this._addBlock(packet);
|
||||
}
|
||||
callback();
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
error = err;
|
||||
}
|
||||
callback(error);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} callback
|
||||
* @protected
|
||||
*/
|
||||
_final(callback) {
|
||||
_flush(callback) {
|
||||
let error = null;
|
||||
try {
|
||||
this._flushCluster();
|
||||
callback();
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
error = err;
|
||||
}
|
||||
callback(error);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user