[alsa-devel] [PATCH 1/1] ALSA: usb-audio: add support for Akai MPD16

Clemens Ladisch clemens at ladisch.de
Thu May 20 09:26:56 CEST 2010


Krzysztof Foltman wrote:
> +		int port = (buffer[pos] >> 4) - 1;
> +		if (... && (port == 0 || port == 1))

Not that it really matters, but if the port variable were unsigned, you
could just check for "port <= 1".

> +static void snd_usbmidi_akai_output(struct snd_usb_midi_out_endpoint *ep,
> +				    struct urb *urb)
> ...
> +	/* only try adding more data when there's space for at least 1 SysEx */
> +	while (urb->transfer_buffer_length + 16 < ep->max_transfer) {
> +		count = snd_rawmidi_transmit(ep->ports[0].substream, &tmp, 1);
> +		if (count < 1) {
> +			ep->ports[0].active = 0;
> +			return;
> +		}

It is possible that ALSA's buffer does not yet contain the entire SysEx
message; in this case, the driver would send off the partial message
without the 0x10 in the first byte.

I think the only solution for that is to use snd_rawmidi_transmit_peek,
and for a SysEx, waiting until the entire message is available before
copying it to the transfer_buffer and calling transmit_ack.

> +	/* Akai MPD16 */
> +	CONTROL_PORT(0x09e8, 0x0062, 0, "%s Control"),
> +	EXTERNAL_PORT(0x09e8, 0x0062, 1, "%s MIDI"),

This MIDI port isn't an external port (which would imply that any random
device could be connected to it).  There is no macro for internal ports;
just use PORT_INFO(... _MIDI_GENERIC | _HARDWARE).


Regards,
Clemens


More information about the Alsa-devel mailing list