mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-02 19:42:51 +08:00
fix: keep accompaniment audible while microphone is muted
This commit is contained in:
1 parent
051cb402e5
commit
777c779d79
8 files changed
+166
-16
No files matched your search
@@ -1,15 +1,15 @@
|
||||
# WebSpeak 代码待修改清单与修改方向
|
||||
|
||||
本文聚焦 `webspeak-webclient`,记录当前代码结构、待修改项、大致修改方向与验收条件。2026 年 10 月 2 日用户指定 `203.0.113.10:9987` 为 TeamSpeak 测试服务器,并明确 Android 暂不纳入修复计划。本机两次真实连接均在认证前超时,传输诊断未收到该服务器 UDP 回包,尚不能开展目录与媒体链路验收。管理诊断和备份的实际下载、审计文案修复及 Windows/Linux/Docker 构建启动已有证据;原生弹窗、真实媒体和兼容验收仍待完成。缺少验证证据的事项不直接认定为代码故障。
|
||||
本文聚焦 `webspeak-webclient`,记录当前代码结构、待修改项、大致修改方向与验收条件。2026 年 10 月 3 日按用户新地址 `webspeak.example.invalid:9987` 成功连接 TeamSpeak 3.13.8 / Linux,完成真实目录、私聊、状态及 PCM/WebRTC 媒体链路检查,并修复实测发现的麦克风静音时伴奏被 TeamSpeak 丢弃的问题。Android 已按用户要求移出本轮修复计划。原生弹窗、完整音质、TS6 及旧版本兼容验收仍待完成;缺少验证证据的事项不直接认定为代码故障。
|
||||
|
||||
按用户要求,每批仅处理当前节点相关问题,合并相关修复后统一验证,不扩展到无关模块。管理页主要交互与布局已检查,原生确认框阻塞的操作验收单独保留。加入、聊天、频道成员、成员菜单、音频设置及密码弹窗已拆分;音频工具栏、私语控制条、语音诊断、共享设置与播放器已提取,语音活动成员卡片也已提取。06-L 的保序格式整理及两份页面样式确认冗余项已完成。真实消息兼容与 TeamSpeak 媒体继续跟踪;Android 既有结果仅作历史记录,不作为当前完成门槛。媒体、连接、命令、诊断、消息、身份及公共皮肤状态已有独立模块,继续复用。当前待办和实施方向放在前部,历史修复及验证记录保留在后部。
|
||||
|
||||
## 范围与依据
|
||||
|
||||
- 记录日期:2026 年 10 月 2 日。
|
||||
- 当前记录基线:`dev` 分支,`6aa19c4cd66b6eed27085ebdc6b3e9d376b1810a`;应用版本 `0.2.5-preview`。以下现状包含当前工作区,不能全部归为该提交的内容。
|
||||
- 本批使用实际 `TSClient`、锁定 SDK 及用户指定服务器执行连接与传输诊断,并更新范围记录;没有修改应用源码或重新运行已通过的本地测试。此前管理事件名称修改通过 20 项管理测试、前端类型检查及生产构建,浏览器复查显示具体审计名称。
|
||||
- 基线 CI 的应用验证、Docker 构建和健康检查已确认成功(运行 36896144974)。此前 `662dad3` 的手动发布工作流完整验证、Windows/Linux 打包启动及 Docker 健康检查通过(运行 36857782727);正式 Release 步骤跳过。
|
||||
- 记录日期:2026 年 10 月 3 日。
|
||||
- 当前记录基线:`dev` 分支,`b649f8b6c45e05a262221fb604f71ee67e61f6be`;应用版本 `0.2.5-preview`。以下现状包含当前工作区,不能全部归为该提交的内容。
|
||||
- 本批只修改 TeamSpeak 输入静音与伴奏状态协调、WebRTC 启停接线及相关测试。新增 7 项回归;统一验证最终通过 416 项测试、后端编译、前端类型检查及生产构建。首次统一运行暴露旧桥接测试替身缺少新增接口,补齐替身并增加生命周期覆盖后重跑通过;未按每处小改动重复验证。
|
||||
- `6aa19c4` 的 CI、Docker 构建和健康检查已确认成功(运行 36896144974)。此前 `662dad3` 的手动发布工作流完整验证、Windows/Linux 打包启动及 Docker 健康检查通过(运行 36857782727);本批远端 CI 按新提交核对。
|
||||
- 既有皮肤修复记录记载新增 23 项测试,以及 `npm run verify` 通过 385 项测试和前后端构建;其中 5 项先复现旧结果覆盖及失效归属问题。这些是此前批次的验证结果,不是本轮重新执行的结果。
|
||||
- Android 从 `662dad3` 源码归档重新安装三套依赖并重建 SDK,在短路径完成 android:sync 和 assembleDebug,134 个 Gradle 任务执行,三个 ABI 包内容及 SHA-256 已检查。首次深层目录因原生工具路径限制失败,短路径重建通过;没有把构建成功写成设备或媒体验收。
|
||||
- 各平台构建环境、执行范围、Actions 归档摘要与本机 APK 校验和见 `docs/LOCAL_ARTIFACTS.zh-CN.md`。`662dad3` 的 x86_64 新包已在只读 Android 15 模拟器安装并冷启动,内嵌网关返回正确健康状态和版本;Android 布局复验仍待可交互环境。
|
||||
@@ -51,18 +51,29 @@
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 06-C 客户端验收 | P2 | 计划中的主要展示区域已提取;真实触屏拖动及原生离开/戳人输入框流程仍待验收 | 保留当前状态边界,在支持的浏览器/真机补齐实际交互证据;不为工具限制重写业务 | 触屏拖动及原生输入框完成操作、取消与结果均有记录 |
|
||||
| 06-C 管理页 | P2 | 展示拆分、主要交互及诊断/备份实际下载已验收;移除皮肤的原生确认框仍使浏览器工具超时,移除和断开会话的完整浏览器流程缺记录 | 保留确认与业务逻辑,工具恢复或人工检查时补验;同一工具阻塞不反复重试 | 移除、断开的确认与取消均有实际结果记录;状态及接口测试不能替代完整浏览器链路 |
|
||||
| 03 | P2 | 共享契约已落地,真实收发与旧客户端兼容仍缺验收证据 | 用脱敏的实际消息样本核对字段、默认值、非法输入及兼容范围 | 两端解析一致;非法消息受控处理,不误丢有效事件 |
|
||||
| 02-C | P2 | 用户已提供测试服务器;本机连接 `203.0.113.10:9987` 两次超时,UDP 诊断未收到目标回包 | 先确认公网 UDP 9987 可达及是否有 VPN/中继/来源白名单要求,再验收双向语音、WebRTC 回退、伴奏和多用户 | 记录实际服务器版本、浏览器、网络、设备、步骤及结果;单个未知版本端点不预先认定覆盖 TS3 和 TS6 |
|
||||
| 03 | P2 | TS3 实服目录、双向私聊、离开与戳人消息通过共享解析器;省略可选 UID 的请求可用;真实旧客户端/旧网关版本矩阵未验收 | 保留实际样本的验证范围,指定旧版本后补交叉版本检查 | 两端解析一致;非法消息受控处理;旧格式请求不等于旧应用整体通过 |
|
||||
| 02-C | P2 | `webspeak.example.invalid:9987` 的 TS3 实服 PCM/WebRTC 双向链路通过,静音伴奏故障已修复;连续音质、浏览器设备采集、TS6、多人混音及完整回退/共享仍缺验收 | 先复查 WebRTC 下行连续性及真实浏览器采集,再补场景矩阵;使用新域名端点,不重复旧 IP 超时探测 | 记录服务器版本、浏览器、网络、设备、步骤及结果;网关与合成客户端验收不替代设备和完整音质 |
|
||||
|
||||
当前范围调整:07-A 全部 Android 运行时、真机和媒体事项,以及 09-A 的 Android 布局复验,按用户要求暂不纳入本轮修复和完成条件。已有 Android 构建及启动记录保留,不认定为这些剩余能力已通过。09-A 在本轮保留的 Windows/Linux/Docker 干净构建与启动要求已完成。
|
||||
|
||||
### 指定 TeamSpeak 服务器连接记录(2026-10-02)
|
||||
### 旧 IP 连接记录(2026-10-02,已由域名端点替代)
|
||||
|
||||
- 用户给出的 HTTP 形式链接按 TeamSpeak 地址 `203.0.113.10:9987` 使用;连接走 SDK 的 UDP 客户端协议,没有把 HTTP 探测当作 TeamSpeak 连通证据。
|
||||
- 使用当前源码的 `TSClient`、锁文件 SDK 和临时测试身份,不读取或修改真实配置、密码或持久身份。第一次连接返回 `timeout / TeamSpeak connection timed out`,随后正常断开。
|
||||
- 第二次在相同实际连接外增加只计数的 UDP 诊断:发起 15 次发送、510 字节,从该服务器收到 0 个数据报、0 字节,未收到 socket error 事件;同样超时并清理连接。这是进程级发送/接收记录,不是网卡抓包证据。
|
||||
- 两次均未取得已认证会话、服务器版本或目录,未发送聊天、戳人或音频。当前只能确认本机未获得协议响应,不能区分服务端状态、网络路径或协议响应原因;待确认公网 UDP 端口及接入条件后继续该节点。
|
||||
|
||||
### 域名实服与静音伴奏修复(2026-10-03)
|
||||
|
||||
- 通过当前 `TSClient` 和锁定 SDK 连接 `webspeak.example.invalid:9987`,服务器返回 `3.13.8`、build `1779874471`、Linux;初次连接约 7.2 秒,自身目录项存在,正常断开。此前 IP 超时不再作为当前接入阻塞。
|
||||
- 两个临时 WebSocket 客户端经本机实际 `VoiceBridge` 连接远端服务,使用真实原生 Opus,无 SDK/编码器替身。临时身份不写入用户配置;私聊、戳人及私语音频仅发给测试会话。目录互见、带 UID 与省略 UID 的私聊、离开/返回、戳人和非法 PCM 拒绝通过;所见 JSON 消息全部通过共享解析器。
|
||||
- WebRTC 使用本机 werift 合成端点,经真实 ICE/DTLS/SRTP 与网关通信,再通过真实 TeamSpeak 服务到另一测试端。修复后上行 50/50 帧到达;反向 50 帧被网关接收并转发到 WebRTC,输出能解码出测试音频。没有使用浏览器麦克风、扬声器或屏幕采集。
|
||||
- 故障先在实服复现:麦克风静音后开启伴奏,网关发送 30 帧,对端收到 0 帧;仅取消静音后,同一伴奏收到 30 帧。原因是 `client_input_muted=1` 会使服务器丢弃该客户端的全部音频,而网关原本只更新混音器伴奏标志。
|
||||
- SDK 适配层现在分别记录逻辑麦克风静音和伴奏状态,串行提交组合后的 TeamSpeak 输入标志,成功后才更新状态;失败不污染后续更新,旧连接的排队/迟到结果失效。播放伴奏时允许整体输入,浏览器仍将麦克风静音;停止伴奏、WebRTC 停止及协商失败恢复输入状态,初始静音加伴奏也走相同处理。
|
||||
- 修复后静音伴奏和初始静音加伴奏均收到 30/30 帧(codec 5);停止伴奏后再次发送的帧均被抑制,关闭 WebRTC 后其他会话看到输入静音恢复。活动 WebRTC 停止后 PCM 恢复,本次观察收到 48/50 帧。测试会话已全部关闭,本机网关活动计数归零。
|
||||
- 质量边界:WebRTC 下行采样中,50 帧远端输入只有 30 个输出帧达到所设 RMS 门槛;该段网关记录 0 队列丢弃、0 解码错误,不能据此判断连续音质通过,也不能直接把帧数差归为网络丢包。下行解码连续性与混音仍需定位。合成无效 SDP 的尝试得到 answer,没有形成预期失败,因此未记为协商失败回退通过。
|
||||
- 416 项本地统一验证及实服结果覆盖本节点;TS6、旧应用版本、浏览器设备、多人/跨频道共享和原生输入框仍按待办推进,Android 不重新纳入。
|
||||
|
||||
## 待修改事项的具体方向
|
||||
|
||||
### 04-D 前端媒体与连接编排
|
||||
|
||||
@@ -16,6 +16,9 @@ const rows = [{ client_unique_identifier: "member", client_flag_avatar: "marker"
|
||||
const transfer = { size: 6n };
|
||||
|
||||
class SdkStub extends EventEmitter {
|
||||
inputCommands: string[] = [];
|
||||
inputUpdate = async (_command: string): Promise<void> => {};
|
||||
async execCommand(command: string) { this.inputCommands.push(command); await this.inputUpdate(command); }
|
||||
initialized = 0;
|
||||
downloaded = 0;
|
||||
metadata = async () => rows;
|
||||
@@ -36,6 +39,57 @@ function fixture() {
|
||||
return { client, sdk, state };
|
||||
}
|
||||
|
||||
test("accompaniment remains audible with the microphone muted and stopping restores mute", async () => {
|
||||
const f = fixture();
|
||||
await f.client.setInputMuted(true);
|
||||
await f.client.setAccompanimentActive(true);
|
||||
await f.client.setInputMuted(true);
|
||||
await f.client.setAccompanimentActive(false);
|
||||
await f.client.setInputMuted(false);
|
||||
assert.deepEqual(f.sdk.inputCommands, [1, 0, 0, 1, 0].map(value => `clientupdate client_input_muted=${value}`));
|
||||
});
|
||||
|
||||
test("overlapping microphone and accompaniment changes use the last accepted input state", async () => {
|
||||
const f = fixture();
|
||||
const pending = deferred<void>();
|
||||
f.sdk.inputUpdate = async () => pending.promise;
|
||||
const mute = f.client.setInputMuted(true);
|
||||
const music = f.client.setAccompanimentActive(true);
|
||||
await nextTurn();
|
||||
assert.equal(f.sdk.inputCommands.length, 1);
|
||||
pending.resolve();
|
||||
await Promise.all([mute, music]);
|
||||
assert.deepEqual(f.sdk.inputCommands, ["clientupdate client_input_muted=1", "clientupdate client_input_muted=0"]);
|
||||
});
|
||||
|
||||
test("a rejected accompaniment update cannot change later mute decisions or poison the queue", async () => {
|
||||
const f = fixture();
|
||||
await f.client.setInputMuted(true);
|
||||
f.sdk.inputUpdate = async () => { throw new Error("denied"); };
|
||||
await assert.rejects(f.client.setAccompanimentActive(true), /denied/);
|
||||
f.sdk.inputUpdate = async () => {};
|
||||
await f.client.setInputMuted(true);
|
||||
assert.equal(f.sdk.inputCommands.at(-1), "clientupdate client_input_muted=1");
|
||||
});
|
||||
|
||||
test("queued and in-flight input changes cannot cross a disconnected session", async () => {
|
||||
const f = fixture();
|
||||
const pending = deferred<void>();
|
||||
f.sdk.inputUpdate = async () => pending.promise;
|
||||
const first = assert.rejects(f.client.setAccompanimentActive(true), /session changed/);
|
||||
const queued = assert.rejects(f.client.setInputMuted(true), /not ready/);
|
||||
await nextTurn();
|
||||
await f.client.disconnect();
|
||||
f.state.client = f.sdk;
|
||||
f.state.connected = true;
|
||||
pending.resolve();
|
||||
await Promise.all([first, queued]);
|
||||
assert.equal(f.sdk.inputCommands.length, 1);
|
||||
f.sdk.inputUpdate = async () => {};
|
||||
await f.client.setInputMuted(true);
|
||||
assert.equal(f.sdk.inputCommands.at(-1), "clientupdate client_input_muted=1");
|
||||
});
|
||||
|
||||
test("an old avatar metadata response cannot start a transfer on a replacement SDK client", async () => {
|
||||
const f = fixture();
|
||||
const pending = deferred<typeof rows>();
|
||||
|
||||
+26
-2
@@ -87,6 +87,8 @@ export class TSClient extends EventEmitter {
|
||||
private clientId = 0;
|
||||
private connected = false;
|
||||
private connectionGeneration = 0;
|
||||
private inputState = { muted: false, accompaniment: false };
|
||||
private inputStateQueue: Promise<void> = Promise.resolve();
|
||||
private preferredChannelId = 0n;
|
||||
private accelerationClient: AccelerationRelayClient | null = null;
|
||||
// Reason id of the most recent self leave, kept so the SDK `kicked` event can
|
||||
@@ -102,6 +104,8 @@ export class TSClient extends EventEmitter {
|
||||
|
||||
async connect(): Promise<void> {
|
||||
this.connectionGeneration++;
|
||||
this.inputState = { muted: false, accompaniment: false };
|
||||
this.inputStateQueue = Promise.resolve();
|
||||
this.selfLeaveReasonId = null;
|
||||
if (!this.adapter || !this.client) {
|
||||
let transportTarget = this.options.target;
|
||||
@@ -357,8 +361,28 @@ export class TSClient extends EventEmitter {
|
||||
}
|
||||
|
||||
async setInputMuted(muted: boolean): Promise<void> {
|
||||
if (!this.client || !this.connected) throw new Error("TeamSpeak session is not ready");
|
||||
await this.client.execCommand(`clientupdate client_input_muted=${muted ? 1 : 0}`);
|
||||
await this.updateInputState({ muted });
|
||||
}
|
||||
|
||||
async setAccompanimentActive(accompaniment: boolean): Promise<void> {
|
||||
await this.updateInputState({ accompaniment });
|
||||
}
|
||||
|
||||
private updateInputState(change: Partial<typeof this.inputState>): Promise<void> {
|
||||
const client = this.client;
|
||||
const generation = this.connectionGeneration;
|
||||
const isCurrent = () => client !== null && this.client === client && this.connected && this.connectionGeneration === generation;
|
||||
const update = this.inputStateQueue.then(async () => {
|
||||
if (!isCurrent()) throw new Error("TeamSpeak session is not ready");
|
||||
const next = { ...this.inputState, ...change };
|
||||
// TeamSpeak discards all audio from an input-muted client, including
|
||||
// music. The browser removes the microphone from its accompaniment mix.
|
||||
await client!.execCommand(`clientupdate client_input_muted=${next.muted && !next.accompaniment ? 1 : 0}`);
|
||||
if (!isCurrent()) throw new Error("TeamSpeak session changed while updating input state");
|
||||
this.inputState = next;
|
||||
});
|
||||
this.inputStateQueue = update.catch(() => undefined);
|
||||
return update;
|
||||
}
|
||||
|
||||
async switchChannel(channelId: bigint, password?: string): Promise<void> {
|
||||
|
||||
@@ -26,6 +26,7 @@ class TeamSpeakStub extends EventEmitter {
|
||||
getChannelId() { return 1n; }
|
||||
isConnected() { return !this.disconnected; }
|
||||
async sendProtocolCommand() {}
|
||||
async setAccompanimentActive() {}
|
||||
sendVoice(data: Buffer) { this.sent.push(data); this.emit("sent", data); }
|
||||
sendWhisper(data: Buffer) { this.sent.push(data); }
|
||||
getClientAvatar(id: number, uid: string) { return this.avatarRequest(id, uid); }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { setImmediate as nextTurn } from "node:timers/promises";
|
||||
import pino from "pino";
|
||||
import { VoiceBridge } from "./voice-bridge.js";
|
||||
import { JoinTicketStore } from "./join-ticket.js";
|
||||
@@ -35,7 +36,7 @@ function fixture() {
|
||||
const entry = {
|
||||
id: "session", session: { state: "connected" }, ws: { readyState: 1 as 0 | 1 | 2 | 3, bufferedAmount: 0, send() {} },
|
||||
webrtc: null as PeerStub | null, webrtcGeneration: 0,
|
||||
tsClient: { setInputMuted: async (_muted: boolean) => {}, sendVoice: () => { forwarded++; }, sendWhisper: () => { forwarded++; } },
|
||||
tsClient: { isConnected: () => true, setInputMuted: async (_muted: boolean) => {}, setAccompanimentActive: async (_active: boolean) => {}, sendVoice: () => { forwarded++; }, sendWhisper: () => { forwarded++; } },
|
||||
whisperActive: false, whisperTargetIds: new Set<number>(), audio: createAudioFlowStats(),
|
||||
audioTransport: null as SessionAudioTransport | null,
|
||||
};
|
||||
@@ -116,8 +117,7 @@ test("a superseded answer failure cannot send an error for the current offer", a
|
||||
const answer = deferred();
|
||||
f.configure(peer => { if (f.peers.length === 1) peer.answerResult = answer.promise; });
|
||||
const old = f.offer("old");
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
await nextTurn();
|
||||
await f.offer("new");
|
||||
const current = f.entry.webrtc;
|
||||
answer.reject(new Error("old peer closed"));
|
||||
@@ -163,6 +163,35 @@ test("a current peer construction failure reports a recoverable negotiation erro
|
||||
assert.deepEqual(f.messages, [{ type: "webrtcError", code: "WEBRTC_NEGOTIATION_FAILED" }]);
|
||||
});
|
||||
|
||||
test("initial accompaniment updates TeamSpeak before creating a muted mixer and resets on stop", async () => {
|
||||
const f = fixture();
|
||||
const inputs: Array<[string, boolean]> = [];
|
||||
f.entry.tsClient.setInputMuted = async muted => { inputs.push(["muted", muted]); };
|
||||
f.entry.tsClient.setAccompanimentActive = async active => { inputs.push(["music", active]); };
|
||||
await f.bridge.handleWebRtcOffer(f.entry, { type: "offer", sdp: "audio", muted: true, accompanimentActive: true }, message => f.messages.push(message));
|
||||
assert.deepEqual(inputs, [["music", false], ["muted", true], ["music", true]]);
|
||||
assert.equal(f.peers[0]?.options.microphoneMuted, true);
|
||||
assert.equal(f.peers[0]?.options.accompanimentActive, true);
|
||||
await f.bridge.stopWebRtc(f.entry);
|
||||
assert.deepEqual(inputs.at(-1), ["music", false]);
|
||||
});
|
||||
|
||||
test("stopping during accompaniment synchronization restores input even without a peer", async () => {
|
||||
const f = fixture();
|
||||
const waiting = deferred();
|
||||
const inputs: boolean[] = [];
|
||||
f.entry.tsClient.setAccompanimentActive = async active => { inputs.push(active); if (active) await waiting.promise; };
|
||||
const offer = f.bridge.handleWebRtcOffer(f.entry, { type: "offer", sdp: "audio", muted: true, accompanimentActive: true }, message => f.messages.push(message));
|
||||
await nextTurn();
|
||||
assert.deepEqual(inputs, [false, true]);
|
||||
await f.bridge.stopWebRtc(f.entry);
|
||||
waiting.resolve();
|
||||
await offer;
|
||||
assert.deepEqual(inputs, [false, true, false]);
|
||||
assert.equal(f.peers.length, 0);
|
||||
assert.deepEqual(f.messages, []);
|
||||
});
|
||||
|
||||
test("old close statistics cannot overwrite a new peer's live snapshot", async () => {
|
||||
const f = fixture();
|
||||
await f.offer("old");
|
||||
|
||||
@@ -659,8 +659,14 @@ export class VoiceBridge {
|
||||
const generation = ++entry.webrtcGeneration;
|
||||
const peer = entry.webrtc;
|
||||
entry.webrtc = null;
|
||||
if (!peer) return;
|
||||
// Enqueue the reset even while an offer is still preparing its first peer.
|
||||
// A later offer's input changes are then ordered after this restoration.
|
||||
const restoreInput = this.entries.get(entry.id) === entry && entry.tsClient.isConnected()
|
||||
? entry.tsClient.setAccompanimentActive(false).catch(() => undefined)
|
||||
: Promise.resolve();
|
||||
if (!peer) { await restoreInput; return; }
|
||||
try { await peer.close(); } catch { /* peer teardown is idempotent */ }
|
||||
await restoreInput;
|
||||
if (entry.webrtcGeneration === generation) {
|
||||
try { Object.assign(entry.audio, peer.getStats()); } catch { /* diagnostics must not abort cleanup */ }
|
||||
}
|
||||
@@ -686,6 +692,7 @@ export class VoiceBridge {
|
||||
// the browser track locally, but TeamSpeak clients only see the state
|
||||
// after the gateway updates its own TS client as well.
|
||||
await entry.tsClient.setInputMuted(muted);
|
||||
if (isCurrent()) await entry.tsClient.setAccompanimentActive(offer.accompanimentActive === true);
|
||||
} catch (error: unknown) {
|
||||
if (isCurrent()) this.logger.warn({ entryId: entry.id, muted, err: error instanceof Error ? error.message : String(error) }, "Could not synchronize initial microphone mute state");
|
||||
}
|
||||
@@ -719,6 +726,8 @@ export class VoiceBridge {
|
||||
if (entry.webrtc === peer) entry.webrtc = null;
|
||||
try { await peer?.close(); } catch { /* best effort */ }
|
||||
if (isCurrent()) {
|
||||
try { await entry.tsClient.setAccompanimentActive(false); } catch { /* best effort */ }
|
||||
if (!isCurrent()) return;
|
||||
this.logger.warn({ entryId: entry.id, err: error instanceof Error ? error.message : String(error) }, "WebRTC audio negotiation failed");
|
||||
sendJson({ type: "webrtcError", code: "WEBRTC_NEGOTIATION_FAILED" });
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ function fixture() {
|
||||
poke: async (...args) => { calls.push(["poke", ...args]); },
|
||||
setAway: async (...args) => { calls.push(["away", ...args]); },
|
||||
setInputMuted: async (...args) => { calls.push(["mute", ...args]); },
|
||||
setAccompanimentActive: async (...args) => { calls.push(["accompaniment", ...args]); },
|
||||
},
|
||||
channelTree: [{ id: "18446744073709551615", parentID: "0", name: "Large ID" }],
|
||||
members,
|
||||
@@ -134,6 +135,23 @@ test("chat routing uses the current channel, server scope, and private target in
|
||||
assert.deepEqual(f.messages.at(-1), { type: "commandCompleted", requestId: "empty" });
|
||||
});
|
||||
|
||||
test("accompaniment changes reach the mixer only after TeamSpeak accepts them", async () => {
|
||||
const f = fixture();
|
||||
let active = false;
|
||||
f.context.webrtc = {
|
||||
getStats: createAudioFlowStats, setMicrophoneMuted() {}, setMemberVolume() {},
|
||||
setAccompanimentActive: value => { active = value; },
|
||||
};
|
||||
f.context.tsClient.setAccompanimentActive = async () => { throw Object.assign(new Error("denied"), { id: 2568 }); };
|
||||
await f.run({ type: "setAccompanimentActive", payload: { active: true }, requestId: "music-denied" });
|
||||
assert.equal(active, false);
|
||||
assert.equal(f.messages.at(-1)?.type, "error");
|
||||
f.context.tsClient.setAccompanimentActive = async () => {};
|
||||
await f.run({ type: "setAccompanimentActive", payload: { active: true }, requestId: "music-ok" });
|
||||
assert.equal(active, true);
|
||||
assert.deepEqual(f.messages.at(-1), { type: "commandCompleted", requestId: "music-ok" });
|
||||
});
|
||||
|
||||
test("audio probing is bounded per session and accepts the next request at the interval boundary", async () => {
|
||||
const f = fixture();
|
||||
f.context.audio.ingressFrames = 8;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { teamSpeakServerErrorCode } from "../errors.js";
|
||||
|
||||
/** Only the session capabilities used by control commands cross this boundary. */
|
||||
export interface VoiceCommandContext extends AudioStatsSource {
|
||||
tsClient: Pick<TSClient, "execCommandWithResponse" | "switchChannel" | "getClientId" | "getChannelId" | "moveClient" | "sendTextMessage" | "poke" | "setAway" | "setInputMuted">;
|
||||
tsClient: Pick<TSClient, "execCommandWithResponse" | "switchChannel" | "getClientId" | "getChannelId" | "moveClient" | "sendTextMessage" | "poke" | "setAway" | "setInputMuted" | "setAccompanimentActive">;
|
||||
channelTree: ChannelInfo[];
|
||||
members: ReadonlyMap<number, { uid?: string }>;
|
||||
whisperTargetIds: Set<number>;
|
||||
@@ -154,7 +154,11 @@ export async function handleCommand(
|
||||
await entry.tsClient.setInputMuted(muted);
|
||||
entry.webrtc?.setMicrophoneMuted(muted);
|
||||
} else if (command.type === "setAccompanimentActive") {
|
||||
entry.webrtc?.setAccompanimentActive(command.payload.active);
|
||||
const peer = entry.webrtc;
|
||||
if (peer) {
|
||||
await entry.tsClient.setAccompanimentActive(command.payload.active);
|
||||
if (entry.webrtc === peer) peer.setAccompanimentActive(command.payload.active);
|
||||
}
|
||||
} else if (command.type === "setMemberVolume") {
|
||||
const clientId = command.payload.clientId;
|
||||
entry.webrtc?.setMemberVolume(clientId, command.payload.volume);
|
||||
|
||||
Reference in new issue
Block a user