summaryrefslogtreecommitdiff
path: root/apps/playback.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-02-09 20:13:13 +0000
committerThomas Martitz <kugel@rockbox.org>2011-02-09 20:13:13 +0000
commitf577a6a22c646669e56c5436859d2f5ec8b421e8 (patch)
tree04673c08ff7fc1e12ad4eb4147b705e0bd0fd926 /apps/playback.c
parent0d902c8c54bbc36f24b40c49eb9872aa75b779e4 (diff)
Embedded album art support in MP3/ID3v2 tags.
- Support is limited to non-desync jpeg in id3v2 tags. Other formats (hopefully) follow in the future. - Embedded album art takes precedence over files in album art files. - No additional buffers are used, the jpeg is read directly from the audio file. Flyspray: FS#11216 Author: Yoshihisa Uchida and I git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29259 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/playback.c')
-rw-r--r--apps/playback.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/apps/playback.c b/apps/playback.c
index fe7b74893a..9030161f4a 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -142,6 +142,7 @@ static struct cuesheet *curr_cue = NULL;
#define MAX_MULTIPLE_AA SKINNABLE_SCREENS_COUNT
#ifdef HAVE_ALBUMART
+
static struct albumart_slot {
struct dim dim; /* holds width, height of the albumart */
int used; /* counter, increments if something uses it */
@@ -228,7 +229,6 @@ static bool audio_have_tracks(void);
static void audio_reset_buffer(void);
static void audio_stop_playback(void);
-
/**************************************/
@@ -647,6 +647,7 @@ bool audio_peek_track(struct mp3entry** id3, int offset)
}
#ifdef HAVE_ALBUMART
+
int playback_current_aa_hid(int slot)
{
if (slot < 0)
@@ -656,13 +657,13 @@ int playback_current_aa_hid(int slot)
cur_idx = track_ridx + offset;
cur_idx &= MAX_TRACK_MASK;
-
return tracks[cur_idx].aa_hid[slot];
}
int playback_claim_aa_slot(struct dim *dim)
{
int i;
+
/* first try to find a slot already having the size to reuse it
* since we don't want albumart of the same size buffered multiple times */
FOREACH_ALBUMART(i)
@@ -693,6 +694,7 @@ void playback_release_aa_slot(int slot)
{
/* invalidate the albumart_slot */
struct albumart_slot *aa_slot = &albumart_slots[slot];
+
if (aa_slot->used > 0)
aa_slot->used--;
}
@@ -1315,19 +1317,37 @@ static void audio_finish_load_track(void)
{
int i;
char aa_path[MAX_PATH];
+
FOREACH_ALBUMART(i)
{
/* albumart_slots may change during a yield of bufopen,
* but that's no problem */
if (tracks[track_widx].aa_hid[i] >= 0 || !albumart_slots[i].used)
continue;
+
+ /* we can only decode jpeg for embedded AA */
+ bool embedded_albumart =
+ track_id3->embed_albumart && track_id3->albumart.type == AA_TYPE_JPG;
/* find_albumart will error out if the wps doesn't have AA */
- if (find_albumart(track_id3, aa_path, sizeof(aa_path),
- &(albumart_slots[i].dim)))
+ if (embedded_albumart || find_albumart(track_id3, aa_path,
+ sizeof(aa_path), &(albumart_slots[i].dim)))
{
- int aa_hid = bufopen(aa_path, 0, TYPE_BITMAP,
- &(albumart_slots[i].dim));
-
+ int aa_hid;
+ struct bufopen_bitmap_data user_data = {
+ .dim = &(albumart_slots[i].dim),
+ .embedded_albumart = NULL,
+ };
+ if (embedded_albumart)
+ {
+ user_data.embedded_albumart = &(track_id3->albumart);
+ aa_hid = bufopen(track_id3->path, 0,
+ TYPE_BITMAP, &user_data);
+ }
+ else
+ {
+ aa_hid = bufopen(aa_path, 0, TYPE_BITMAP,
+ &user_data);
+ }
if(aa_hid == ERR_BUFFER_FULL)
{
filling = STATE_FULL;
@@ -1342,7 +1362,6 @@ static void audio_finish_load_track(void)
tracks[track_widx].aa_hid[i] = aa_hid;
}
}
-
}
#endif