controller: UI-toggle audio output + astreamselect decouple (Phase 7 Вариант 2)

Web UI checkbox в Audio source карточке: «вывод аудио в стрим». Off →
TV получает silence + downstream audio chain isolated от live-audio RTSP
(нестабильный sidecar поток больше не блокирует video pipeline).

Изменения:
  state.InstanceState: + audio_output_enabled (default True)
  config.InstanceCfg:
    + audio_output_volume_target (default volume@output_audio)
    + audio_input_select_target (default astreamselect@audio_input)
  dispatch.set_audio_output_enabled(enabled):
    enabled=False → astreamselect map=1 (anullsrc) + volume=0
    enabled=True  → astreamselect map=0 (live-audio) + volume=1
    Двойная команда: select decouples upstream, volume гарантирует тишину
    на случай если в anullsrc что-то не так.
  http_api: + GET /audio-output/{instance}, POST /audio-output/{instance}
  static/index.html: + checkbox в Audio source header + loadAudioOut/toggleAudioOut

ZMQ smoke test OK. HTTP roundtrip OK.

Сопутствующий pipeline change: docker-compose.phase7.yml — amix заменён
на astreamselect@audio_input (см. localhost-infra commit).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gx
2026-05-21 20:44:50 +01:00
parent e2764160b6
commit 48eb62bddc
5 changed files with 91 additions and 1 deletions
@@ -218,6 +218,39 @@ class CommandDispatcher:
использует cell 0 как main slot. Семантика идентична: cell_map 0 = cam_index."""
await self.set_main_cam(instance, cam_index)
async def set_audio_output_enabled(self, instance: str, enabled: bool) -> bool:
"""Phase 7 Вариант 2: mute = astreamselect map=1 (anullsrc) + volume=0.
unmute = astreamselect map=0 (live-audio) + volume=1. astreamselect
decouples downstream от jittery live-audio RTSP — при mute frames
идут только через anullsrc chain, video не зависит от audio sidecar."""
inst = self._find_instance(instance)
if inst is None:
return False
client = self._client(inst)
input_map = "0" if enabled else "1"
volume = "1.0" if enabled else "0.0"
try:
reply1 = await client.send_command(
inst.audio_input_select_target, "map", input_map
)
reply2 = await client.send_command(
inst.audio_output_volume_target, "volume", volume
)
log.info("dispatch.audio_output_set",
instance=instance, enabled=enabled,
input_map=input_map, volume=volume,
select_reply=reply1, volume_reply=reply2)
except (TimeoutError, Exception) as e:
log.warning("dispatch.audio_output_fail",
instance=instance, error=str(e))
return False
await self.state.set_audio_output_enabled(instance, enabled)
if self.on_state_change:
await self.on_state_change(instance, "audio_output", "on" if enabled else "off")
if self.on_event:
await self.on_event(instance, "audio_output_changed", {"enabled": enabled})
return True
async def _reload_icon(self, instance: str, icon_name: str) -> None:
"""Invalidate cached icon atlas во всех cuda_grid instances — каждый
имеет свой кеш."""