summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-04-06 14:32:31 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-04-06 14:32:31 +0200
commite41f4453e2c5311a0534643c4eeddfc4bb56dfe9 (patch)
tree273d6f7b7cd98d131e6f1a19de8967fc5dd46499
parentbdc72d79ac75d88aedff946c778153492dadf471 (diff)
added is_local_file routine to plugin API
-rw-r--r--deadbeef.h2
-rw-r--r--plugins.c17
-rw-r--r--plugins.h3
-rw-r--r--plugins/artwork/artwork.c18
4 files changed, 24 insertions, 16 deletions
diff --git a/deadbeef.h b/deadbeef.h
index 80508b8d..f2e774ab 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -483,6 +483,8 @@ typedef struct {
int (*plug_activate) (struct DB_plugin_s *p, int activate);
const char * (*plug_get_decoder_id) (const char *id);
void (*plug_remove_decoder_id) (const char *id);
+ // misc utilities
+ int (*is_local_file) (const char *fname); // returns 1 for local filename, 0 otherwise
} DB_functions_t;
// base plugin interface
diff --git a/plugins.c b/plugins.c
index 03246303..805cc6ee 100644
--- a/plugins.c
+++ b/plugins.c
@@ -238,6 +238,8 @@ static DB_functions_t deadbeef_api = {
.plug_activate = plug_activate,
.plug_get_decoder_id = plug_get_decoder_id,
.plug_remove_decoder_id = plug_remove_decoder_id,
+ // misc utilities
+ .is_local_file = plug_is_local_file,
};
DB_functions_t *deadbeef = &deadbeef_api;
@@ -920,3 +922,18 @@ plug_get_decoder_for_id (const char *id) {
}
return NULL;
}
+
+int
+plug_is_local_file (const char *fname) {
+ if (!strncasecmp (fname, "file://", 7)) {
+ return 1;
+ }
+
+ for (; *fname; fname++) {
+ if (!strncmp (fname, "://", 3)) {
+ return 0;
+ }
+ }
+
+ return 1;
+}
diff --git a/plugins.h b/plugins.h
index 7f19ceb3..3f3db11c 100644
--- a/plugins.h
+++ b/plugins.h
@@ -133,4 +133,7 @@ plug_free_decoder_ids (void);
DB_decoder_t *
plug_get_decoder_for_id (const char *id);
+int
+plug_is_local_file (const char *fname);
+
#endif // __PLUGINS_H
diff --git a/plugins/artwork/artwork.c b/plugins/artwork/artwork.c
index ef0c9113..aa4fc64e 100644
--- a/plugins/artwork/artwork.c
+++ b/plugins/artwork/artwork.c
@@ -211,20 +211,6 @@ filter_jpg (const struct dirent *f)
return 0;
}
-static int
-is_local_file (const char *fname) {
- if (!strncasecmp (fname, "file://", 7)) {
- return 1;
- }
- for (; *fname; fname++) {
- if (!strncmp (fname, "://", 3)) {
- return 0;
- }
- }
-
- return 1;
-}
-
static uint8_t *
id3v2_skip_str (int enc, uint8_t *ptr, uint8_t *end) {
if (enc == 0 || enc == 3) {
@@ -276,7 +262,7 @@ fetcher_thread (void *none)
trace ("fetching cover for %s %s\n", param->album, param->artist);
// try to load embedded from id3v2
- if (is_local_file (param->fname)) {
+ if (deadbeef->is_local_file (param->fname)) {
if (deadbeef->conf_get_int ("artwork.enable_embedded", 1)) {
trace ("trying to load artwork from id3v2 tag for %s\n", param->fname);
DB_id3v2_tag_t tag;
@@ -461,7 +447,7 @@ get_album_art (const char *fname, const char *artist, const char *album, artwork
return strdup (DEFAULT_COVER_PATH);
}
- if (!is_local_file (fname)) {
+ if (!deadbeef->is_local_file (fname)) {
return strdup (DEFAULT_COVER_PATH);
}