[Bugfix] --audio-off and config.audio_enabled are dead code: audio plays under --headless #406

Open
opened 2026-07-27 15:38:05 +00:00 by john · 0 comments
Owner

Found while working #394 (seeding the engine's internal RNG streams).

McRogueFaceConfig::audio_enabled is written and never read:

$ grep -rn "audio_enabled" src/
src/CommandLineParser.cpp:84:            config.audio_enabled = false;   # --headless
src/CommandLineParser.cpp:96:            config.audio_enabled = false;   # --audio-off
src/CommandLineParser.cpp:102:           config.audio_enabled = true;    # --audio-on
src/McRogueFaceConfig.h:11:    bool audio_enabled = true;

Nothing in GameEngine, PySound, PySoundBuffer or PyMusic consults it. Consequences:

  • --audio-off is a no-op. Constructing a Sound still opens an OpenAL device and play()
    still plays.
  • --headless is a runtime flag and MCRF_HEADLESS is a build option — unrelated. The stock
    build/mcrogueface is a full SFML build, so --headless gets the real OpenAL-backed sf::Sound,
    not src/platform/HeadlessTypes.h's stubs. Verified: a Sound built from
    SoundBuffer.sfxr(...) under --headless --audio-off reports playing == True.

This is also the likely mechanism behind #400 (alc_cleanup: 1 device not closed aborts during
teardown in the default headless suite): a suite that believes it is running without audio is
opening and closing real devices.

Suggested fix: have PySound/PySoundBuffer/PyMusic honour audio_enabled — either refuse to
open a device (Fail Early, loud) or make playback a documented no-op. Deleting the flag is the other
honest option; silently accepting a flag that does nothing is the worst of the three.

Found while working #394 (seeding the engine's internal RNG streams). `McRogueFaceConfig::audio_enabled` is **written and never read**: ``` $ grep -rn "audio_enabled" src/ src/CommandLineParser.cpp:84: config.audio_enabled = false; # --headless src/CommandLineParser.cpp:96: config.audio_enabled = false; # --audio-off src/CommandLineParser.cpp:102: config.audio_enabled = true; # --audio-on src/McRogueFaceConfig.h:11: bool audio_enabled = true; ``` Nothing in `GameEngine`, `PySound`, `PySoundBuffer` or `PyMusic` consults it. Consequences: * **`--audio-off` is a no-op.** Constructing a `Sound` still opens an OpenAL device and `play()` still plays. * `--headless` is a *runtime* flag and `MCRF_HEADLESS` is a *build* option — unrelated. The stock `build/mcrogueface` is a full SFML build, so `--headless` gets the real OpenAL-backed `sf::Sound`, not `src/platform/HeadlessTypes.h`'s stubs. Verified: a `Sound` built from `SoundBuffer.sfxr(...)` under `--headless --audio-off` reports `playing == True`. This is also the likely mechanism behind #400 (`alc_cleanup: 1 device not closed` aborts during teardown in the default headless suite): a suite that believes it is running without audio is opening and closing real devices. Suggested fix: have `PySound`/`PySoundBuffer`/`PyMusic` honour `audio_enabled` — either refuse to open a device (Fail Early, loud) or make playback a documented no-op. Deleting the flag is the other honest option; silently accepting a flag that does nothing is the worst of the three.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
john/McRogueFace#406
No description provided.