From fefe490c602608d14551956e5d67db454298adb9 Mon Sep 17 00:00:00 2001 From: NoLogicAlan Date: Fri, 11 Sep 2026 03:06:38 +0300 Subject: [PATCH] ... --- src/music/audio/FluxerAudioBridge.mjs | 34 ++++----------------------- 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/src/music/audio/FluxerAudioBridge.mjs b/src/music/audio/FluxerAudioBridge.mjs index c0b6db1..39bf974 100644 --- a/src/music/audio/FluxerAudioBridge.mjs +++ b/src/music/audio/FluxerAudioBridge.mjs @@ -80,12 +80,9 @@ export class FluxerAudioBridge extends EventEmitter { const direct = await this._getTrackstreamUrl(trackInfo); if (direct?.url && /webm|opus/i.test(direct.format || "")) { this._usedTrackstream = true; - logger.player("[AudioBridge] Passthrough webm/opus via trackstream: " + (trackInfo.title || "unknown")); + logger.player("[AudioBridge] Passthrough webm/opus via trackstream (zero-copy): " + (trackInfo.title || "unknown")); - const directLoaded = await this._httpRequestStream(direct.url, this._streamFetchHeaders(trackInfo)); - this._sourceStream = directLoaded.stream; - this._sourceReq = directLoaded.req || null; - await conn.play(directLoaded.stream); + await conn.play(direct.url); if (generation !== this._playGeneration) return "stopped"; if (durationMs > 0) await this._waitDuration(durationMs); @@ -108,11 +105,8 @@ export class FluxerAudioBridge extends EventEmitter { const freshDirect = await this._getTrackstreamUrl(trackInfo); if (freshDirect?.url && /webm|opus/i.test(freshDirect.format || "")) { this._usedTrackstream = true; - logger.player("[AudioBridge] Fresh trackstream is webm/opus — passthrough: " + (trackInfo.title || "unknown")); - const freshLoaded = await this._httpRequestStream(freshDirect.url, this._streamFetchHeaders(trackInfo)); - this._sourceStream = freshLoaded.stream; - this._sourceReq = freshLoaded.req || null; - await conn.play(freshLoaded.stream); + logger.player("[AudioBridge] Fresh trackstream is webm/opus — zero-copy passthrough: " + (trackInfo.title || "unknown")); + await conn.play(freshDirect.url); if (generation !== this._playGeneration) return "stopped"; if (durationMs > 0) await this._waitDuration(durationMs); if (generation !== this._playGeneration) return "stopped"; @@ -310,26 +304,6 @@ export class FluxerAudioBridge extends EventEmitter { } } - /** - * @param {object} trackInfo - * @returns {object} - * @private - */ - _streamFetchHeaders(trackInfo) { - const headers = {}; - if (trackInfo?.url && /^https?:\/\//i.test(trackInfo.url)) { - try { - const host = new URL(trackInfo.url).hostname; - if (/(^|\.)bilibili\.com$/i.test(host)) { - headers["Referer"] = "https://www.bilibili.com/"; - } else { - headers["Referer"] = new URL(trackInfo.url).origin + "/"; - } - } catch (_) {} - } - return headers; - } - /** Stop current playback and clean up resources. */ stop() { const wasPlaying = this._playing;