a few more changes to oss code
git-svn-id: https://svn.musicpd.org/mpd/trunk@2395 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
@ -46,29 +46,58 @@
|
|||||||
#endif /* !(defined(__OpenBSD__) || defined(__NetBSD__) */
|
#endif /* !(defined(__OpenBSD__) || defined(__NetBSD__) */
|
||||||
|
|
||||||
static typedef struct _OssData {
|
static typedef struct _OssData {
|
||||||
int device;
|
int fd;
|
||||||
|
char * device;
|
||||||
} OssData;
|
} OssData;
|
||||||
|
|
||||||
static OssData * newOssData() {
|
static OssData * newOssData() {
|
||||||
OssData * ret = malloc(sizeof(OssData));
|
OssData * ret = malloc(sizeof(OssData));
|
||||||
|
|
||||||
ret->device = 0;
|
ret->device = NULL;
|
||||||
|
ret->fd = -1;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void freeOssData(OssData * od) {
|
static void freeOssData(OssData * od) {
|
||||||
|
if(od->device) free(od->device);
|
||||||
|
|
||||||
free(od);
|
free(od);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void oss_initDriver(AudioOutput * audioOutput, ConfigParam * param) {
|
static void oss_initDriver(AudioOutput * audioOutput, ConfigParam * param) {
|
||||||
char * test;
|
char * test;
|
||||||
audio_write_size = strtol((getConf())[CONF_AUDIO_WRITE_SIZE],&test,10);
|
BlockParam * bp = getBlockParam(param, "device");
|
||||||
if (*test!='\0') {
|
OssData * od = newOssData():
|
||||||
ERROR("\"%s\" is not a valid write size",
|
|
||||||
(getConf())[CONF_AUDIO_WRITE_SIZE]);
|
audioOutput->data = od;
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
|
if(!bp) {
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
if(0 <= (fd = fopen("/dev/sound/dsp", O_WRONLY | O_NONBLOCK))) {
|
||||||
|
od->device = strdup("/dev/sound/dsp");
|
||||||
|
}
|
||||||
|
else if(0 <= (fd = fopen("/dev/dsp", O_WRONLY | O_NONBLOCK))) {
|
||||||
|
od->device = strdup("/dev/dsp");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ERROR("Error trying to open default OSS device "
|
||||||
|
"specified at line %i\n", param->line);
|
||||||
|
ERROR("Specify a OSS device and/or check your "
|
||||||
|
"permissions\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
close(od->fd);
|
||||||
|
od->fd = -1;
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
od->device = strdup(bp->value);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void oss_finishDriver(AudioOutput * audioOutput) {
|
static void oss_finishDriver(AudioOutput * audioOutput) {
|
||||||
|
Reference in New Issue
Block a user