mirror of https://github.com/ericonr/sndio.git
Support rsnd/default for opening the default device
This commit is contained in:
parent
6b35921d2b
commit
31cfb9b6dc
|
@ -63,11 +63,11 @@ sio_open(const char *str, unsigned int mode, int nbio)
|
|||
if (hdl != NULL)
|
||||
return hdl;
|
||||
#if defined(USE_SUN)
|
||||
return _sio_sun_open("rsnd/0", mode, nbio);
|
||||
return _sio_sun_open("rsnd/default", mode, nbio);
|
||||
#elif defined(USE_OSS)
|
||||
return _sio_oss_open("rsnd/0", mode, nbio);
|
||||
return _sio_oss_open("rsnd/default", mode, nbio);
|
||||
#elif defined(USE_ALSA)
|
||||
return _sio_alsa_open("rsnd/0", mode, nbio);
|
||||
return _sio_alsa_open("rsnd/default", mode, nbio);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
|
|
|
@ -304,6 +304,8 @@ _sio_alsa_open(const char *str, unsigned mode, int nbio)
|
|||
if (err < 0)
|
||||
DALSA("couldn't attach to stderr", err);
|
||||
#endif
|
||||
if (strcmp(p, "default") == 0)
|
||||
p = "0";
|
||||
len = strlen(p);
|
||||
hdl->devname = malloc(len + sizeof(DEVNAME_PREFIX));
|
||||
if (hdl->devname == NULL)
|
||||
|
|
|
@ -249,12 +249,16 @@ sio_oss_getfd(const char *str, unsigned int mode, int nbio)
|
|||
DPRINTF("sio_oss_getfd: %s: '/' expected\n", str);
|
||||
return -1;
|
||||
}
|
||||
p = _sndio_parsenum(p, &devnum, 255);
|
||||
if (p == NULL || *p != '\0') {
|
||||
DPRINTF("sio_oss_getfd: %s: number expected after '/'\n", str);
|
||||
return -1;
|
||||
if (strcmp(p, "default") == 0) {
|
||||
strlcpy(path, DEVPATH_PREFIX, sizeof(path));
|
||||
} else {
|
||||
p = _sndio_parsenum(p, &devnum, 255);
|
||||
if (p == NULL || *p != '\0') {
|
||||
DPRINTF("sio_sun_getfd: %s: number expected after '/'\n", str);
|
||||
return -1;
|
||||
}
|
||||
snprintf(path, sizeof(path), DEVPATH_PREFIX "%u", devnum);
|
||||
}
|
||||
snprintf(path, sizeof(path), DEVPATH_PREFIX "%u", devnum);
|
||||
if (mode == (SIO_PLAY | SIO_REC))
|
||||
flags = O_RDWR;
|
||||
else
|
||||
|
|
|
@ -291,10 +291,14 @@ sio_sun_getfd(const char *str, unsigned int mode, int nbio)
|
|||
DPRINTF("sio_sun_getfd: %s: '/' expected\n", str);
|
||||
return -1;
|
||||
}
|
||||
p = _sndio_parsenum(p, &devnum, 255);
|
||||
if (p == NULL || *p != '\0') {
|
||||
DPRINTF("sio_sun_getfd: %s: number expected after '/'\n", str);
|
||||
return -1;
|
||||
if (strcmp(p, "default") == 0) {
|
||||
devnum = 0;
|
||||
} else {
|
||||
p = _sndio_parsenum(p, &devnum, 255);
|
||||
if (p == NULL || *p != '\0') {
|
||||
DPRINTF("sio_sun_getfd: %s: number expected after '/'\n", str);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
snprintf(path, sizeof(path), DEVPATH_PREFIX "%u", devnum);
|
||||
if (mode == (SIO_PLAY | SIO_REC))
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
* default device in server mode
|
||||
*/
|
||||
#ifndef DEFAULT_DEV
|
||||
#define DEFAULT_DEV "rsnd/0"
|
||||
#define DEFAULT_DEV "rsnd/default"
|
||||
#endif
|
||||
|
||||
void sigint(int);
|
||||
|
|
Loading…
Reference in New Issue