summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorAndrew Mahone <andrew.mahone@gmail.com>2009-05-29 10:31:56 +0000
committerAndrew Mahone <andrew.mahone@gmail.com>2009-05-29 10:31:56 +0000
commit84106fd917d80b63c551436f786bc8492174b224 (patch)
tree352eba1ebd2304b6de24f94d3a543962abd25bf4 /apps
parentb714ace1634cd6da7f21fca10ac2e8981da7fc88 (diff)
downloadrockbox-84106fd917d80b63c551436f786bc8492174b224.tar.gz
rockbox-84106fd917d80b63c551436f786bc8492174b224.tar.bz2
rockbox-84106fd917d80b63c551436f786bc8492174b224.zip
Change the search_albumart_files "ignore track art" option to check track art last.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21126 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/recorder/albumart.c156
1 files changed, 86 insertions, 70 deletions
diff --git a/apps/recorder/albumart.c b/apps/recorder/albumart.c
index e33fcb8d08..381e61d2c9 100644
--- a/apps/recorder/albumart.c
+++ b/apps/recorder/albumart.c
@@ -133,7 +133,7 @@ static bool try_exts(char *path, int len)
*
* If the first symbol in size_string is a colon (e.g. ":100x100")
* then the colon is skipped ("100x100" will be used) and the track
- * specific image (./<trackname><size>.bmp) is not tried.
+ * specific image (./<trackname><size>.bmp) is tried last instead of first.
*/
bool search_albumart_files(const struct mp3entry *id3, const char *size_string,
char *buf, int buflen)
@@ -141,6 +141,8 @@ bool search_albumart_files(const struct mp3entry *id3, const char *size_string,
char path[MAX_PATH + 1];
char dir[MAX_PATH + 1];
bool found = false;
+ int track_first = 1;
+ int pass;
const char *trackname;
const char *artist;
int dirlen;
@@ -155,93 +157,107 @@ bool search_albumart_files(const struct mp3entry *id3, const char *size_string,
if (strcmp(trackname, "No file!") == 0)
return false;
- strip_filename(dir, sizeof(dir), trackname);
- dirlen = strlen(dir);
- albumlen = id3->album ? strlen(id3->album) : 0;
-
- /* the first file we look for is one specific to the track playing */
if (*size_string == ':')
- size_string++;
- else {
- strip_extension(path, sizeof(path) - strlen(size_string) - 4, trackname);
- strcat(path, size_string);
- strcat(path, "." EXT);
- #ifdef USE_JPEG_COVER
- pathlen = strlen(path);
- #endif
- found = try_exts(path, pathlen);
- }
- if (!found && albumlen > 0)
{
- /* if it doesn't exist,
- * we look for a file specific to the track's album name */
- pathlen = snprintf(path, sizeof(path),
- "%s%s%s." EXT, dir, id3->album, size_string);
- fix_path_part(path, dirlen, albumlen);
- found = try_exts(path, pathlen);
+ size_string++;
+ track_first = 0;
}
- if (!found)
- {
- /* if it still doesn't exist, we look for a generic file */
- pathlen = snprintf(path, sizeof(path),
- "%scover%s." EXT, dir, size_string);
- found = try_exts(path, pathlen);
- }
+ strip_filename(dir, sizeof(dir), trackname);
+ dirlen = strlen(dir);
+ albumlen = id3->album ? strlen(id3->album) : 0;
-#ifdef USE_JPEG_COVER
- if (!found && !*size_string)
+ for(pass = 0; pass < 2; pass++)
{
- snprintf (path, sizeof(path), "%sfolder.jpg", dir);
- found = file_exists(path);
- }
+ if (track_first || pass)
+ {
+ /* the first file we look for is one specific to the
+ current track */
+ strip_extension(path, sizeof(path) - strlen(size_string) - 4,
+ trackname);
+ strcat(path, size_string);
+ strcat(path, "." EXT);
+#ifdef USE_JPEG_COVER
+ pathlen = strlen(path);
#endif
-
- artist = id3->albumartist != NULL ? id3->albumartist : id3->artist;
-
- if (!found && artist && id3->album)
- {
- /* look in the albumart subdir of .rockbox */
- pathlen = snprintf(path, sizeof(path),
- ROCKBOX_DIR "/albumart/%s-%s%s." EXT,
- artist,
- id3->album,
- size_string);
- fix_path_part(path, strlen(ROCKBOX_DIR "/albumart/"), MAX_PATH);
- found = try_exts(path, pathlen);
- }
-
- if (!found)
- {
- /* if it still doesn't exist,
- * we continue to search in the parent directory */
- strcpy(path, dir);
- path[dirlen - 1] = 0;
- strip_filename(dir, sizeof(dir), path);
- dirlen = strlen(dir);
- }
-
- /* only try parent if there is one */
- if (dirlen > 0)
- {
+ found = try_exts(path, pathlen);
+ }
+ if (pass)
+ break;
if (!found && albumlen > 0)
{
- /* we look in the parent directory
- * for a file specific to the track's album name */
+ /* if it doesn't exist,
+ * we look for a file specific to the track's album name */
pathlen = snprintf(path, sizeof(path),
- "%s%s%s." EXT, dir, id3->album, size_string);
+ "%s%s%s." EXT, dir, id3->album, size_string);
fix_path_part(path, dirlen, albumlen);
found = try_exts(path, pathlen);
}
-
+
if (!found)
{
- /* if it still doesn't exist, we look in the parent directory
- * for a generic file */
+ /* if it still doesn't exist, we look for a generic file */
+ pathlen = snprintf(path, sizeof(path),
+ "%scover%s." EXT, dir, size_string);
+ found = try_exts(path, pathlen);
+ }
+
+#ifdef USE_JPEG_COVER
+ if (!found && !*size_string)
+ {
+ snprintf (path, sizeof(path), "%sfolder.jpg", dir);
+ found = file_exists(path);
+ }
+#endif
+
+ artist = id3->albumartist != NULL ? id3->albumartist : id3->artist;
+
+ if (!found && artist && id3->album)
+ {
+ /* look in the albumart subdir of .rockbox */
pathlen = snprintf(path, sizeof(path),
- "%scover%s." EXT, dir, size_string);
+ ROCKBOX_DIR "/albumart/%s-%s%s." EXT,
+ artist,
+ id3->album,
+ size_string);
+ fix_path_part(path, strlen(ROCKBOX_DIR "/albumart/"), MAX_PATH);
found = try_exts(path, pathlen);
}
+
+ if (!found)
+ {
+ /* if it still doesn't exist,
+ * we continue to search in the parent directory */
+ strcpy(path, dir);
+ path[dirlen - 1] = 0;
+ strip_filename(dir, sizeof(dir), path);
+ dirlen = strlen(dir);
+ }
+
+ /* only try parent if there is one */
+ if (dirlen > 0)
+ {
+ if (!found && albumlen > 0)
+ {
+ /* we look in the parent directory
+ * for a file specific to the track's album name */
+ pathlen = snprintf(path, sizeof(path),
+ "%s%s%s." EXT, dir, id3->album, size_string);
+ fix_path_part(path, dirlen, albumlen);
+ found = try_exts(path, pathlen);
+ }
+
+ if (!found)
+ {
+ /* if it still doesn't exist, we look in the parent directory
+ * for a generic file */
+ pathlen = snprintf(path, sizeof(path),
+ "%scover%s." EXT, dir, size_string);
+ found = try_exts(path, pathlen);
+ }
+ }
+ if (found)
+ break;
}
if (!found)