aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/decode.c33
-rw-r--r--src/decode.h2
-rw-r--r--src/inputPlugins/wavpack_plugin.c6
-rw-r--r--src/outputBuffer.c1
-rw-r--r--src/player_error.c36
-rw-r--r--src/player_error.h5
-rw-r--r--src/playlist.c8
-rw-r--r--src/playlist.h2
8 files changed, 44 insertions, 49 deletions
diff --git a/src/decode.c b/src/decode.c
index e0685e0e9..dd1ea9396 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -173,12 +173,9 @@ static int decode_start(void)
InputStream is;
InputPlugin *plugin = NULL;
char path_max_fs[MPD_PATH_MAX];
- char path_max_utf8[MPD_PATH_MAX];
assert(pthread_equal(pthread_self(), dc.thread));
assert(dc.state == DC_STATE_DECODE);
- assert(dc.current_song);
- get_song_url(path_max_utf8, dc.current_song);
- assert(*path_max_utf8);
+ assert(*dc.utf8url);
switch (dc.action) {
case DC_ACTION_START:
@@ -193,20 +190,20 @@ static int decode_start(void)
default: assert("unknown action!" && 0);
}
- if (isRemoteUrl(path_max_utf8)) {
- pathcpy_trunc(path_max_fs, path_max_utf8);
+ if (isRemoteUrl(dc.utf8url)) {
+ pathcpy_trunc(path_max_fs, dc.utf8url);
} else {
rmp2amp_r(path_max_fs,
- utf8_to_fs_charset(path_max_fs, path_max_utf8));
+ utf8_to_fs_charset(path_max_fs, dc.utf8url));
}
if (openInputStream(&is, path_max_fs) < 0) {
DEBUG("couldn't open song: %s\n", path_max_fs);
- player_seterror(PLAYER_ERROR_FILENOTFOUND, dc.current_song);
+ player_seterror(PLAYER_ERROR_FILENOTFOUND, dc.utf8url);
return err;
}
- if (isRemoteUrl(path_max_utf8)) {
+ if (isRemoteUrl(dc.utf8url)) {
unsigned int next = 0;
/* first we try mime types: */
@@ -224,7 +221,7 @@ static int decode_start(void)
/* if that fails, try suffix matching the URL: */
if (plugin == NULL) {
- const char *s = getSuffix(path_max_utf8);
+ const char *s = getSuffix(dc.utf8url);
next = 0;
while (err && (plugin = getInputPluginFromSuffix(s, next++))) {
if (!plugin->streamDecodeFunc)
@@ -250,7 +247,7 @@ static int decode_start(void)
}
} else {
unsigned int next = 0;
- const char *s = getSuffix(path_max_utf8);
+ const char *s = getSuffix(dc.utf8url);
while (err && (plugin = getInputPluginFromSuffix(s, next++))) {
if (!plugin->streamTypes & INPUT_PLUGIN_STREAM_FILE)
continue;
@@ -273,9 +270,9 @@ static int decode_start(void)
if (err) {
if (plugin)
- player_seterror(PLAYER_ERROR_SYSTEM, dc.current_song);
+ player_seterror(PLAYER_ERROR_SYSTEM, dc.utf8url);
else
- player_seterror(PLAYER_ERROR_UNKTYPE, dc.current_song);
+ player_seterror(PLAYER_ERROR_UNKTYPE, dc.utf8url);
}
if (player_errno)
ERROR("player_error: %s\n", player_strerror());
@@ -299,20 +296,18 @@ static void * decoder_task(mpd_unused void *arg)
case DC_STATE_DECODE:
/* DEBUG(__FILE__": %s %d\n", __func__, __LINE__); */
/* DEBUG("dc.action: %d\n", (int)dc.action); */
- if ((dc.current_song = playlist_queued_song())) {
- char p[MPD_PATH_MAX];
+ if (playlist_queued_url(dc.utf8url)) {
int err;
ob_advance_sequence();
- get_song_url(p, dc.current_song);
- DEBUG("decoding song: %s\n", p);
+ DEBUG("decoding song: %s\n", dc.utf8url);
err = decode_start();
- DEBUG("DONE decoding song: %s\n", p);
+ DEBUG("DONE decoding song: %s\n", dc.utf8url);
if (err)
ob_trigger_action(OB_ACTION_RESET);
else
ob_flush();
- dc.current_song = NULL;
+ dc.utf8url[0] = '\0';
}
finalize_per_track_actions();
playlist_queue_next();
diff --git a/src/decode.h b/src/decode.h
index 61eeee078..71e7a498e 100644
--- a/src/decode.h
+++ b/src/decode.h
@@ -43,7 +43,7 @@ enum dc_state {
};
struct decoder_control {
- Song * current_song; /* only needed for wavpack, remove? */
+ char utf8url[MPD_PATH_MAX]; /* only needed for wavpack, remove? */
enum dc_state state; /* rw=dc.thread, r=main */
enum dc_action action; /* rw protected by action_cond */
float total_time; /* w=dc.thread, r=main */
diff --git a/src/inputPlugins/wavpack_plugin.c b/src/inputPlugins/wavpack_plugin.c
index 8bba8ae2b..b6da51e5e 100644
--- a/src/inputPlugins/wavpack_plugin.c
+++ b/src/inputPlugins/wavpack_plugin.c
@@ -429,10 +429,8 @@ static int wavpack_open_wvc(InputStream *is_wvc)
char wvc_url[MPD_PATH_MAX];
size_t len;
- /* This is the only reader of dc.current_song */
- if (!get_song_url(wvc_url, dc.current_song))
- return 0;
-
+ /* This is the only reader of dc.utf8url (in inputPlugins) */
+ pathcpy_trunc(wvc_url, dc.utf8url);
len = strlen(wvc_url);
if ((len + 2) >= MPD_PATH_MAX)
return 0;
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index 9a659db41..7216a9c9c 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -22,7 +22,6 @@
#include "normalize.h"
#include "ringbuf.h"
#include "condition.h"
-#include "song.h"
#include "main_notify.h"
#include "player_error.h"
#include "log.h"
diff --git a/src/player_error.c b/src/player_error.c
index 4c7f7b9de..38e76e2c4 100644
--- a/src/player_error.c
+++ b/src/player_error.c
@@ -4,50 +4,52 @@
#include "path.h"
enum player_error player_errno;
-Song *player_errsong;
+static char errsong_url[MPD_PATH_MAX];
void player_clearerror(void)
{
player_errno = PLAYER_ERROR_NONE;
- player_errsong = NULL;
+ *errsong_url = '\0';
}
-void player_seterror(enum player_error err, Song *song)
+void player_seterror(enum player_error err, const char *url)
{
if (player_errno)
ERROR("Clobbering existing error: %s\n", player_strerror());
player_errno = err;
- player_errsong = song;
+ pathcpy_trunc(errsong_url, url);
}
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 */
+ const char *ret = NULL;
switch (player_errno) {
- case PLAYER_ERROR_NONE: break;
+ case PLAYER_ERROR_NONE:
+ ret = "";
+ break;
case PLAYER_ERROR_FILE:
- snprintf(error, sizeof(error), "problems decoding \"%s\"",
- get_song_url(path_max_tmp, player_errsong));
+ snprintf(error, sizeof(error),
+ "problems decoding \"%s\"", errsong_url);
break;
case PLAYER_ERROR_AUDIO:
- strcpy(error, "problems opening audio device");
+ ret = "problems opening audio device";
break;
case PLAYER_ERROR_SYSTEM:
- strcpy(error, "system error occured");
+ /* DONTFIX: misspelling "occurred" here is client-visible */
+ ret = "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));
+ "file type of \"%s\" is unknown", errsong_url);
break;
+ case PLAYER_ERROR_FILENOTFOUND:
+ snprintf(error, sizeof(error),
+ "file \"%s\" does not exist or is inaccessible",
+ errsong_url);
}
- return *error ? error : NULL;
+ return ret ? ret : error;
}
diff --git a/src/player_error.h b/src/player_error.h
index c90c98420..997cb4604 100644
--- a/src/player_error.h
+++ b/src/player_error.h
@@ -19,8 +19,6 @@
#ifndef PLAYER_ERROR_H
#define PLAYER_ERROR_H
-#include "song.h"
-
enum player_error {
PLAYER_ERROR_NONE = 0,
PLAYER_ERROR_FILE,
@@ -31,10 +29,9 @@ enum player_error {
};
extern enum player_error player_errno;
-extern Song *player_errsong;
void player_clearerror(void);
-void player_seterror(enum player_error err, Song *song);
+void player_seterror(enum player_error err, const char *url);
const char *player_strerror(void);
#endif /* PLAYER_ERROR_H */
diff --git a/src/playlist.c b/src/playlist.c
index ca903036d..2ab09ebff 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -554,11 +554,15 @@ void playlist_queue_next(void)
wakeup_main_task();
}
-Song *playlist_queued_song(void)
+char *playlist_queued_url(char utf8url[MPD_PATH_MAX])
{
+ Song *song;
+
assert(pthread_equal(pthread_self(), dc.thread));
pthread_mutex_lock(&queue_lock);
- return song_at(playlist.queued);
+ song = song_at(playlist.queued);
+
+ return song ? get_song_url(utf8url, song) : NULL;
}
static void queue_song_locked(int order_num)
diff --git a/src/playlist.h b/src/playlist.h
index 265b58356..df1bd9e7b 100644
--- a/src/playlist.h
+++ b/src/playlist.h
@@ -68,7 +68,7 @@ enum playlist_result playlistInfo(int fd, int song);
enum playlist_result playlistId(int fd, int song);
-Song *playlist_queued_song(void);
+char *playlist_queued_url(char utf8url[MPD_PATH_MAX]);
void playlist_queue_next(void);