diff --git a/src/device.c b/src/device.c index 6edbb78..99af305 100644 --- a/src/device.c +++ b/src/device.c @@ -121,7 +121,7 @@ static gint query_program(const gint pgm_num) #define DEV_NAME_MAX_LEN 64 -void device_init(void) +int device_init(void) { guint dev_count; #ifdef HAVE_RTMIDI4 @@ -153,7 +153,7 @@ void device_init(void) if (!found) { g_critical("No MPKmini MK3 device found"); rtmidi_in_free(midi_in); - return; + return -1; } g_debug("Using device %d: %s", i, dev_name); midi_out = rtmidi_out_create_default(); @@ -167,6 +167,8 @@ void device_init(void) dev.in = midi_in; dev.out = midi_out; + + return 0; } diff --git a/src/device.h b/src/device.h index 8892d4e..dfb9195 100644 --- a/src/device.h +++ b/src/device.h @@ -1,7 +1,7 @@ #ifndef _DEVICE_H #define _DEVICE_H -void device_init(void); +int device_init(void); void device_close(void); gint device_read_pgm(gint pgm_num); gint device_write_pgm(gint pgm_num); diff --git a/src/main.c b/src/main.c index 1a951b8..b780e0f 100644 --- a/src/main.c +++ b/src/main.c @@ -26,7 +26,10 @@ int main(int argc, char ** argv) GtkWidget *app_win; gtk_init(&argc, &argv); - device_init(); + if (device_init() < 0) { + show_error(); + return -1; + } if (device_read_pgm(PGM_NUM_RAM) < 0) { show_error(); return -1;