diff options
author | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2021-10-07 16:12:10 +0200 |
---|---|---|
committer | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2021-10-07 16:12:10 +0200 |
commit | 314596035337348abbc934d96e4d83d4398f64f1 (patch) | |
tree | ff0889c026133834a13c57a73307ecc03491cba5 /gdigi.c | |
parent | d4700c96fd551eea539921572c03842ecdc6c8c3 (diff) |
Import Upstream version 0.3.0
Diffstat (limited to 'gdigi.c')
-rw-r--r-- | gdigi.c | 41 |
1 files changed, 25 insertions, 16 deletions
@@ -25,7 +25,7 @@ static unsigned char device_id = 0x7F; static unsigned char family_id = 0x7F; -static unsigned char product_id = 0x7F; +unsigned char product_id = 0x7F; static snd_rawmidi_t *output = NULL; static snd_rawmidi_t *input = NULL; @@ -122,13 +122,11 @@ GString *pack_data(gchar *data, gint len) gint i; gint new_len; unsigned char status; - gint offset; gint status_byte; new_len = len + (len/7); packed = g_string_sized_new(new_len); status = 0; - offset = -1; status_byte = 0; for (i=0; i<len; i++) { @@ -267,10 +265,12 @@ void push_message(GString *msg) GDK_THREADS_ENTER(); g_timeout_add(0, apply_current_preset_to_gui, NULL); GDK_THREADS_LEAVE(); - } else + } else { g_message("%d %d moved to %d %d", str[9], str[10], str[11], str[12]); + } + break; default: - g_message("Received unhandled device notification"); + g_message("Received unhandled device notification 0x%x", str[11]); } g_string_free(msg, TRUE); return; @@ -302,7 +302,7 @@ gpointer read_data_thread(gboolean *stop) /* SysEx messages can't contain bytes with 8th bit set. memset our buffer to 0xFF, so if for some reason we'll get out of reply bounds, we'll catch it */ - memset(buf, sizeof(buf), 0xFF); + memset(buf, '\0', sizeof(buf)); err = poll(pfds, npfds, 200); if (err < 0 && errno == EINTR) @@ -1058,6 +1058,8 @@ static gboolean request_who_am_i(unsigned char *device_id, unsigned char *family *device_id = data->str[8]; *family_id = data->str[9]; *product_id = data->str[10]; + g_message("I am device id %d family %d product id %d.", + *device_id, *family_id, *product_id); g_string_free(data, TRUE); return TRUE; } @@ -1122,18 +1124,14 @@ static gint get_digitech_devices(GList **devices) { gint card_num = -1; gint number = 0; - snd_card_next(&card_num); - while (card_num > -1) { + while (!snd_card_next(&card_num) && (card_num > -1)) { char* name; snd_card_get_longname(card_num, &name); - gint count = strspn(name,"DigiTech"); - if (count > 0) - { + if (strspn(name,"DigiTech") > 0) { number++; *devices = g_list_append(*devices, GINT_TO_POINTER(card_num)); } - snd_card_next(&card_num); } return number; @@ -1161,13 +1159,24 @@ int main(int argc, char *argv[]) { if (device_port == NULL) { /* port not given explicitly in commandline - search for devices */ - GList *devices = NULL; - if (get_digitech_devices(&devices) <= 0) { - g_message("Couldn't find DigiTech devices!"); + GList *devices = NULL; + GList *device = NULL; + int num_devices = 0; + int chosen_device = 0; + if ((num_devices = get_digitech_devices(&devices)) <= 0) { + g_message("Couldn't find any DigiTech devices!"); exit(EXIT_FAILURE); } + if (num_devices > 1) { + chosen_device = select_device_dialog(devices); + if (chosen_device < 0) { + show_error_message(NULL, "No device chosen"); + exit(EXIT_FAILURE); + } + } + device = g_list_nth(devices, chosen_device); device_port = g_strdup_printf("hw:%d,0,0", - GPOINTER_TO_INT(devices->data)); + GPOINTER_TO_INT(device->data)); g_list_free(devices); g_message("Found device %s", device_port); } else { |