mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -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 */
|
/** @param {Buffer} chunk @param {string} _enc @param {Function} cb @protected */
|
||||||
_transform(chunk, _enc, cb) {
|
_transform(chunk, _enc, cb) {
|
||||||
|
let error = null;
|
||||||
try {
|
try {
|
||||||
if (this._done) {
|
if (this._done) this.push(chunk);
|
||||||
this.push(chunk);
|
else if (this._kind === "ogg") this._feedOgg(chunk);
|
||||||
return cb();
|
|
||||||
}
|
|
||||||
if (this._kind === "ogg") this._feedOgg(chunk);
|
|
||||||
else this._feedWebm(chunk);
|
else this._feedWebm(chunk);
|
||||||
cb();
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
cb(err);
|
error = err;
|
||||||
}
|
}
|
||||||
|
cb(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {Function} cb @protected */
|
/** @param {Function} cb @protected */
|
||||||
|
|||||||
@@ -252,26 +252,28 @@ export class WebMOpusMuxer extends Transform {
|
|||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
_transform(packet, _encoding, callback) {
|
_transform(packet, _encoding, callback) {
|
||||||
|
let error = null;
|
||||||
try {
|
try {
|
||||||
if (Buffer.isBuffer(packet) && packet.length > 0) {
|
if (Buffer.isBuffer(packet) && packet.length > 0) {
|
||||||
this._addBlock(packet);
|
this._addBlock(packet);
|
||||||
}
|
}
|
||||||
callback();
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
callback(err);
|
error = err;
|
||||||
}
|
}
|
||||||
|
callback(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
_final(callback) {
|
_flush(callback) {
|
||||||
|
let error = null;
|
||||||
try {
|
try {
|
||||||
this._flushCluster();
|
this._flushCluster();
|
||||||
callback();
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
callback(err);
|
error = err;
|
||||||
}
|
}
|
||||||
|
callback(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user