mirror of https://github.com/nealey/hdjd.git
fix some segfaults
This commit is contained in:
parent
46e3d5ce71
commit
a843d39b79
23
hdjd.c
23
hdjd.c
|
@ -74,24 +74,30 @@ usb_xfer_done(struct libusb_transfer *transfer)
|
||||||
void
|
void
|
||||||
handle_alsa()
|
handle_alsa()
|
||||||
{
|
{
|
||||||
snd_midi_event_t *midi_event_parser;
|
static snd_midi_event_t *midi_event_parser = NULL;
|
||||||
snd_seq_event_t *ev;
|
snd_seq_event_t *ev;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
|
|
||||||
for (ret = 1; ret > 0; ) {
|
DUMP();
|
||||||
char buf[512];
|
for (;;) {
|
||||||
|
char buf[256];
|
||||||
long converted;
|
long converted;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ret = snd_seq_event_input(handle, &ev);
|
if (snd_seq_event_input(handle, &ev) < 0) {
|
||||||
snd_midi_event_new(512, &midi_event_parser);
|
break;
|
||||||
converted = snd_midi_event_decode(midi_event_parser, buf, 512, ev);
|
}
|
||||||
|
if (! midi_event_parser) {
|
||||||
|
if (snd_midi_event_new(256, &midi_event_parser) < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
converted = snd_midi_event_decode(midi_event_parser, buf, 256, ev);
|
||||||
printf(" << ");
|
printf(" << ");
|
||||||
for (i = 0; i < converted; i += 1) {
|
for (i = 0; i < converted; i += 1) {
|
||||||
printf("%02x ", buf[i]);
|
printf("%02x ", buf[i]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf(":\n");
|
||||||
snd_midi_event_free(midi_event_parser);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,6 +230,7 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = select(nfds + 1, &rfds, &wfds, NULL, timeout);
|
ret = select(nfds + 1, &rfds, &wfds, NULL, timeout);
|
||||||
|
DUMP_d(rfds);
|
||||||
|
|
||||||
for (i = 0; usb_fds[i]; i += 1) {
|
for (i = 0; usb_fds[i]; i += 1) {
|
||||||
int fd = usb_fds[i]->fd;
|
int fd = usb_fds[i]->fd;
|
||||||
|
|
Loading…
Reference in New Issue