From 40917e6f59e21d3407d55b08b9101562e01e9f32 Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Fri, 29 Oct 2004 04:11:10 +0000 Subject: a few more changes to oss code git-svn-id: https://svn.musicpd.org/mpd/trunk@2395 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/audioOutput_oss.c | 43 ++++++++++++++++++++++++++++++++++++------- 1 file 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) { -- cgit v1.2.3