aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs/audioOutput_alsa.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/audioOutputs/audioOutput_alsa.c24
1 files changed, 23 insertions, 1 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 */
};