From d38944becdac0deec9cd4344efbc6b531db4161d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 22 Jan 2007 14:14:11 +0000 Subject: [PATCH] correctly detect missing ALSA MIDI system git-svn-id: svn://localhost/ardour2/trunk@1369 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/midi++2/alsa_sequencer_midiport.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libs/midi++2/alsa_sequencer_midiport.cc b/libs/midi++2/alsa_sequencer_midiport.cc index 26cdb7d1fd..a47678bf1b 100644 --- a/libs/midi++2/alsa_sequencer_midiport.cc +++ b/libs/midi++2/alsa_sequencer_midiport.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -39,6 +40,7 @@ using namespace std; using namespace MIDI; +using namespace PBD; snd_seq_t* ALSA_SequencerMidiPort::seq = 0; @@ -186,12 +188,20 @@ ALSA_SequencerMidiPort::CreatePorts (PortRequest &req) int ALSA_SequencerMidiPort::init_client (std::string name) { - int err; + static bool called = false; - if (0 <= (err = snd_seq_open (&seq, "default", SND_SEQ_OPEN_DUPLEX, 0))) { + if (called) { + return -1; + } + + called = true; + + if (snd_seq_open (&seq, "default", SND_SEQ_OPEN_DUPLEX, 0) >= 0) { snd_seq_set_client_name (seq, name.c_str()); return 0; } else { - return -err; + warning << "The ALSA MIDI system is not available. No ports based on it will be created" + << endmsg; + return -1; } }