mirror of
https://github.com/db9979/uconsole_asw_game.git
synced 2026-12-05 20:34:16 +01:00
Browsers went silent after any host key press: every input-owner change bumped the world epoch, the server cleared the audio ring and restarted numbering at 1, and the AudioWorklet dropped every "old" block until the count passed its last sequence. Numbering is now monotonic per role for the server lifetime; a cleared ring and a retuned receiver skip one number so browsers crossfade, reconnects resume with ?after=<sequence>, duplicates are counted, and the audio socket tolerates a six-second send stall. Buffers sized for the 16 GB device: local lead 1.5 s with a 5 s queue, browser lead 2 s with a 6 s maximum, refill 1 s, stale 3 s, SIM_CATCHUP_MAX_S 2.5 s (queue >= lead + catch-up + block, pinned by a test), SDL mixer buffer 2048 samples. Remote Crew publication no longer spikes the main thread: sonar history rows are cached per station with identical results, role states are shallow copies, the compact sonar state is built from the dict, the roster is read at 4 Hz. New counters (mixer channel idle, late pump iterations, input gaps, per-phase frame times, server stream stats) and tools/audio_soak.py, which runs the game headless with simulated browsers or as a Wi-Fi client and reports stream continuity. Docs, manual and install guide updated. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
"""The audio soak tool runs headless, isolates user data and reports continuity."""
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
@pytest.mark.timeout(240)
|
|
def test_audio_soak_tool_runs_headless_and_reports_ok(tmp_path):
|
|
fake_home = tmp_path / "home"
|
|
fake_home.mkdir()
|
|
(fake_home / ".u-jagd").mkdir()
|
|
marker = fake_home / ".u-jagd" / "settings.json"
|
|
marker.write_text("{}", encoding="utf-8")
|
|
env = dict(os.environ, HOME=str(fake_home), SDL_VIDEODRIVER="dummy",
|
|
SDL_AUDIODRIVER="dummy")
|
|
env.pop("U_JAGD_AUDIO_DEBUG", None)
|
|
env.pop("U_JAGD_PERF_DEBUG", None)
|
|
result = subprocess.run(
|
|
[sys.executable, str(ROOT / "tools" / "audio_soak.py"), "host",
|
|
"--dummy-audio", "--duration", "8", "--clients", "3",
|
|
"--bump-every", "3", "--retune-every", "4"],
|
|
cwd=ROOT, env=env, capture_output=True, text=True, timeout=200)
|
|
assert result.returncode == 0, result.stdout + result.stderr
|
|
out = result.stdout
|
|
assert "RESULT: OK" in out
|
|
assert "stream sonar:" in out and "stream uboot_sonar:" in out
|
|
assert "backwards 0" in out and "silences_over_2.0s 0" in out
|
|
assert "local mixer: underruns 0" in out
|
|
assert "epoch steps" in out
|
|
# The tool never writes into the caller's ~/.u-jagd.
|
|
assert sorted(path.name for path in (fake_home / ".u-jagd").iterdir()) == ["settings.json"]
|
|
assert marker.read_text(encoding="utf-8") == "{}"
|