You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When configuring a machine in a Linux host with a running MIDI client (e.g. Fluidsynth), there's no "MIDI out device" dropdown under Sound Devices > Device Configuration, which can (and will) cause a segfault when playing any kind of MIDI from inside the emulated OS. See "Additional context" for the full enchilada, it's deeper than it looks.
To Reproduce
Install and run any MIDI client of your preference with any kind of soundfont (e.g. fluidsynth /path/to/gm.sf2)
Configure a machine with any kind of sound card, then proceed to seek any "MIDI out device" dropdown there without success
Start the emulated OS anyway, install drivers and etc., then try playing any .mid file, or playing a game that outputs MIDI (e.g. Gruntz, Time Commando, etc.)
He's dead, Jim
Expected behavior
Being able to see and set the MIDI out device in the config while Fluidsynth is running in the background.
Emulator configuration
Any should do as this seems to be a machine-agnostic bug, but here's mine for reference:
MOBO: Gigabyte GA-686BX
CPU: Intel Pentium II/450
GPU: 3DFX Voodoo 3 3000
Sound: Sound Blaster 16 or AWE32
OS: Windows 98SE
Host machine
OS: Debian 12 Bookworm w/ all necessary dependencies to compile the project
PCem vNext, cloned directly from this repo, compiled from source, dev branch, commit 2e87d35, with the command cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DUSE_ALSA=ON . && ninja
Additional context
This isn't a "new" issue but rather an extension of this specific post from user flk92, who kindly provided two very simple patches that solve the problem altogether - he was fixing something else but it turns out his patch (B) also fixes this. From what I could understand by reading the code, it goes more or less like this:
The pointer to the MIDI device in src/sound/midi_alsa.c (*current_output) is set to NULL by default
The dropdown seems to only appear when there's at least one MIDI client/sink available, but the current code can't find any for some reason
No MIDI clients/sinks found, no dropdown, pointer remains NULL and is never set
Emulated OS sends a MIDI out instruction, midi_write() is called, snd_rawmidi_write() is called with the NULL pointer passed to it
Aaaand there's your segfault (rawmidi.c: Assertion 'rawmidi' failed or something like that)
Since his patch properly exposes ALSA's MIDI interface, the dropdown appears again in the configs and you can properly set it, thus indirectly fixing the issue in a way. The patches themselves don't work as-is right now because they're pointing to the wrong file (src/midi_alsa.c when it should be src/sound/midi_alsa.c as per the current repo's structure), but I've manually applied both patches (as in literally copy-pasted the diff by hand), recompiled the project and it works fine for me now.
I believe this might also be the cause to #251, assuming the user who opened that issue doesn't know about any of this. I've decided to post this issue specifically because:
It's a quite important fix from 3 years ago that is not that easily searchable and solves a real problem I had a couple days ago (playing games specifically with the Windows General MIDI due to nostalgia)
I don't know if you accept PRs, and even if you did, it's not really my code but someone else's - I just wanted to bring attention to it again because the fix is already there, maybe it was just accidentally forgotten I guess
I don't use forums so this is the closest and more fitting contact I can get IMO without resorting to a lengthy email
The text was updated successfully, but these errors were encountered:
Describe the bug
When configuring a machine in a Linux host with a running MIDI client (e.g. Fluidsynth), there's no "MIDI out device" dropdown under Sound Devices > Device Configuration, which can (and will) cause a segfault when playing any kind of MIDI from inside the emulated OS. See "Additional context" for the full enchilada, it's deeper than it looks.
To Reproduce
fluidsynth /path/to/gm.sf2
)Expected behavior
Being able to see and set the MIDI out device in the config while Fluidsynth is running in the background.
Emulator configuration
Any should do as this seems to be a machine-agnostic bug, but here's mine for reference:
Host machine
dev
branch, commit 2e87d35, with the commandcmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DUSE_ALSA=ON . && ninja
Additional context
This isn't a "new" issue but rather an extension of this specific post from user flk92, who kindly provided two very simple patches that solve the problem altogether - he was fixing something else but it turns out his patch (B) also fixes this. From what I could understand by reading the code, it goes more or less like this:
src/sound/midi_alsa.c
(*current_output
) is set to NULL by defaultmidi_write()
is called,snd_rawmidi_write()
is called with the NULL pointer passed to itrawmidi.c: Assertion 'rawmidi' failed
or something like that)Since his patch properly exposes ALSA's MIDI interface, the dropdown appears again in the configs and you can properly set it, thus indirectly fixing the issue in a way. The patches themselves don't work as-is right now because they're pointing to the wrong file (
src/midi_alsa.c
when it should besrc/sound/midi_alsa.c
as per the current repo's structure), but I've manually applied both patches (as in literally copy-pasted the diff by hand), recompiled the project and it works fine for me now.I believe this might also be the cause to #251, assuming the user who opened that issue doesn't know about any of this. I've decided to post this issue specifically because:
The text was updated successfully, but these errors were encountered: