From dc83c35b0de3d9d88ceae990e5fbe5fa397ade38 Mon Sep 17 00:00:00 2001 From: HeikkiSairanen Date: Fri, 6 Nov 2026 13:50:36 +0200 Subject: [PATCH] Run without music when no MIDI backend exists audio::Init called ABORT when RtMidiOut could not be created, for example when /dev/snd/seq is missing in a container or on a headless machine. IVAN therefore refused to start at all. Exiting from inside Init also skipped the destructor of the temporary music directory string, which Memcheck reported as a possibly lost block. Return from Init instead, leaving midiout null and the audio thread unstarted. GetMIDIOutputDevices and ChangeMIDIOutputDevice run during ivanconfig::Initialize, so make both handle a null midiout. No other midiout use is reachable, as they all run on the audio thread. Fixes #675 Co-Authored-By: Claude Opus 5.5 --- audio/audio.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/audio/audio.cpp b/audio/audio.cpp index 4e278a012..ef1994e28 100644 --- a/audio/audio.cpp +++ b/audio/audio.cpp @@ -103,7 +103,8 @@ void audio::Init(cfestring& musicDirectory) } catch (RtMidiError &error) { error.printMessage(); - ABORT("MIDI Out Error"); + // No MIDI backend (e.g. no /dev/snd/seq): run without music. + return; } @@ -181,6 +182,9 @@ cfestring& audio::GetCurrentlyPlayedFile() /* Port0 is NULL, and disabled. */ int audio::ChangeMIDIOutputDevice(int newPort) { + if( !midiout ) + return 0; + if( newPort != CurrentMIDIOutPort) { audio::SetPlaybackStatus(0x00); @@ -209,6 +213,9 @@ int audio::ChangeMIDIOutputDevice(int newPort) int audio::GetMIDIOutputDevices(std::vector& deviceNames) { + if( !midiout ) + return 0; + int nPorts = midiout->getPortCount(); std::string portName;