mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
fix: update Icy-MetaData header and optimize StreamPositioner logic
This commit is contained in:
1 parent
5866dbf8d8
commit
cc91e602fc
3 files changed
+6
-9
No files matched your search
+1
-1
@@ -187,4 +187,4 @@
|
|||||||
"spawnTimeout": 30000,
|
"spawnTimeout": 30000,
|
||||||
"spawnDelay": 5000
|
"spawnDelay": 5000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ export class FluxerAudioBridge extends EventEmitter {
|
|||||||
headers: {
|
headers: {
|
||||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
||||||
"Accept": "*/*",
|
"Accept": "*/*",
|
||||||
"Icy-MetaData": "1",
|
"Icy-MetaData": "0",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
stream = opened.stream;
|
stream = opened.stream;
|
||||||
|
|||||||
@@ -327,10 +327,8 @@ export class StreamPositioner extends Transform {
|
|||||||
|
|
||||||
// Emit: cluster header (+ Timecode) then from the first surviving block on.
|
// Emit: cluster header (+ Timecode) then from the first surviving block on.
|
||||||
const skipped = firstKeptOffset - firstBlockRegionStart;
|
const skipped = firstKeptOffset - firstBlockRegionStart;
|
||||||
this._consume(firstKeptOffset); // buffer now starts at the surviving block
|
|
||||||
if (skipped > 0) {
|
if (skipped > 0) {
|
||||||
// Blocks were trimmed — the original size vint would now overstate the
|
this._consume(firstKeptOffset);
|
||||||
// payload and desync the demuxer. Rebuild the header with the real size.
|
|
||||||
const keptPayload =
|
const keptPayload =
|
||||||
(firstBlockRegionStart - headerLen) + (cluster.length - firstKeptOffset);
|
(firstBlockRegionStart - headerLen) + (cluster.length - firstKeptOffset);
|
||||||
this.push(Buffer.concat([
|
this.push(Buffer.concat([
|
||||||
@@ -451,19 +449,18 @@ export class StreamPositioner extends Transform {
|
|||||||
if (pageLen > MAX_OGG_PAGE_BYTES) { this._startPassthrough(); return; }
|
if (pageLen > MAX_OGG_PAGE_BYTES) { this._startPassthrough(); return; }
|
||||||
if (this._buf.length < pageLen) return;
|
if (this._buf.length < pageLen) return;
|
||||||
|
|
||||||
const granule = Number(this._buf.readBigUInt64LE(6));
|
const rawGranule = this._buf.readBigUInt64LE(6);
|
||||||
const page = Buffer.from(this._buf.subarray(0, pageLen));
|
const page = Buffer.from(this._buf.subarray(0, pageLen));
|
||||||
this._consume(pageLen);
|
this._consume(pageLen);
|
||||||
|
|
||||||
if (this._oggPagesKept < 2) {
|
if (this._oggPagesKept < 2) {
|
||||||
// OpusHead (BOS) + OpusTags pages must survive for the demuxer.
|
|
||||||
this._oggPagesKept++;
|
this._oggPagesKept++;
|
||||||
this.push(page);
|
this.push(page);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isFiller = granule === -1n || granule === 0xffffffffffffffffn;
|
const isFiller = rawGranule === 0xffffffffffffffffn;
|
||||||
if (!isFiller && granule >= this._targetMs * OPUS_SAMPLE_RATE) {
|
if (!isFiller && Number(rawGranule) >= this._targetMs * OPUS_SAMPLE_RATE) {
|
||||||
for (const p of this._oggReplay) this.push(p);
|
for (const p of this._oggReplay) this.push(p);
|
||||||
this._oggReplay = [];
|
this._oggReplay = [];
|
||||||
this._startPassthrough(page);
|
this._startPassthrough(page);
|
||||||
|
|||||||
Reference in new issue
Block a user