diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2005-03-12 03:10:09 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2005-03-12 03:10:09 +0000 |
commit | 8583a3bc4e9af2a1be06c82422a7cac1470341ce (patch) | |
tree | 4befe14e73239f6bcabc6046499bd0e4a99ebe88 /src/audioOutputs | |
parent | 18651935754dbf8972cd8188c2ec5b05ded60299 (diff) | |
download | mpd-8583a3bc4e9af2a1be06c82422a7cac1470341ce.tar.gz mpd-8583a3bc4e9af2a1be06c82422a7cac1470341ce.tar.xz mpd-8583a3bc4e9af2a1be06c82422a7cac1470341ce.zip |
if no audioOutput specified, we no attempt to detect if there exists a usable oss or alsa device
git-svn-id: https://svn.musicpd.org/mpd/trunk@3057 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/audioOutputs')
-rw-r--r-- | src/audioOutputs/audioOutput_alsa.c | 24 | ||||
-rw-r--r-- | src/audioOutputs/audioOutput_ao.c | 2 | ||||
-rw-r--r-- | src/audioOutputs/audioOutput_oss.c | 44 | ||||
-rw-r--r-- | src/audioOutputs/audioOutput_shout.c | 2 |
4 files changed, 67 insertions, 5 deletions
diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c index d804720b0..9cc15c842 100644 --- a/src/audioOutputs/audioOutput_alsa.c +++ b/src/audioOutputs/audioOutput_alsa.c @@ -69,7 +69,10 @@ static void freeAlsaData(AlsaData * ad) { } static int alsa_initDriver(AudioOutput * audioOutput, ConfigParam * param) { - BlockParam * bp = getBlockParam(param, "device"); + BlockParam * bp = NULL; + + if(param) bp = getBlockParam(param, "device"); + AlsaData * ad = newAlsaData(); audioOutput->data = ad; @@ -85,6 +88,23 @@ static void alsa_finishDriver(AudioOutput * audioOutput) { freeAlsaData(ad); } +static int alsa_testDefault() +{ + snd_pcm_t * handle; + + int ret = snd_pcm_open(&handle, "default", SND_PCM_STREAM_PLAYBACK, + SND_PCM_NONBLOCK); + + if(ret) { + WARNING("Error opening default alsa device: %s\n", + snd_strerror(-ret)); + return -1; + } + else snd_pcm_close(handle); + + return 0; +} + static int alsa_openDevice(AudioOutput * audioOutput) { AlsaData * ad = audioOutput->data; @@ -313,6 +333,7 @@ static int alsa_playAudio(AudioOutput * audioOutput, char * playChunk, AudioOutputPlugin alsaPlugin = { "alsa", + alsa_testDefault, alsa_initDriver, alsa_finishDriver, alsa_openDevice, @@ -332,6 +353,7 @@ AudioOutputPlugin alsaPlugin = NULL, NULL, NULL, + NULL, NULL /* sendMetadataFunc */ }; diff --git a/src/audioOutputs/audioOutput_ao.c b/src/audioOutputs/audioOutput_ao.c index 380e6e9d5..25dd3ff10 100644 --- a/src/audioOutputs/audioOutput_ao.c +++ b/src/audioOutputs/audioOutput_ao.c @@ -237,6 +237,7 @@ static int audioOutputAo_play(AudioOutput * audioOutput, char * playChunk, AudioOutputPlugin aoPlugin = { "ao", + NULL, audioOutputAo_initDriver, audioOutputAo_finishDriver, audioOutputAo_openDevice, @@ -259,6 +260,7 @@ AudioOutputPlugin aoPlugin = NULL, NULL, NULL, + NULL, NULL }; diff --git a/src/audioOutputs/audioOutput_oss.c b/src/audioOutputs/audioOutput_oss.c index b3ad9bff4..fc703bd90 100644 --- a/src/audioOutputs/audioOutput_oss.c +++ b/src/audioOutputs/audioOutput_oss.c @@ -291,10 +291,38 @@ static int oss_statDevice(char * device, int * stErrno) { return 0; } +static int oss_testDefault() { + int fd; + + fd = open("/dev/sound/dsp", O_WRONLY); + + if(fd) { + close(fd); + return 0; + } + + WARNING("Error opening OSS device \"/dev/sound/dsp\": %s\n", + strerror(errno)); + + fd = open("/dev/dsp", O_WRONLY); + + if(fd) { + close(fd); + return 0; + } + + WARNING("Error opening OSS device \"/dev/dsp\": %s\n", + strerror(errno)); + + return -1; +} + static int oss_initDriver(AudioOutput * audioOutput, ConfigParam * param) { - BlockParam * bp = getBlockParam(param, "device"); + BlockParam * bp = NULL; + + if(param) bp = getBlockParam(param, "device"); + OssData * od = newOssData(); - audioOutput->data = od; if(!bp) { @@ -307,8 +335,14 @@ static int oss_initDriver(AudioOutput * audioOutput, ConfigParam * param) { if(ret[0] == 0) od->device = strdup("/dev/sound/dsp"); else if(ret[1] == 0) od->device = strdup("/dev/dsp"); else { - ERROR("Error trying to open default OSS device " - "specified at line %i\n", param->line); + if(param) { + ERROR("Error trying to open default OSS device " + "specified at line %i\n", param->line); + } + else { + ERROR("Error trying to open default OSS " + "device\n"); + } if(ret[0] == ret[1] == OSS_STAT_DOESN_T_EXIST) { ERROR("Neither /dev/dsp nor /dev/sound/dsp " @@ -501,6 +535,7 @@ static int oss_playAudio(AudioOutput * audioOutput, char * playChunk, AudioOutputPlugin ossPlugin = { "oss", + oss_testDefault, oss_initDriver, oss_finishDriver, oss_openDevice, @@ -521,6 +556,7 @@ AudioOutputPlugin ossPlugin = NULL, NULL, NULL, + NULL, NULL /* sendMetadataFunc */ }; diff --git a/src/audioOutputs/audioOutput_shout.c b/src/audioOutputs/audioOutput_shout.c index 9a54eb8a9..322f7e325 100644 --- a/src/audioOutputs/audioOutput_shout.c +++ b/src/audioOutputs/audioOutput_shout.c @@ -597,6 +597,7 @@ static void myShout_setTag(AudioOutput * audioOutput, MpdTag * tag) { AudioOutputPlugin shoutPlugin = { "shout", + NULL, myShout_initDriver, myShout_finishDriver, myShout_openDevice, @@ -617,6 +618,7 @@ AudioOutputPlugin shoutPlugin = NULL, NULL, NULL, + NULL, NULL }; |