diff options
author | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-15 06:46:05 +0000 |
---|---|---|
committer | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-15 06:46:05 +0000 |
commit | 5bb30c25fd9f8d1097c0434800f922541da2a1f8 (patch) | |
tree | 5ae3ca9cdb5fe1f9ccdcef9054321544259ded7c | |
parent | 13cc654ceace5ead037b6494813c79a73b0add3e (diff) | |
download | rockbox-5bb30c25fd9f8d1097c0434800f922541da2a1f8.tar.gz rockbox-5bb30c25fd9f8d1097c0434800f922541da2a1f8.zip |
Sort by and display disc number in PictureFlow, increase MAX_TRACKS to 128, prevent display of garbage tracklist on failure.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20940 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 73dca5a485..3d223f13a4 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c | |||
@@ -220,7 +220,7 @@ typedef fb_data pix_t; | |||
220 | 220 | ||
221 | /* maximum number of albums */ | 221 | /* maximum number of albums */ |
222 | 222 | ||
223 | #define MAX_TRACKS 50 | 223 | #define MAX_TRACKS 128 |
224 | #define AVG_TRACK_NAME_LENGTH 20 | 224 | #define AVG_TRACK_NAME_LENGTH 20 |
225 | 225 | ||
226 | 226 | ||
@@ -805,16 +805,26 @@ int create_track_index(const int slide_index) | |||
805 | rb->tagcache_search_add_filter(&tcs, tag_album, album[slide_index].seek); | 805 | rb->tagcache_search_add_filter(&tcs, tag_album, album[slide_index].seek); |
806 | track_count=0; | 806 | track_count=0; |
807 | int string_index = 0, i, track_num; | 807 | int string_index = 0, i, track_num; |
808 | int disc_num; | ||
808 | 809 | ||
809 | while (rb->tagcache_get_next(&tcs) && track_count < MAX_TRACKS) | 810 | while (rb->tagcache_get_next(&tcs)) |
810 | { | 811 | { |
812 | if (track_count == MAX_TRACKS) | ||
813 | goto fail; | ||
811 | track_num = rb->tagcache_get_numeric(&tcs, tag_tracknumber); | 814 | track_num = rb->tagcache_get_numeric(&tcs, tag_tracknumber); |
815 | disc_num = rb->tagcache_get_numeric(&tcs, tag_discnumber); | ||
812 | int avail = sizeof(track_names) - string_index; | 816 | int avail = sizeof(track_names) - string_index; |
813 | int len; | 817 | int len = 0; |
818 | if (disc_num < 0) | ||
819 | disc_num = 0; | ||
814 | if (track_num >= 0) | 820 | if (track_num >= 0) |
815 | { | 821 | { |
816 | len = 1 + rb->snprintf(track_names + string_index , avail, | 822 | if (disc_num > 0) |
817 | "%d: %s", track_num, tcs.result); | 823 | len = 1 + rb->snprintf(track_names + string_index , avail, |
824 | "%d.%02d: %s", disc_num, track_num, tcs.result); | ||
825 | else | ||
826 | len = 1 + rb->snprintf(track_names + string_index , avail, | ||
827 | "%d: %s", track_num, tcs.result); | ||
818 | } | 828 | } |
819 | else | 829 | else |
820 | { | 830 | { |
@@ -823,8 +833,9 @@ int create_track_index(const int slide_index) | |||
823 | rb->strncpy(track_names + string_index, tcs.result, avail); | 833 | rb->strncpy(track_names + string_index, tcs.result, avail); |
824 | } | 834 | } |
825 | if (len > avail) | 835 | if (len > avail) |
826 | return -1; | 836 | goto fail; |
827 | temp_tracknums[track_count] = (track_num << 8) + track_count; | 837 | temp_tracknums[track_count] = (disc_num << 16) + (track_num << 7) |
838 | + track_count; | ||
828 | temp_tracks[track_count].name_idx = string_index; | 839 | temp_tracks[track_count].name_idx = string_index; |
829 | temp_tracks[track_count].seek = tcs.result_seek; | 840 | temp_tracks[track_count].seek = tcs.result_seek; |
830 | track_count++; | 841 | track_count++; |
@@ -838,10 +849,16 @@ int create_track_index(const int slide_index) | |||
838 | rb->qsort(temp_tracknums, track_count, sizeof(int), compare_uints); | 849 | rb->qsort(temp_tracknums, track_count, sizeof(int), compare_uints); |
839 | for (i = 0; i < track_count; i++) | 850 | for (i = 0; i < track_count; i++) |
840 | { | 851 | { |
841 | tracks[i].name_idx = temp_tracks[0xFF & temp_tracknums[i]].name_idx; | 852 | track_num = 127 & temp_tracknums[i]; |
842 | tracks[i].seek = temp_tracks[0xFF & temp_tracknums[i]].seek; | 853 | tracks[i].name_idx = temp_tracks[track_num].name_idx; |
854 | tracks[i].seek = temp_tracks[track_num].seek; | ||
843 | } | 855 | } |
844 | return (track_count > 0) ? 0 : -1; | 856 | if (track_count == 0) |
857 | goto fail; | ||
858 | return 0; | ||
859 | fail: | ||
860 | track_count = 0; | ||
861 | return -1; | ||
845 | } | 862 | } |
846 | 863 | ||
847 | /** | 864 | /** |