|
NAMEmio_open , mio_close ,
mio_read , mio_write ,
mio_nfds , mio_pollfd ,
mio_revents , mio_eof —
sndio interface to MIDI streams
SYNOPSIS#include <sndio.h>
struct mio_hdl *
void
size_t
size_t
int
int
int
int
DESCRIPTIONThesndio library allows user processes to access
midi(4)
hardware and
sndiod(8)
MIDI thru boxes and control ports in a uniform way.
Opening and closing a MIDI streamFirst the application must call themio_open () function
to obtain a handle representing the newly created stream; later it will be
passed as the hdl argument of most other functions. The
name parameter gives the device string discussed in
sndio(7).
If the program is using a single device and is providing no device chooser, it
should be set to MIO_PORTANY to allow the user to select it using the
MIDIDEVICE environment variable.
The mode parameter gives the direction of the stream. The following are supported:
If the nbio_flag argument is true (i.e.
non-zero), then the The Sending and receiving dataWhen input mode is selected, themio_read () function
must be called to retrieve received data; it must be called often enough to
ensure that internal buffers will not overrun. It will store at most
nbytes bytes at the addr location.
Unless the nbio_flag flag is set, it will block until
data becomes available and will return zero only on error.
When output mode is selected, the
Non-blocking mode operationIf the nbio_flag is set onmio_open (), then the
mio_read () and mio_write ()
functions will never block; if no data is available, they will return zero
immediately.
To avoid busy loops when non-blocking mode is used, the
poll(2)
system call can be used to check if data can be read from or written to the
stream. The poll(2)
will sleep until any of the events requested with
Error handlingErrors related to the MIDI subsystem (like hardware errors or dropped connections) and programming errors (such as a call tomio_read () on a play-only stream) are considered
fatal. Once an error occurs, all functions which take a
mio_hdl argument, except
mio_close () and mio_eof (),
stop working (i.e. always return 0).
RETURN VALUESThemio_open () function returns the newly created handle
on success or NULL on failure.
The The The The ENVIRONMENT
SEE ALSOpoll(2), midi(4), sndio(7), sndiod(8)HISTORYThese functions first appeared in OpenBSD 4.7.AUTHORSAlexandre Ratchov <ratchov@openbsd.org>
Visit the GSP FreeBSD Man Page Interface. |