diff options
author | Thomas Martitz <kugel@rockbox.org> | 2011-02-09 20:13:13 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2011-02-09 20:13:13 +0000 |
commit | f577a6a22c646669e56c5436859d2f5ec8b421e8 (patch) | |
tree | 04673c08ff7fc1e12ad4eb4147b705e0bd0fd926 /apps/playback.c | |
parent | 0d902c8c54bbc36f24b40c49eb9872aa75b779e4 (diff) | |
download | rockbox-f577a6a22c646669e56c5436859d2f5ec8b421e8.tar.gz rockbox-f577a6a22c646669e56c5436859d2f5ec8b421e8.zip |
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.c | 35 |
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; | |||
142 | #define MAX_MULTIPLE_AA SKINNABLE_SCREENS_COUNT | 142 | #define MAX_MULTIPLE_AA SKINNABLE_SCREENS_COUNT |
143 | 143 | ||
144 | #ifdef HAVE_ALBUMART | 144 | #ifdef HAVE_ALBUMART |
145 | |||
145 | static struct albumart_slot { | 146 | static struct albumart_slot { |
146 | struct dim dim; /* holds width, height of the albumart */ | 147 | struct dim dim; /* holds width, height of the albumart */ |
147 | int used; /* counter, increments if something uses it */ | 148 | int used; /* counter, increments if something uses it */ |
@@ -228,7 +229,6 @@ static bool audio_have_tracks(void); | |||
228 | static void audio_reset_buffer(void); | 229 | static void audio_reset_buffer(void); |
229 | static void audio_stop_playback(void); | 230 | static void audio_stop_playback(void); |
230 | 231 | ||
231 | |||
232 | /**************************************/ | 232 | /**************************************/ |
233 | 233 | ||
234 | 234 | ||
@@ -647,6 +647,7 @@ bool audio_peek_track(struct mp3entry** id3, int offset) | |||
647 | } | 647 | } |
648 | 648 | ||
649 | #ifdef HAVE_ALBUMART | 649 | #ifdef HAVE_ALBUMART |
650 | |||
650 | int playback_current_aa_hid(int slot) | 651 | int playback_current_aa_hid(int slot) |
651 | { | 652 | { |
652 | if (slot < 0) | 653 | if (slot < 0) |
@@ -656,13 +657,13 @@ int playback_current_aa_hid(int slot) | |||
656 | 657 | ||
657 | cur_idx = track_ridx + offset; | 658 | cur_idx = track_ridx + offset; |
658 | cur_idx &= MAX_TRACK_MASK; | 659 | cur_idx &= MAX_TRACK_MASK; |
659 | |||
660 | return tracks[cur_idx].aa_hid[slot]; | 660 | return tracks[cur_idx].aa_hid[slot]; |
661 | } | 661 | } |
662 | 662 | ||
663 | int playback_claim_aa_slot(struct dim *dim) | 663 | int playback_claim_aa_slot(struct dim *dim) |
664 | { | 664 | { |
665 | int i; | 665 | int i; |
666 | |||
666 | /* first try to find a slot already having the size to reuse it | 667 | /* first try to find a slot already having the size to reuse it |
667 | * since we don't want albumart of the same size buffered multiple times */ | 668 | * since we don't want albumart of the same size buffered multiple times */ |
668 | FOREACH_ALBUMART(i) | 669 | FOREACH_ALBUMART(i) |
@@ -693,6 +694,7 @@ void playback_release_aa_slot(int slot) | |||
693 | { | 694 | { |
694 | /* invalidate the albumart_slot */ | 695 | /* invalidate the albumart_slot */ |
695 | struct albumart_slot *aa_slot = &albumart_slots[slot]; | 696 | struct albumart_slot *aa_slot = &albumart_slots[slot]; |
697 | |||
696 | if (aa_slot->used > 0) | 698 | if (aa_slot->used > 0) |
697 | aa_slot->used--; | 699 | aa_slot->used--; |
698 | } | 700 | } |
@@ -1315,19 +1317,37 @@ static void audio_finish_load_track(void) | |||
1315 | { | 1317 | { |
1316 | int i; | 1318 | int i; |
1317 | char aa_path[MAX_PATH]; | 1319 | char aa_path[MAX_PATH]; |
1320 | |||
1318 | FOREACH_ALBUMART(i) | 1321 | FOREACH_ALBUMART(i) |
1319 | { | 1322 | { |
1320 | /* albumart_slots may change during a yield of bufopen, | 1323 | /* albumart_slots may change during a yield of bufopen, |
1321 | * but that's no problem */ | 1324 | * but that's no problem */ |
1322 | if (tracks[track_widx].aa_hid[i] >= 0 || !albumart_slots[i].used) | 1325 | if (tracks[track_widx].aa_hid[i] >= 0 || !albumart_slots[i].used) |
1323 | continue; | 1326 | continue; |
1327 | |||
1328 | /* we can only decode jpeg for embedded AA */ | ||
1329 | bool embedded_albumart = | ||
1330 | track_id3->embed_albumart && track_id3->albumart.type == AA_TYPE_JPG; | ||
1324 | /* find_albumart will error out if the wps doesn't have AA */ | 1331 | /* find_albumart will error out if the wps doesn't have AA */ |
1325 | if (find_albumart(track_id3, aa_path, sizeof(aa_path), | 1332 | if (embedded_albumart || find_albumart(track_id3, aa_path, |
1326 | &(albumart_slots[i].dim))) | 1333 | sizeof(aa_path), &(albumart_slots[i].dim))) |
1327 | { | 1334 | { |
1328 | int aa_hid = bufopen(aa_path, 0, TYPE_BITMAP, | 1335 | int aa_hid; |
1329 | &(albumart_slots[i].dim)); | 1336 | struct bufopen_bitmap_data user_data = { |
1330 | 1337 | .dim = &(albumart_slots[i].dim), | |
1338 | .embedded_albumart = NULL, | ||
1339 | }; | ||
1340 | if (embedded_albumart) | ||
1341 | { | ||
1342 | user_data.embedded_albumart = &(track_id3->albumart); | ||
1343 | aa_hid = bufopen(track_id3->path, 0, | ||
1344 | TYPE_BITMAP, &user_data); | ||
1345 | } | ||
1346 | else | ||
1347 | { | ||
1348 | aa_hid = bufopen(aa_path, 0, TYPE_BITMAP, | ||
1349 | &user_data); | ||
1350 | } | ||
1331 | if(aa_hid == ERR_BUFFER_FULL) | 1351 | if(aa_hid == ERR_BUFFER_FULL) |
1332 | { | 1352 | { |
1333 | filling = STATE_FULL; | 1353 | filling = STATE_FULL; |
@@ -1342,7 +1362,6 @@ static void audio_finish_load_track(void) | |||
1342 | tracks[track_widx].aa_hid[i] = aa_hid; | 1362 | tracks[track_widx].aa_hid[i] = aa_hid; |
1343 | } | 1363 | } |
1344 | } | 1364 | } |
1345 | |||
1346 | } | 1365 | } |
1347 | #endif | 1366 | #endif |
1348 | 1367 | ||