@torrent-tv/proxy 2.107.43 → 2.107.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -856,6 +856,7 @@ function scheduleTail({ trackState, sourceState, runStarts, trackFinish, link,
|
|
|
856
856
|
|
|
857
857
|
let outputBits = 0;
|
|
858
858
|
let latestTrackFinish = 0;
|
|
859
|
+
let earliestTrackStart = Number.POSITIVE_INFINITY;
|
|
859
860
|
for (let trackIndex = 0; trackIndex < trackState.length; trackIndex += 1) {
|
|
860
861
|
const state = trackState[trackIndex];
|
|
861
862
|
const end = state.tailEndSeconds;
|
|
@@ -874,7 +875,9 @@ function scheduleTail({ trackState, sourceState, runStarts, trackFinish, link,
|
|
|
874
875
|
const localStart = tailStart - state.clockSeconds;
|
|
875
876
|
const inRun = run.spans.some(span => localStart >= span.start && localStart < span.end);
|
|
876
877
|
const open = work > 0 && !inRun ? run.openSeconds : 0;
|
|
877
|
-
const
|
|
878
|
+
const productionStart = trackFinish[trackIndex] + open;
|
|
879
|
+
const finishedAt = work > 0 ? processing.finish(work, productionStart) : trackFinish[trackIndex];
|
|
880
|
+
if (work > 0) earliestTrackStart = Math.min(earliestTrackStart, productionStart);
|
|
878
881
|
latestTrackFinish = Math.max(latestTrackFinish, finishedAt);
|
|
879
882
|
const deliveryStart = Math.max(tailStart, position + buffered);
|
|
880
883
|
outputBits += Math.max(0, state.bitsPerMediaSecond) * Math.max(0, end - deliveryStart);
|
|
@@ -885,7 +888,13 @@ function scheduleTail({ trackState, sourceState, runStarts, trackFinish, link,
|
|
|
885
888
|
|
|
886
889
|
if (outputBits > 0) {
|
|
887
890
|
const end = Math.max(...trackState.map(state => state.tailEndSeconds));
|
|
888
|
-
|
|
891
|
+
// Production and transfer are tandem services. Starting the link only
|
|
892
|
+
// after the last track finishes charges both complete workloads in series.
|
|
893
|
+
// The fluid suffix is bounded by the later service completion, with the
|
|
894
|
+
// link queue beginning no earlier than the first produced output.
|
|
895
|
+
const deliveryStart = Math.max(transferFinish, Number.isFinite(earliestTrackStart) ? earliestTrackStart : 0);
|
|
896
|
+
const deliveryAt = link.finish(outputBits, deliveryStart);
|
|
897
|
+
const completedAt = Math.max(latestTrackFinish, deliveryAt);
|
|
889
898
|
const ahead = Math.max(0, end - position);
|
|
890
899
|
constrain(completedAt - Math.max(0, ahead - reserve), "delivery", 0,
|
|
891
900
|
trackState[0]?.segments.at(-1)?.index ?? 0, completedAt, ahead, false, sourceArrivalAt, false);
|