summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-05-31 14:40:25 +0000
committerThomas Martitz <kugel@rockbox.org>2009-05-31 14:40:25 +0000
commit8b8768bfff48d148795b1579d330461abd99b980 (patch)
tree61cd727fe427c14f8d060db36c252186899e7126 /apps
parentf0aa8ba95d8171ebe73919078da91834605dd561 (diff)
downloadrockbox-8b8768bfff48d148795b1579d330461abd99b980.tar.gz
rockbox-8b8768bfff48d148795b1579d330461abd99b980.zip
Commit the first part of FS#10263: Starting playback from within pictureflow, by creating a playlist from the tracklist and playing it. The database integration part is postponed until it's more featured.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21143 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugin.c6
-rw-r--r--apps/plugin.h4
-rw-r--r--apps/plugins/pictureflow/pictureflow.c73
3 files changed, 74 insertions, 9 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index dfdcb01b19..31990a9b00 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -649,8 +649,12 @@ static const struct plugin_api rockbox_api = {
649 action_get_touchscreen_press, 649 action_get_touchscreen_press,
650#endif 650#endif
651#if defined(HAVE_TAGCACHE) && defined(HAVE_TC_RAMCACHE) 651#if defined(HAVE_TAGCACHE) && defined(HAVE_TC_RAMCACHE)
652 tagcache_fill_tags 652 tagcache_fill_tags,
653#endif 653#endif
654 playlist_add,
655 playlist_sync,
656 playlist_remove_all_tracks,
657 playlist_create,
654}; 658};
655 659
656int plugin_load(const char* plugin, const void* parameter) 660int plugin_load(const char* plugin, const void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index 3346a76e43..84501aca07 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -813,6 +813,10 @@ struct plugin_api {
813#if defined(HAVE_TAGCACHE) && defined(HAVE_TC_RAMCACHE) 813#if defined(HAVE_TAGCACHE) && defined(HAVE_TC_RAMCACHE)
814 bool (*tagcache_fill_tags)(struct mp3entry *id3, const char *filename); 814 bool (*tagcache_fill_tags)(struct mp3entry *id3, const char *filename);
815#endif 815#endif
816 int (*playlist_add)(const char *filename);
817 void (*playlist_sync)(struct playlist_info* playlist);
818 int (*playlist_remove_all_tracks)(struct playlist_info *playlist);
819 int (*playlist_create)(const char *dir, const char *file);
816}; 820};
817 821
818/* plugin header */ 822/* plugin header */
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
254struct track_data { 254struct 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
260struct rect { 261struct rect {
@@ -758,6 +759,13 @@ char* get_track_name(const int track_index)
758 return 0; 759 return 0;
759} 760}
760 761
762char* 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;
800retry: 810retry:
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 */
2329void 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: