fix: don't log errors while reconnecting
This commit is contained in:
+22
-5
@@ -6,19 +6,36 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
void midi_open(MidiDevice *device, const char *name) {
|
||||
void snd_no_log(__attribute__((unused)) int prio,
|
||||
__attribute__((unused)) int interface,
|
||||
__attribute__((unused)) const char *file,
|
||||
__attribute__((unused)) int line,
|
||||
__attribute__((unused)) const char *function,
|
||||
__attribute__((unused)) int errcode,
|
||||
__attribute__((unused)) const char *fmt,
|
||||
__attribute__((unused)) va_list arg) {}
|
||||
|
||||
void midi_open(MidiDevice *device, const char *name, bool log_error) {
|
||||
strlcpy(device->name, name, STR_LEN);
|
||||
device->connected = false;
|
||||
device->input = NULL;
|
||||
device->output = NULL;
|
||||
|
||||
if (!log_error) {
|
||||
snd_lib_log_set_handler(snd_no_log);
|
||||
}
|
||||
|
||||
snd_rawmidi_open(&device->input, &device->output, name, SND_RAWMIDI_NONBLOCK);
|
||||
|
||||
device->connected = device->input != NULL && device->output != NULL;
|
||||
|
||||
if (device->connected) {
|
||||
log_info("(%s) MIDI open", name);
|
||||
if (log_error) {
|
||||
if (device->connected) {
|
||||
log_info("(%s) MIDI open", name);
|
||||
} else {
|
||||
log_warn("(%s) MIDI open failed", name);
|
||||
}
|
||||
} else {
|
||||
log_warn("(%s) MIDI open failed", name);
|
||||
snd_lib_log_set_handler(snd_lib_vlog);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user