aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutput_oss.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-10-29 04:11:10 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-10-29 04:11:10 +0000
commit40917e6f59e21d3407d55b08b9101562e01e9f32 (patch)
tree4603245b1874f8da8f7e606e2b028ada72891a01 /src/audioOutput_oss.c
parent9906d3a7b2c509764afb14e9414789b36b266364 (diff)
downloadmpd-40917e6f59e21d3407d55b08b9101562e01e9f32.tar.gz
mpd-40917e6f59e21d3407d55b08b9101562e01e9f32.tar.xz
mpd-40917e6f59e21d3407d55b08b9101562e01e9f32.zip
a few more changes to oss code
git-svn-id: https://svn.musicpd.org/mpd/trunk@2395 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/audioOutput_oss.c')
-rw-r--r--src/audioOutput_oss.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/audioOutput_oss.c b/src/audioOutput_oss.c
index a445761ec..d02a7cbba 100644
--- a/src/audioOutput_oss.c
+++ b/src/audioOutput_oss.c
@@ -46,29 +46,58 @@
#endif /* !(defined(__OpenBSD__) || defined(__NetBSD__) */
static typedef struct _OssData {
- int device;
+ int fd;
+ char * device;
} OssData;
static OssData * newOssData() {
OssData * ret = malloc(sizeof(OssData));
- ret->device = 0;
+ ret->device = NULL;
+ ret->fd = -1;
return ret;
}
static void freeOssData(OssData * od) {
+ if(od->device) free(od->device);
+
free(od);
}
static void oss_initDriver(AudioOutput * audioOutput, ConfigParam * param) {
char * test;
- audio_write_size = strtol((getConf())[CONF_AUDIO_WRITE_SIZE],&test,10);
- if (*test!='\0') {
- ERROR("\"%s\" is not a valid write size",
- (getConf())[CONF_AUDIO_WRITE_SIZE]);
- exit(EXIT_FAILURE);
+ BlockParam * bp = getBlockParam(param, "device");
+ OssData * od = newOssData():
+
+ audioOutput->data = od;
+
+ 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) {