Skip to content

fix(menu): a chosen microphone is found again after a restart - #2572

Merged
hckrman101 merged 1 commit into
NotRexed:mainfrom
jarynclouatre:fix/mic-name-after-restart
Nov 11, 2026
Merged

hckrman101 merged 1 commit into
NotRexed:mainfrom
jarynclouatre:fix/mic-name-after-restart

Conversation

@jarynclouatre

Copy link
Copy Markdown
Contributor

A microphone chosen on the Audio tab's Microphone row is lost at the next start. The row saves the device's name as microphone_device=<name>. When the file is read back, mic_key turns every control character into a space, the line's own \n included, before the load strips line ends. So the name comes back as "USB Mic " and matches no device: the row shows "USB Mic (not connected)" and the host is told a name it cannot find, so the ocarina hears the default microphone. Each save then writes the name with one more space at the end.

mic_key now drops spaces at the end of a name. The saved line reads back as it was saved, and a file an older build wrote with the extra spaces reads back too. The load's own line-end strip had no effect after mic_key and is removed.

Testing (Linux, game-free)

  • tests/test_audio_in.py: a new case reads "USB Mic\n", "USB Mic\r\n" and "USB Mic \n" through mic_key, then refresh_mics, and expects the device found (mic_want == "USB Mic", not missing, the row on it, the host told index 0). It fails on main and passes with this change. The test also checks that the load reads the name through mic_key.
  • tests/test_menu_utf8.py: its line-break case now expects the name without the trailing space.
  • The other menu tests (test_menu_*.py, test_audio_output_menu.py, test_options_budget_once.py) pass.
  • Not run in the game.

The Microphone row saves the device's name as microphone_device=<name>. Reading it back, mic_key turned the
line's end into a space before the load stripped line ends, so the name came back as "USB Mic " and matched no
microphone: the row showed "USB Mic (not connected)" and the host listened to the default one. Each save then
wrote the name with one more space.

mic_key now drops spaces at the end of a name, so the saved line reads back as it was, files an older build saved
with the extra spaces read back too, and the load's own strip goes.

@ghost ghost left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, and the fix is in the right place. I traced it on main: mic_key turns the line's \n into a space before the old strip runs, so the strip never had anything to remove, and any saved name shorter than the 60-byte cut came back with a space on the end. It then matched no device, and each save added another space. Names of 60 bytes or more only worked because the cut happened to drop the line end.

Trimming inside mic_key fixes it for every caller at once. The load, refresh_mics' matching (both sides go through mic_key), mic_chosen and the unplugged name told to the host (still a prefix of the real name) all use the same key now. Files saved with the extra spaces load again too. Cutting first and trimming after is the right order, because the cut can leave a space at the end as well.

The new test_audio_in case covers \n, \r\n and the old padded form through refresh_mics, and the source check keeps the load on mic_key. Both touched tests pass on Linux and Windows CI. The two part 2/2 failures aren't from this PR: test_env_on (HOS_FPS_LOG in host/oot_high_fps.c, fixed by #2575) and test_psychov35 on Windows, which also fail on main.

Small side effect worth knowing: a device whose real name ends in a space is now matched without it. That's harmless, since both sides get trimmed the same way.

@hckrman101
hckrman101 merged commit ef81aee into NotRexed:main Nov 11, 2026
10 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant