aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-25 16:17:48 +0100
committerMax Kellermann <max@duempel.org>2008-11-25 16:17:48 +0100
commit423276a38431a9057ea188ddf170305288098220 (patch)
tree448823241dccfc36f6547e35ff92818c6f45f5ad /src
parentffc604498ec8dcc239d62ef1559acba3a69ad7d9 (diff)
downloadmpd-423276a38431a9057ea188ddf170305288098220.tar.gz
mpd-423276a38431a9057ea188ddf170305288098220.tar.xz
mpd-423276a38431a9057ea188ddf170305288098220.zip
ao: support all libao error codes
The function audioOutputAo_error() did not implement all possible libao error codes. Support the rest of them, and fall back to strerror().
Diffstat (limited to 'src')
-rw-r--r--src/output/ao_plugin.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/output/ao_plugin.c b/src/output/ao_plugin.c
index d883b7da1..b3819a1d8 100644
--- a/src/output/ao_plugin.c
+++ b/src/output/ao_plugin.c
@@ -42,15 +42,36 @@ static AoData *newAoData(void)
return ret;
}
-static void audioOutputAo_error(void)
+static void audioOutputAo_error(const char *msg)
{
- if (errno == AO_ENOTLIVE) {
- g_warning("not a live ao device\n");
- } else if (errno == AO_EOPENDEVICE) {
- g_warning("not able to open audio device\n");
- } else if (errno == AO_EBADOPTION) {
- g_warning("bad driver option\n");
+ const char *error;
+
+ switch (errno) {
+ case AO_ENODRIVER:
+ error = "No such libao driver";
+ break;
+
+ case AO_ENOTLIVE:
+ error = "This driver is not a libao live device";
+ break;
+
+ case AO_EBADOPTION:
+ error = "Invalid libao option";
+ break;
+
+ case AO_EOPENDEVICE:
+ error = "Cannot open the libao device";
+ break;
+
+ case AO_EFAIL:
+ error = "Generic libao failure";
+ break;
+
+ default:
+ error = strerror(errno);
}
+
+ g_warning("%s: %s\n", msg, error);
}
static void *audioOutputAo_initDriver(struct audio_output *ao,
@@ -224,8 +245,7 @@ audioOutputAo_play(void *data, const char *playChunk, size_t size)
? size : (size_t)ad->writeSize;
if (ao_play_deconst(ad->device, playChunk, chunk_size) == 0) {
- audioOutputAo_error();
- g_warning("closing audio device due to write error\n");
+ audioOutputAo_error("Closing libao device due to play error");
return false;
}