struct sio_hdl * sio_open(const char *str, unsigned int mode, int nbio) { static char devany[] = SIO_DEVANY; struct sio_hdl *hdl; const char *p; #ifdef DEBUG _sndio_debug_init(); #endif if ((mode & (SIO_PLAY | SIO_REC)) == 0) return NULL; if (str == NULL) /* backward compat */ str = devany; if (strcmp(str, devany) == 0 && !issetugid()) { str = getenv("AUDIODEVICE"); if (str == NULL) str = devany; } if (strcmp(str, devany) == 0) { hdl = _sio_aucat_open("/0", mode, nbio); if (hdl != NULL) return hdl; return _sio_sun_open("/0", mode, nbio); } if ((p = _sndio_parsetype(str, "snd")) != NULL || (p = _sndio_parsetype(str, "aucat")) != NULL) return _sio_aucat_open(p, mode, nbio); if ((p = _sndio_parsetype(str, "rsnd")) != NULL || (p = _sndio_parsetype(str, "sun")) != NULL) { return _sio_sun_open(p, mode, nbio); } DPRINTF("sio_open: %s: unknown device type\n", str); return NULL; }
struct mio_hdl * mio_open(const char *str, unsigned int mode, int nbio) { static char portany[] = MIO_PORTANY; struct mio_hdl *hdl; #ifdef DEBUG _sndio_debug_init(); #endif if ((mode & (MIO_OUT | MIO_IN)) == 0) return NULL; if (str == NULL) /* backward compat */ str = portany; if (strcmp(str, portany) == 0 && !issetugid()) { str = getenv("MIDIDEVICE"); if (str == NULL) str = portany; } if (strcmp(str, portany) == 0) { hdl = _mio_aucat_open("midithru/0", mode, nbio); if (hdl != NULL) return hdl; return _mio_rmidi_open("rmidi/0", mode, nbio); } if (_sndio_parsetype(str, "snd") || _sndio_parsetype(str, "midithru") || _sndio_parsetype(str, "midi")) return _mio_aucat_open(str, mode, nbio); if (_sndio_parsetype(str, "rmidi")) return _mio_rmidi_open(str, mode, nbio); DPRINTF("mio_open: %s: unknown device type\n", str); return NULL; }