Re: Unblock MIDI IN in blocking read mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Florian wrote:
> for best performance, I use a blocking snd_rawmidi_read() on an ALSA
> MIDI input device, byte by byte. It works fine, except:
>
> 1) How do I close the device from a different thread?

You don't.  The ALSA library isn't thread-safe; you cannot close the
device as long as the read() is still executing.

> I.e. how can I unblock the blocking read() call when it's time to
> close the device and no MIDI data is currently coming in?

You cannot.  The blocking read() unblocks when there is data to read,
or when an error occurs.  The raw MIDI functions do not implement an
API for non-MIDI messages.

> Maybe I can resort to non-blocking mode and avoid the situation above.

Yes; use another file descriptor (a pipe or something like that) that
can be used to let poll() return.


HTH
Clemens
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux