aboutsummaryrefslogtreecommitdiffstats
path: root/src/player_error.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-08-16 09:28:15 -0700
committerEric Wong <normalperson@yhbt.net>2008-08-16 09:39:32 -0700
commit44d9f62f34e0561d83ea32941f0ea1b529b1490d (patch)
tree5345eba046b6e3bcf8c063e7bae8b501b7a99f4a /src/player_error.c
parentf9f70860622613686e6ac0bf7ebd448f437d92a7 (diff)
downloadmpd-44d9f62f34e0561d83ea32941f0ea1b529b1490d.tar.gz
mpd-44d9f62f34e0561d83ea32941f0ea1b529b1490d.tar.xz
mpd-44d9f62f34e0561d83ea32941f0ea1b529b1490d.zip
core rewrite (decode,player,outputBuffer,playlist)
This is a huge refactoring of the core mpd process. The queueing/buffering mechanism is heavily reworked. The player.c code has been merged into outputBuffer (the actual ring buffering logic is handled by ringbuf.c); and decode.c actually handles decoding stuff. The end result is several hundreds of lines shorter, even though we still have a lot of DEBUG statements left in there for tracing and a lot of assertions, too.
Diffstat (limited to '')
-rw-r--r--src/player_error.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/player_error.c b/src/player_error.c
new file mode 100644
index 000000000..4c7f7b9de
--- /dev/null
+++ b/src/player_error.c
@@ -0,0 +1,53 @@
+#include "player_error.h"
+#include "os_compat.h"
+#include "log.h"
+#include "path.h"
+
+enum player_error player_errno;
+Song *player_errsong;
+
+void player_clearerror(void)
+{
+ player_errno = PLAYER_ERROR_NONE;
+ player_errsong = NULL;
+}
+
+void player_seterror(enum player_error err, Song *song)
+{
+ if (player_errno)
+ ERROR("Clobbering existing error: %s\n", player_strerror());
+ player_errno = err;
+ player_errsong = song;
+}
+
+const char *player_strerror(void)
+{
+ /* static OK here, only one user in main task */
+ static char error[MPD_PATH_MAX + 64]; /* still too much */
+ char path_max_tmp[MPD_PATH_MAX];
+ *error = '\0'; /* likely */
+
+ switch (player_errno) {
+ case PLAYER_ERROR_NONE: break;
+ case PLAYER_ERROR_FILE:
+ snprintf(error, sizeof(error), "problems decoding \"%s\"",
+ get_song_url(path_max_tmp, player_errsong));
+ break;
+ case PLAYER_ERROR_AUDIO:
+ strcpy(error, "problems opening audio device");
+ break;
+ case PLAYER_ERROR_SYSTEM:
+ strcpy(error, "system error occured");
+ break;
+ case PLAYER_ERROR_UNKTYPE:
+ snprintf(error, sizeof(error), "file type of \"%s\" is unknown",
+ get_song_url(path_max_tmp, player_errsong));
+ case PLAYER_ERROR_FILENOTFOUND:
+ snprintf(error, sizeof(error),
+ "file \"%s\" does not exist or is inaccessible",
+ get_song_url(path_max_tmp, player_errsong));
+ break;
+ }
+ return *error ? error : NULL;
+}
+