aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder_thread.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-14 11:10:49 +0200
committerMax Kellermann <max@duempel.org>2008-10-14 11:10:49 +0200
commit5b71d5f6f707a35a7b7a47b33ef2e1417ea6bcc6 (patch)
tree5fd2efeb95e3412ac177434611770ca864325c0e /src/decoder_thread.c
parenta52a9fc1fc2b385dd66edd45f602ac337399cc83 (diff)
downloadmpd-5b71d5f6f707a35a7b7a47b33ef2e1417ea6bcc6.tar.gz
mpd-5b71d5f6f707a35a7b7a47b33ef2e1417ea6bcc6.tar.xz
mpd-5b71d5f6f707a35a7b7a47b33ef2e1417ea6bcc6.zip
mapper: new song-to-filesystem mapper library
The mapper library maps directory and song objects to file system paths. With this central library, the code mixture in path.c should be cleaned up, and we will be able to add neat features like aliasing.
Diffstat (limited to '')
-rw-r--r--src/decoder_thread.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index 594bfbc77..f0f315f3a 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -22,27 +22,28 @@
#include "decoder_internal.h"
#include "player_control.h"
#include "song.h"
-
+#include "mapper.h"
#include "path.h"
#include "log.h"
#include "ls.h"
static void decodeStart(void)
{
+ struct song *song = dc.next_song;
struct decoder decoder;
int ret;
bool close_instream = true;
InputStream inStream;
struct decoder_plugin *plugin = NULL;
char path_max_fs[MPD_PATH_MAX];
- char path_max_utf8[MPD_PATH_MAX];
- song_get_url(dc.next_song, path_max_utf8);
- if (!isRemoteUrl(path_max_utf8)) {
- rmp2amp_r(path_max_fs,
- utf8_to_fs_charset(path_max_fs, path_max_utf8));
- } else
+ if (song_is_file(song))
+ map_song_fs(song, path_max_fs);
+ else {
+ char path_max_utf8[MPD_PATH_MAX];
+ song_get_url(song, path_max_utf8);
pathcpy_trunc(path_max_fs, path_max_utf8);
+ }
dc.current_song = dc.next_song; /* NEED LOCK */
if (openInputStream(&inStream, path_max_fs) < 0) {
@@ -74,7 +75,7 @@ static void decodeStart(void)
goto stop;
ret = DECODE_ERROR_UNKTYPE;
- if (isRemoteUrl(path_max_utf8)) {
+ if (!song_is_file(song)) {
unsigned int next = 0;
/* first we try mime types: */
@@ -92,7 +93,7 @@ static void decodeStart(void)
/* if that fails, try suffix matching the URL: */
if (plugin == NULL) {
- const char *s = getSuffix(path_max_utf8);
+ const char *s = getSuffix(path_max_fs);
next = 0;
while (ret && (plugin = decoder_plugin_from_suffix(s, next++))) {
if (plugin->stream_decode == NULL)
@@ -123,7 +124,7 @@ static void decodeStart(void)
}
} else {
unsigned int next = 0;
- const char *s = getSuffix(path_max_utf8);
+ const char *s = getSuffix(path_max_fs);
while (ret && (plugin = decoder_plugin_from_suffix(s, next++))) {
if (!plugin->stream_types & INPUT_PLUGIN_STREAM_FILE)
continue;