diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 73 |
1 files changed, 65 insertions, 8 deletions
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 538f7a8506..2ceef7c9cb 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c | |||
@@ -253,8 +253,9 @@ struct album_data { | |||
253 | 253 | ||
254 | struct track_data { | 254 | struct track_data { |
255 | uint32_t sort; | 255 | uint32_t sort; |
256 | int name_idx; | 256 | int name_idx; /* offset to the track name */ |
257 | long seek; | 257 | long seek; |
258 | int filename_idx; /* offset to the filename in the string */ | ||
258 | }; | 259 | }; |
259 | 260 | ||
260 | struct rect { | 261 | struct rect { |
@@ -758,6 +759,13 @@ char* get_track_name(const int track_index) | |||
758 | return 0; | 759 | return 0; |
759 | } | 760 | } |
760 | 761 | ||
762 | char* get_track_filename(const int track_index) | ||
763 | { | ||
764 | if ( track_index < track_count ) | ||
765 | return track_names + tracks[track_index].filename_idx; | ||
766 | return 0; | ||
767 | } | ||
768 | |||
761 | /** | 769 | /** |
762 | Compare two unsigned ints passed via pointers. | 770 | Compare two unsigned ints passed via pointers. |
763 | */ | 771 | */ |
@@ -791,28 +799,45 @@ void create_track_index(const int slide_index) | |||
791 | tracks = (struct track_data*)(track_names + borrowed); | 799 | tracks = (struct track_data*)(track_names + borrowed); |
792 | while (rb->tagcache_get_next(&tcs)) | 800 | while (rb->tagcache_get_next(&tcs)) |
793 | { | 801 | { |
802 | int len = 0, fn_idx = 0, remain; | ||
803 | |||
794 | avail -= sizeof(struct track_data); | 804 | avail -= sizeof(struct track_data); |
795 | track_num = rb->tagcache_get_numeric(&tcs, tag_tracknumber) - 1; | 805 | track_num = rb->tagcache_get_numeric(&tcs, tag_tracknumber) - 1; |
796 | disc_num = rb->tagcache_get_numeric(&tcs, tag_discnumber); | 806 | disc_num = rb->tagcache_get_numeric(&tcs, tag_discnumber); |
797 | int len = 0; | 807 | |
798 | if (disc_num < 0) | 808 | if (disc_num < 0) |
799 | disc_num = 0; | 809 | disc_num = 0; |
800 | retry: | 810 | retry: |
801 | if (track_num >= 0) | 811 | if (track_num >= 0) |
802 | { | 812 | { |
803 | if (disc_num) | 813 | if (disc_num) |
804 | len = 1 + rb->snprintf(track_names + string_index , avail, | 814 | fn_idx = 1 + rb->snprintf(track_names + string_index , avail, |
805 | "%d.%02d: %s", disc_num, track_num + 1, tcs.result); | 815 | "%d.%02d: %s", disc_num, track_num + 1, tcs.result); |
806 | else | 816 | else |
807 | len = 1 + rb->snprintf(track_names + string_index , avail, | 817 | fn_idx = 1 + rb->snprintf(track_names + string_index , avail, |
808 | "%d: %s", track_num + 1, tcs.result); | 818 | "%d: %s", track_num + 1, tcs.result); |
809 | } | 819 | } |
810 | else | 820 | else |
811 | { | 821 | { |
812 | track_num = 0; | 822 | track_num = 0; |
813 | len = tcs.result_len; | 823 | fn_idx = 1 + rb->snprintf(track_names + string_index, avail, |
814 | rb->strncpy(track_names + string_index, tcs.result, avail); | 824 | "%s", tcs.result); |
825 | } | ||
826 | if (fn_idx <= 0) | ||
827 | goto fail; | ||
828 | remain = avail - fn_idx; | ||
829 | if (remain >= MAX_PATH) | ||
830 | { /* retrieve filename for building the playlist */ | ||
831 | rb->tagcache_retrieve(&tcs, tcs.idx_id, tag_filename, | ||
832 | track_names + string_index + fn_idx, remain); | ||
833 | len = fn_idx + rb->strlen(track_names + string_index + fn_idx) + 1; | ||
834 | /* make sure track name and file name are really split by a \0, else | ||
835 | * get_track_name might fail */ | ||
836 | *(track_names + string_index + fn_idx -1) = '\0'; | ||
837 | |||
815 | } | 838 | } |
839 | else /* request more buffer so that track and filename fit */ | ||
840 | len = (avail - remain) + MAX_PATH; | ||
816 | if (len > avail) | 841 | if (len > avail) |
817 | { | 842 | { |
818 | while (len > avail) | 843 | while (len > avail) |
@@ -839,6 +864,7 @@ retry: | |||
839 | tracks->sort = ((disc_num - 1) << 24) + (track_num << 14) + track_count; | 864 | tracks->sort = ((disc_num - 1) << 24) + (track_num << 14) + track_count; |
840 | tracks->name_idx = string_index; | 865 | tracks->name_idx = string_index; |
841 | tracks->seek = tcs.result_seek; | 866 | tracks->seek = tcs.result_seek; |
867 | tracks->filename_idx = fn_idx + string_index; | ||
842 | track_count++; | 868 | track_count++; |
843 | string_index += len; | 869 | string_index += len; |
844 | } | 870 | } |
@@ -2297,6 +2323,34 @@ void select_prev_track(void) | |||
2297 | } | 2323 | } |
2298 | } | 2324 | } |
2299 | 2325 | ||
2326 | /* | ||
2327 | * Puts the current tracklist into a newly created playlist and starts playling | ||
2328 | */ | ||
2329 | void start_playback(void) | ||
2330 | { | ||
2331 | static int old_playlist = -1; | ||
2332 | if (center_slide.slide_index == old_playlist) | ||
2333 | { | ||
2334 | rb->playlist_start(selected_track, 0); | ||
2335 | } | ||
2336 | /* First, replace the current playlist with a new one */ | ||
2337 | else if ((rb->playlist_remove_all_tracks(NULL) == 0) && | ||
2338 | (rb->playlist_create(PLUGIN_DEMOS_DIR, NULL) == 0)) | ||
2339 | { | ||
2340 | int count = 0; | ||
2341 | do { | ||
2342 | if (rb->playlist_add(get_track_filename(count)) != 0) | ||
2343 | break; | ||
2344 | } while(++count < track_count); | ||
2345 | |||
2346 | rb->playlist_sync(NULL); | ||
2347 | |||
2348 | rb->playlist_start(selected_track, 0); | ||
2349 | } | ||
2350 | old_playlist = center_slide.slide_index; | ||
2351 | |||
2352 | } | ||
2353 | |||
2300 | /** | 2354 | /** |
2301 | Draw the current album name | 2355 | Draw the current album name |
2302 | */ | 2356 | */ |
@@ -2597,6 +2651,9 @@ int main(void) | |||
2597 | if ( pf_state == pf_idle ) { | 2651 | if ( pf_state == pf_idle ) { |
2598 | pf_state = pf_cover_in; | 2652 | pf_state = pf_cover_in; |
2599 | } | 2653 | } |
2654 | else if ( pf_state == pf_show_tracks ) { | ||
2655 | start_playback(); | ||
2656 | } | ||
2600 | break; | 2657 | break; |
2601 | 2658 | ||
2602 | default: | 2659 | default: |