mirror of https://github.com/nealey/hdjd.git
Seems to work with MP3e2 again
This commit is contained in:
parent
879aa06038
commit
f5a8148993
36
alsa.c
36
alsa.c
|
@ -73,9 +73,10 @@ alsa_fd_setup(int *nfds, fd_set *rfds, fd_set *wfds)
|
||||||
void
|
void
|
||||||
alsa_read_ready()
|
alsa_read_ready()
|
||||||
{
|
{
|
||||||
static snd_seq_event_t *ev;
|
snd_midi_event_init(midi_event_parser);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
snd_seq_event_t *ev;
|
||||||
unsigned char buf[ALSA_BUFSIZE];
|
unsigned char buf[ALSA_BUFSIZE];
|
||||||
long converted;
|
long converted;
|
||||||
int r;
|
int r;
|
||||||
|
@ -83,19 +84,34 @@ alsa_read_ready()
|
||||||
r = snd_seq_event_input(snd_handle, &ev);
|
r = snd_seq_event_input(snd_handle, &ev);
|
||||||
|
|
||||||
if (r == -EAGAIN) {
|
if (r == -EAGAIN) {
|
||||||
|
// input queue empty
|
||||||
break;
|
break;
|
||||||
}
|
} else if (r == -ENOSPC) {
|
||||||
if (r == -ENOSPC) {
|
warn("Input queue overflow");
|
||||||
warn("Out of space on input queue");
|
continue;
|
||||||
|
} else if (r < 0) {
|
||||||
|
warn("snd_seq_event_input() = %d", r);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
converted = snd_midi_event_decode(midi_event_parser, buf, ALSA_BUFSIZE, ev);
|
converted = snd_midi_event_decode(midi_event_parser, buf, ALSA_BUFSIZE, ev);
|
||||||
if (converted < 0) {
|
if (converted < 0) {
|
||||||
warn("Can't decode MIDI event type %d", ev->type);
|
warn("Can't decode MIDI event type %x", ev->type);
|
||||||
} else {
|
continue;
|
||||||
DUMP_d(converted);
|
|
||||||
usb_write(buf, converted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (converted < 3) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
warn("Uh oh, weird MIDI packet with length %ld (does this make sense if prefixed with 90?)", converted);
|
||||||
|
|
||||||
|
for (i = 0; i < converted; i += 1) {
|
||||||
|
fprintf(stderr, " %02x", buf[i]);
|
||||||
|
}
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
usb_write(buf, converted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +135,8 @@ alsa_write(uint8_t *data, size_t datalen)
|
||||||
{
|
{
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
|
|
||||||
|
snd_midi_event_init(midi_event_parser);
|
||||||
|
|
||||||
for (; datalen > offset;) {
|
for (; datalen > offset;) {
|
||||||
snd_seq_event_t ev;
|
snd_seq_event_t ev;
|
||||||
long encoded;
|
long encoded;
|
||||||
|
|
2
dump.h
2
dump.h
|
@ -9,7 +9,7 @@
|
||||||
#ifdef NODUMP
|
#ifdef NODUMP
|
||||||
# define DUMPf(fmt, args...)
|
# define DUMPf(fmt, args...)
|
||||||
#else
|
#else
|
||||||
# define DUMPf(fmt, args...) fprintf(stderr, "%s:%s:%d " fmt "\n", __FILE__, __FUNCTION__, __LINE__, ##args)
|
# define DUMPf(fmt, args...) fprintf(stderr, "%s:%d " fmt "\n", __FILE__, __LINE__, ##args)
|
||||||
#endif
|
#endif
|
||||||
#define DUMP() DUMPf("")
|
#define DUMP() DUMPf("")
|
||||||
#define DUMP_d(v) DUMPf("%s = %d", #v, (int)v)
|
#define DUMP_d(v) DUMPf("%s = %d", #v, (int)v)
|
||||||
|
|
13
usb.c
13
usb.c
|
@ -156,7 +156,9 @@ usb_check_fds(fd_set *rfds, fd_set *wfds)
|
||||||
void
|
void
|
||||||
usb_write_done(struct libusb_transfer *xfer)
|
usb_write_done(struct libusb_transfer *xfer)
|
||||||
{
|
{
|
||||||
DUMP_d(xfer->status);
|
if (xfer->status) {
|
||||||
|
warn("USB Write status %d", xfer->status);
|
||||||
|
}
|
||||||
writes_pending -= 1;
|
writes_pending -= 1;
|
||||||
free(xfer->buffer);
|
free(xfer->buffer);
|
||||||
libusb_free_transfer(xfer);
|
libusb_free_transfer(xfer);
|
||||||
|
@ -167,14 +169,7 @@ usb_write(uint8_t *data, size_t datalen)
|
||||||
{
|
{
|
||||||
struct libusb_transfer *xfer;
|
struct libusb_transfer *xfer;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
int i;
|
|
||||||
|
|
||||||
DUMP_d(datalen);
|
|
||||||
for (i = 0; i < datalen; i += 1) {
|
|
||||||
fprintf(stderr, " %02x", data[i]);
|
|
||||||
}
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
|
|
||||||
writes_pending += 1;
|
writes_pending += 1;
|
||||||
xfer = libusb_alloc_transfer(0);
|
xfer = libusb_alloc_transfer(0);
|
||||||
buf = (unsigned char *)malloc(datalen);
|
buf = (unsigned char *)malloc(datalen);
|
||||||
|
|
Loading…
Reference in New Issue