|
@@ -65,12 +65,23 @@ function HlsReader(segmentReader, options) {
|
|
|
this.isHooked = false;
|
|
this.isHooked = false;
|
|
|
this.buffer = new Passthrough({ highWaterMark: this.bufferSize });
|
|
this.buffer = new Passthrough({ highWaterMark: this.bufferSize });
|
|
|
|
|
|
|
|
- StreamEach(this.reader, this.process.bind(this), (err) => {
|
|
|
|
|
|
|
+ const processStreams = () => {
|
|
|
|
|
|
|
|
- if (err) throw err;
|
|
|
|
|
|
|
+ StreamEach(this.reader, this.process.bind(this), (err) => {
|
|
|
|
|
|
|
|
- this.buffer.end();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if (err) {
|
|
|
|
|
+ return processStreams(); // retry
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.buffer.end();
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ if (this.reader.index) {
|
|
|
|
|
+ processStreams();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.reader.once('index', processStreams);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// start output if needed
|
|
// start output if needed
|
|
|
if (!this.sync) {
|
|
if (!this.sync) {
|
|
@@ -133,6 +144,7 @@ HlsReader.prototype.process = async function(segmentInfo, done) {
|
|
|
this.hook();
|
|
this.hook();
|
|
|
}
|
|
}
|
|
|
catch (err) {
|
|
catch (err) {
|
|
|
|
|
+ console.error('process error', err.stack || err);
|
|
|
result = err;
|
|
result = err;
|
|
|
}
|
|
}
|
|
|
finally {
|
|
finally {
|