@torrent-tv/proxy 2.100.6 → 2.100.8
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
|
@@ -855,7 +855,12 @@ export class ViewerRequests {
|
|
|
855
855
|
const segments = [];
|
|
856
856
|
for (let index = 0; index < count; index++) {
|
|
857
857
|
const endSeconds = timeline.publishedStartOf(index + 1);
|
|
858
|
-
|
|
858
|
+
// Only a made piece has media intervals to read. Asked of every piece,
|
|
859
|
+
// each one not made cost a `stat` of its file in the store's safety net
|
|
860
|
+
// for a missed directory event: 1327 per poll per output, 12.6 s of 300 s
|
|
861
|
+
// of the main thread at a cold start on Home Assistant (r61,
|
|
862
|
+
// torrent-tv/meta#178), while requests waited behind it.
|
|
863
|
+
const ranges = inventory.has(index) ? this.#host.encodeRuns.finishedMediaRangesOf(output, index) : undefined;
|
|
859
864
|
const mediaRanges = ranges && output.segmentFormat?.servedMediaRanges ?
|
|
860
865
|
output.segmentFormat.servedMediaRanges(ranges, { initBytes: sessionInit }) : undefined;
|
|
861
866
|
if (index !== 0 && mediaRanges === undefined && !inventory.has(index) &&
|
|
@@ -104,6 +104,17 @@ export class SegmentStore {
|
|
|
104
104
|
|
|
105
105
|
/** Output key → how to read its file names. @type {Map<string, object>} */
|
|
106
106
|
#formats = new Map();
|
|
107
|
+
/**
|
|
108
|
+
* The outputs whose served pieces this store names itself, in `publish`.
|
|
109
|
+
* Their record is complete by construction: a piece arrives through
|
|
110
|
+
* `publish` and leaves through this store's removals. Only an output whose
|
|
111
|
+
* muxer renames its own pieces into place (the `hls` branch, taken where
|
|
112
|
+
* there is no grid of cuts) can hold a piece the record has not been told
|
|
113
|
+
* of yet, and only there does `pathOf` look at the disk.
|
|
114
|
+
*
|
|
115
|
+
* @type {Set<string>}
|
|
116
|
+
*/
|
|
117
|
+
#publishing = new Set();
|
|
107
118
|
#reads = new Map();
|
|
108
119
|
|
|
109
120
|
/** Hold physical material while a read is prepared or its stream is open. */
|
|
@@ -668,6 +679,7 @@ export class SegmentStore {
|
|
|
668
679
|
}
|
|
669
680
|
// Publication registers the material even after the previous directory was dropped.
|
|
670
681
|
this.useFormat(key, format);
|
|
682
|
+
this.#publishing.add(key);
|
|
671
683
|
// What the directory holds has changed by this one piece.
|
|
672
684
|
if (index >= 0) this.#heldArrived(key, index);
|
|
673
685
|
else this.#held.delete(key);
|
|
@@ -1135,10 +1147,15 @@ export class SegmentStore {
|
|
|
1135
1147
|
this.#touched.set(key, this.#now());
|
|
1136
1148
|
const contents = this.refresh(key);
|
|
1137
1149
|
const found = contents.byNumber.get(index);
|
|
1138
|
-
|
|
1150
|
+
// An output this store publishes answers from its record alone. Looking
|
|
1151
|
+
// at the disk for every piece not made, as it did for every output, cost
|
|
1152
|
+
// the main thread 12.6 s of 300 s at a cold start on Home Assistant, the
|
|
1153
|
+
// forecast asking about each piece of the film on every poll (r61,
|
|
1154
|
+
// torrent-tv/meta#178).
|
|
1155
|
+
if (found || !contents.followed || this.#publishing.has(key)) return found ?? null;
|
|
1139
1156
|
// A reading kept up piece by piece answers from what it was told, and a
|
|
1140
|
-
//
|
|
1141
|
-
//
|
|
1157
|
+
// piece a muxer renamed into place may not have been told of yet. The one
|
|
1158
|
+
// file asked about is looked at — a `stat`, not a listing.
|
|
1142
1159
|
this.#heldArrived(key, index);
|
|
1143
1160
|
return contents.byNumber.get(index) ?? null;
|
|
1144
1161
|
}
|
|
@@ -1178,6 +1195,7 @@ export class SegmentStore {
|
|
|
1178
1195
|
}
|
|
1179
1196
|
this.#held.delete(key);
|
|
1180
1197
|
this.#formats.delete(key);
|
|
1198
|
+
this.#publishing.delete(key);
|
|
1181
1199
|
this.#mediaRanges.delete(key);
|
|
1182
1200
|
this.#touched.delete(key);
|
|
1183
1201
|
this.#inits.delete(key);
|