aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ls.c35
-rw-r--r--src/ls.h6
-rw-r--r--src/song.c47
-rw-r--r--src/update.c10
4 files changed, 39 insertions, 59 deletions
diff --git a/src/ls.c b/src/ls.c
index 85f0d266..5be3f7b7 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -19,8 +19,6 @@
#include "ls.h"
#include "client.h"
#include "config.h"
-#include "decoder_list.h"
-#include "archive_list.h"
#include <string.h>
@@ -66,36 +64,3 @@ const char *getSuffix(const char *utf8file)
return dot != NULL ? dot + 1 : NULL;
}
-
-const struct decoder_plugin *
-hasMusicSuffix(const char *utf8file, unsigned int next)
-{
- const struct decoder_plugin *ret = NULL;
-
- const char *s = getSuffix(utf8file);
- if (s) {
- ret = decoder_plugin_from_suffix(s, next);
- } else {
- g_debug("hasMusicSuffix: The file: %s has no valid suffix\n",
- utf8file);
- }
-
- return ret;
-}
-
-#ifdef ENABLE_ARCHIVE
-const struct archive_plugin *
-get_archive_by_suffix(const char *utf8file)
-{
- const struct archive_plugin *ret = NULL;
-
- const char *s = getSuffix(utf8file);
- if (s) {
- ret = archive_plugin_from_suffix(s);
- } else {
- g_debug("get_archive_by_suffix: The file: %s has no valid suffix\n",
- utf8file);
- }
- return ret;
-}
-#endif
diff --git a/src/ls.h b/src/ls.h
index 711e33d6..62777d9e 100644
--- a/src/ls.h
+++ b/src/ls.h
@@ -34,12 +34,6 @@ bool uri_has_scheme(const char *uri);
bool isRemoteUrl(const char *url);
-const struct decoder_plugin *
-hasMusicSuffix(const char *utf8file, unsigned int next);
-
-const struct archive_plugin *
-get_archive_by_suffix(const char *utf8file);
-
void printRemoteUrlHandlers(struct client *client);
#endif
diff --git a/src/song.c b/src/song.c
index 19abb963..e89b2ac8 100644
--- a/src/song.c
+++ b/src/song.c
@@ -101,13 +101,23 @@ song_free(struct song *song)
bool
song_file_update(struct song *song)
{
+ const char *suffix;
char *path_fs;
const struct decoder_plugin *plugin;
- unsigned int next = 0;
struct stat st;
assert(song_is_file(song));
+ /* check if there's a suffix and a plugin */
+
+ suffix = getSuffix(song->url);
+ if (suffix == NULL)
+ return false;
+
+ plugin = decoder_plugin_from_suffix(suffix, false);
+ if (plugin == NULL)
+ return false;
+
path_fs = map_song_fs(song);
if (path_fs == NULL)
return false;
@@ -124,9 +134,13 @@ song_file_update(struct song *song)
song->mtime = st.st_mtime;
- while (song->tag == NULL &&
- (plugin = hasMusicSuffix(path_fs, next++)))
+ do {
song->tag = plugin->tag_dup(path_fs);
+ if (song->tag != NULL)
+ break;
+
+ plugin = decoder_plugin_from_suffix(suffix, true);
+ } while (plugin != NULL);
g_free(path_fs);
return song->tag != NULL;
@@ -135,29 +149,30 @@ song_file_update(struct song *song)
bool
song_file_update_inarchive(struct song *song)
{
- char *path_fs;
+ const char *suffix;
const struct decoder_plugin *plugin;
assert(song_is_file(song));
- path_fs = map_song_fs(song);
- if (path_fs == NULL)
+ /* check if there's a suffix and a plugin */
+
+ suffix = getSuffix(song->url);
+ if (suffix == NULL)
return false;
- if (song->tag != NULL) {
+ plugin = decoder_plugin_from_suffix(suffix, false);
+ if (plugin == NULL)
+ return false;
+
+ if (song->tag != NULL)
tag_free(song->tag);
- song->tag = NULL;
- }
+
//accept every file that has music suffix
//because we dont support tag reading throught
//input streams
- plugin = hasMusicSuffix(path_fs, 0);
- g_free(path_fs);
- if (plugin) {
- song->tag = tag_new();
- //tag_add_item(tag, TAG_ITEM_TITLE, f->title);
- }
- return song->tag != NULL;
+ song->tag = tag_new();
+
+ return true;
}
char *
diff --git a/src/update.c b/src/update.c
index 826a17dc..0cf73ff8 100644
--- a/src/update.c
+++ b/src/update.c
@@ -24,6 +24,7 @@
#include "ls.h"
#include "mapper.h"
#include "path.h"
+#include "decoder_list.h"
#include "playlist.h"
#include "event_pipe.h"
#include "condition.h"
@@ -351,7 +352,12 @@ static void
update_regular_file(struct directory *directory,
const char *name, const struct stat *st)
{
- if (hasMusicSuffix(name, 0)) {
+ const char *suffix = getSuffix(name);
+
+ if (suffix == NULL)
+ return;
+
+ if (decoder_plugin_from_suffix(suffix, false) != NULL) {
struct song *song = songvec_find(&directory->songs, name);
if (song == NULL) {
@@ -371,7 +377,7 @@ update_regular_file(struct directory *directory,
modified = true;
}
#ifdef ENABLE_ARCHIVE
- } else if ((archive = get_archive_by_suffix(name))) {
+ } else if ((archive = archive_plugin_from_suffix(suffix))) {
struct archive_file *archfile;
char pathname[MPD_PATH_MAX];