Skip to content

Commit

Permalink
Do not try to read seq if seq has failed
Browse files Browse the repository at this point in the history
- test connect ALSA seq connection before trying to read it.
- fix a crash when closing a non opened seq connection
- fix a crash when displaying a warning....
  • Loading branch information
mans17 committed Apr 8, 2020
1 parent 4971207 commit bfef1db
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/MidiComm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ void midiInit() {
return;

int err = snd_seq_open(&alsa_seq, "default", SND_SEQ_OPEN_DUPLEX, 0);
int ownid = snd_seq_client_id(alsa_seq);
midi_initiated = true;

// Could not open sequencer, no out devices
if (err < 0) {
alsa_seq = NULL;
Compatible::ShowError("Could not open MIDI sequencer. No MIDI available");
//Compatible::ShowError("Could not open MIDI sequencer. No MIDI available"); // FIXME ?
fprintf (stdout, "WARNING :: could not open MIDI sequencer. No MIDI available\n");
return;
}

int ownid = snd_seq_client_id(alsa_seq);

snd_seq_set_client_name(alsa_seq, "Linthesia");

// meanings of READ and WRITE are permissions of the port from the viewpoint of other ports
Expand Down Expand Up @@ -91,6 +93,8 @@ void midiInit() {

void midiStop() {

if (alsa_seq == NULL)
return;
snd_seq_close(alsa_seq);
}

Expand Down

0 comments on commit bfef1db

Please sign in to comment.