Rdzleo
b1577d8418
fix: 软 RTC 退出待命音三连修 + 尾音延迟
问题与修复(按发现顺序):
【问题1】AudioLoop guard 冻结 OnAudioOutput → 待命音队列永远不被消费
- 现象: WaitForAudioPlayback 3秒超时, 无声
- 根因: EnterIdleHibernate Step 0 设 hibernating_=true, AudioLoop 顶层
if(hibernating_) continue 会同时跳过 OnAudioInput + OnAudioOutput,
PlaySound 入队的 Opus 永远不解码。
- 修复: guard 下沉到 OnAudioInput 入口(仅 input 侧关 codec 有 bad_alloc 风险),
OnAudioOutput 自带 codec->output_enabled() 保护。
【问题2】volc_rtc_stop 副作用关 I2S 通道 → codec 状态错位
- 现象: 听到杂音而非待命音; i2s_channel_disable "not enabled yet" 错误
- 根因: 火山 RTC SDK 的 stop 内部关闭 ES8311 I2S, 但 codec class 内部
output_enabled_ 标志仍是 true → 状态错位, PlaySound 写入到 disabled 的 I2S。
- 修复: EnterIdleHibernate 在 PlaySound 前显式 EnableOutput(false→true)
强制重新激活 I2S, 并灌 200ms silence 覆盖 DMA 残留。
【问题3 - 真因】protocol downlink_is_pcm_ 标志位污染 → Opus 被当 PCM 字节流写出
- 现象: 杂音仍在
- 根因: 火山 RTC 下行音频是 PCM, DataCallback 设 downlink_is_pcm_=true。
LeaveRoom 没重置这个 flag, 后续 hibernate 中 PlaySound 入队的 Opus 包,
OnAudioOutput 读到 protocol_->downlink_is_pcm() 返回 true →
treat_as_pcm=true → 跳过 opus_decoder, 直接把 Opus 编码字节当 int16
PCM 样本写到 codec → 杂音。
- 修复: VolcRtcProtocol::LeaveRoom 末尾重置 downlink_is_pcm_=false +
first_downlink_logged_=false。唤醒重连后 DataCallback 收到首包会立即
重新设置该 flag, 不影响欢迎语 PCM 播放。
【问题4】WaitForAudioPlayback 完成 ≠ DMA 输出完成 → 尾音被截
- 现象: 待命音能听见但提前结束约 1 秒
- 根因: WaitForAudioPlayback 只判断 audio_decode_queue_ 出队完毕。
OnAudioOutput 是 background_task Schedule 异步执行 codec write,
队列空 ≠ codec 写完; codec.Write 返回 ≠ I2S DMA + ES8311 FIFO 输出完毕。
- 修复: WaitForAudioPlayback 之后追加 background_task->WaitForCompletion +
vTaskDelay(1000) 让 DMA 尾音自然衰减, 才关 player_pipeline。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 18:29:09 +08:00
..
2026-01-20 16:55:17 +08:00
2026-01-20 16:55:17 +08:00
2026-02-10 14:32:55 +08:00
2026-01-20 16:55:17 +08:00
2026-05-15 17:43:29 +08:00
2026-01-20 16:55:17 +08:00
2026-01-20 16:55:17 +08:00
2026-01-20 16:55:17 +08:00
2026-05-15 18:29:09 +08:00
2026-05-15 18:29:09 +08:00
2026-05-15 17:43:29 +08:00
2026-01-20 16:55:17 +08:00
2026-01-20 16:55:17 +08:00
2026-02-10 15:00:57 +08:00
2026-02-10 15:00:57 +08:00
2026-02-10 14:32:55 +08:00
2026-01-20 16:55:17 +08:00
2026-02-10 16:16:28 +08:00
2026-01-20 16:55:17 +08:00
2026-02-10 18:28:35 +08:00
2026-02-10 16:16:28 +08:00
2026-01-20 16:55:17 +08:00
2026-02-12 16:53:30 +08:00
2026-01-20 16:55:17 +08:00
2026-01-20 16:55:17 +08:00
2026-01-20 16:55:17 +08:00
2026-01-20 16:55:17 +08:00
2026-03-05 15:43:11 +08:00
2026-02-12 14:38:31 +08:00
2026-01-20 16:55:17 +08:00
2026-01-20 16:55:17 +08:00
2026-01-20 16:55:17 +08:00
2026-01-20 16:55:17 +08:00
2026-02-12 14:38:31 +08:00
2026-02-12 14:38:31 +08:00
2026-01-20 16:55:17 +08:00
2026-01-20 16:55:17 +08:00
2026-01-20 16:55:17 +08:00