[alsa-devel] [PATCH v2 7/9] ALSA: line6: Allow processing of raw incoming messages
Takashi Iwai
tiwai at suse.de
Wed Aug 24 17:05:46 CEST 2016
On Fri, 19 Aug 2016 00:20:37 +0200,
Andrej Krutak wrote:
>
> Not all PODs use MIDI via USB data interface, thus allow avoiding
> that code and instead using direct processing.
>
> Signed-off-by: Andrej Krutak <dev at andree.sk>
> ---
> sound/usb/line6/driver.c | 59 ++++++++++++++++++++++++++++--------------------
> sound/usb/line6/driver.h | 8 ++++---
> sound/usb/line6/midi.c | 2 +-
> 3 files changed, 40 insertions(+), 29 deletions(-)
>
> diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c
> index 9b16777..853a143 100644
> --- a/sound/usb/line6/driver.c
> +++ b/sound/usb/line6/driver.c
> @@ -290,26 +290,31 @@ static void line6_data_received(struct urb *urb)
> if (urb->status == -ESHUTDOWN)
> return;
>
> - done =
> - line6_midibuf_write(mb, urb->transfer_buffer, urb->actual_length);
> + if (line6->properties->capabilities & LINE6_CAP_CONTROL_MIDI) {
> + done =
> + line6_midibuf_write(mb, urb->transfer_buffer, urb->actual_length);
>
> - if (done < urb->actual_length) {
> - line6_midibuf_ignore(mb, done);
> - dev_dbg(line6->ifcdev, "%d %d buffer overflow - message skipped\n",
> - done, urb->actual_length);
> - }
> + if (done < urb->actual_length) {
> + line6_midibuf_ignore(mb, done);
> + dev_dbg(line6->ifcdev, "%d %d buffer overflow - message skipped\n",
> + done, urb->actual_length);
> + }
>
> - for (;;) {
> - done =
> - line6_midibuf_read(mb, line6->buffer_message,
> - LINE6_MESSAGE_MAXLEN);
> + for (;;) {
> + done =
> + line6_midibuf_read(mb, line6->buffer_message,
> + LINE6_MESSAGE_MAXLEN);
>
> - if (done == 0)
> - break;
> + if (done == 0)
> + break;
>
> - line6->message_length = done;
> - line6_midi_receive(line6, line6->buffer_message, done);
> + line6->message_length = done;
> + line6_midi_receive(line6, line6->buffer_message, done);
>
> + if (line6->process_message)
> + line6->process_message(line6);
> + }
> + } else {
> if (line6->process_message)
> line6->process_message(line6);
> }
Both if and else run the same code (line6->process_message) here at
the end. That is, this can be outside the if block.
Also, the patch should be also before the actual usage, i.e. patch 5.
Takashi
More information about the Alsa-devel
mailing list