mirror of https://github.com/nealey/hdjd.git
It works!
This commit is contained in:
parent
bc38826f46
commit
22f6bc30de
10
alsa.c
10
alsa.c
|
@ -126,14 +126,4 @@ alsa_write(uint8_t *data, size_t datalen)
|
|||
}
|
||||
|
||||
snd_seq_drain_output(snd_handle);
|
||||
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("A> ");
|
||||
for (i = 0; i < datalen; i += 1) {
|
||||
printf("%02x ", data[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
23
usb.c
23
usb.c
|
@ -9,7 +9,7 @@
|
|||
#include "dump.h"
|
||||
|
||||
static struct libusb_device_handle *usb_dev;
|
||||
static struct libusb_transfer *xfer;
|
||||
static struct libusb_transfer *xfer = NULL;
|
||||
static const struct device *d;
|
||||
uint8_t data[80];
|
||||
|
||||
|
@ -31,6 +31,9 @@ static void
|
|||
usb_initiate_transfer()
|
||||
{
|
||||
// Tell libusb we want to know about bulk transfers
|
||||
if (xfer) {
|
||||
libusb_free_transfer(xfer);
|
||||
}
|
||||
xfer = libusb_alloc_transfer(0);
|
||||
libusb_fill_bulk_transfer(xfer, usb_dev, d->ep_in, data, sizeof(data), usb_xfer_done, NULL, 0);
|
||||
libusb_submit_transfer(xfer);
|
||||
|
@ -43,7 +46,6 @@ usb_xfer_done(struct libusb_transfer *transfer)
|
|||
int datalen = transfer->actual_length;
|
||||
|
||||
alsa_write(data, datalen);
|
||||
|
||||
usb_initiate_transfer();
|
||||
}
|
||||
|
||||
|
@ -133,14 +135,19 @@ usb_check_fds(fd_set *rfds, fd_set *wfds)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
usb_write_done(struct libusb_transfer *transfer)
|
||||
{
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
void
|
||||
usb_write(uint8_t *data, size_t datalen)
|
||||
{
|
||||
int i;
|
||||
struct libusb_transfer *xfer;
|
||||
|
||||
printf("U> ");
|
||||
for (i = 0; i < datalen; i += 1) {
|
||||
printf("%02x ", data[i]);
|
||||
}
|
||||
printf("\n");
|
||||
xfer = libusb_alloc_transfer(0);
|
||||
libusb_fill_bulk_transfer(xfer, usb_dev, d->ep_out, data, datalen, usb_write_done, NULL, 0);
|
||||
libusb_submit_transfer(xfer);
|
||||
}
|
Loading…
Reference in New Issue