diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-05-31 19:19:34 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-05-31 19:19:34 +0000 |
commit | de2d99a177ff440303f86da8d1db3b6c3d6c9b26 (patch) | |
tree | b32421aefa77c6f1b4e326d9b0ae1654042ebc97 /apps | |
parent | 9067c915ad4fb8104a0f44e340a915a11614b379 (diff) | |
download | rockbox-de2d99a177ff440303f86da8d1db3b6c3d6c9b26.tar.gz rockbox-de2d99a177ff440303f86da8d1db3b6c3d6c9b26.zip |
A bit more work on playback controlling pictureflow:
*) Fix that the generated playlist can't be resumed after reboot
*) make it work with shuffle
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21151 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugin.c | 2 | ||||
-rw-r--r-- | apps/plugin.h | 5 | ||||
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 37 |
3 files changed, 32 insertions, 12 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index 31990a9b00..eba2c28b33 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -655,6 +655,8 @@ static const struct plugin_api rockbox_api = { | |||
655 | playlist_sync, | 655 | playlist_sync, |
656 | playlist_remove_all_tracks, | 656 | playlist_remove_all_tracks, |
657 | playlist_create, | 657 | playlist_create, |
658 | playlist_insert_track, | ||
659 | playlist_shuffle, | ||
658 | }; | 660 | }; |
659 | 661 | ||
660 | int plugin_load(const char* plugin, const void* parameter) | 662 | int plugin_load(const char* plugin, const void* parameter) |
diff --git a/apps/plugin.h b/apps/plugin.h index 6f5a6940e7..6c2c903308 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -128,7 +128,7 @@ void* plugin_get_buffer(size_t *buffer_size); | |||
128 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 128 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
129 | 129 | ||
130 | /* increase this every time the api struct changes */ | 130 | /* increase this every time the api struct changes */ |
131 | #define PLUGIN_API_VERSION 154 | 131 | #define PLUGIN_API_VERSION 155 |
132 | 132 | ||
133 | /* update this to latest version if a change to the api struct breaks | 133 | /* update this to latest version if a change to the api struct breaks |
134 | backwards compatibility (and please take the opportunity to sort in any | 134 | backwards compatibility (and please take the opportunity to sort in any |
@@ -817,6 +817,9 @@ struct plugin_api { | |||
817 | void (*playlist_sync)(struct playlist_info* playlist); | 817 | void (*playlist_sync)(struct playlist_info* playlist); |
818 | int (*playlist_remove_all_tracks)(struct playlist_info *playlist); | 818 | int (*playlist_remove_all_tracks)(struct playlist_info *playlist); |
819 | int (*playlist_create)(const char *dir, const char *file); | 819 | int (*playlist_create)(const char *dir, const char *file); |
820 | int (*playlist_insert_track)(struct playlist_info* playlist, | ||
821 | const char *filename, int position, bool queue, bool sync); | ||
822 | int (*playlist_shuffle)(int random_seed, int start_index); | ||
820 | }; | 823 | }; |
821 | 824 | ||
822 | /* plugin header */ | 825 | /* plugin header */ |
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index de9859897c..cd8ef1a29f 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c | |||
@@ -2330,27 +2330,42 @@ void select_prev_track(void) | |||
2330 | */ | 2330 | */ |
2331 | void start_playback(void) | 2331 | void start_playback(void) |
2332 | { | 2332 | { |
2333 | static int old_playlist = -1; | 2333 | static int old_playlist = -1, old_shuffle = 0; |
2334 | if (center_slide.slide_index == old_playlist) | 2334 | int count = 0; |
2335 | int position = selected_track; | ||
2336 | int shuffle = rb->global_settings->playlist_shuffle; | ||
2337 | /* reuse existing playlist if possible | ||
2338 | * regenerate if shuffle is on or changed, since playlist index and | ||
2339 | * selected track are "out of sync" */ | ||
2340 | if (!shuffle && center_slide.slide_index == old_playlist | ||
2341 | && (old_shuffle == shuffle)) | ||
2335 | { | 2342 | { |
2336 | rb->playlist_start(selected_track, 0); | 2343 | goto play; |
2337 | } | 2344 | } |
2338 | /* First, replace the current playlist with a new one */ | 2345 | /* First, replace the current playlist with a new one */ |
2339 | else if ((rb->playlist_remove_all_tracks(NULL) == 0) && | 2346 | else if (rb->playlist_remove_all_tracks(NULL) == 0 |
2340 | (rb->playlist_create(PLUGIN_DEMOS_DIR, NULL) == 0)) | 2347 | && rb->playlist_create(NULL, NULL) == 0) |
2341 | { | 2348 | { |
2342 | int count = 0; | ||
2343 | do { | 2349 | do { |
2344 | if (rb->playlist_add(get_track_filename(count)) != 0) | 2350 | rb->yield(); |
2351 | if (rb->playlist_insert_track(NULL, get_track_filename(count), | ||
2352 | PLAYLIST_INSERT_LAST, false, true) < 0) | ||
2345 | break; | 2353 | break; |
2346 | } while(++count < track_count); | 2354 | } while(++count < track_count); |
2347 | |||
2348 | rb->playlist_sync(NULL); | 2355 | rb->playlist_sync(NULL); |
2349 | |||
2350 | rb->playlist_start(selected_track, 0); | ||
2351 | } | 2356 | } |
2357 | else | ||
2358 | return; | ||
2359 | |||
2360 | if (rb->global_settings->playlist_shuffle) | ||
2361 | position = rb->playlist_shuffle(*rb->current_tick, selected_track); | ||
2362 | play: | ||
2363 | /* TODO: can we adjust selected_track if !play_selected ? | ||
2364 | * if shuffle, we can't predict the playing track easily, and for either | ||
2365 | * case the track list doesn't get auto scrolled*/ | ||
2366 | rb->playlist_start(position, 0); | ||
2352 | old_playlist = center_slide.slide_index; | 2367 | old_playlist = center_slide.slide_index; |
2353 | 2368 | old_shuffle = shuffle; | |
2354 | } | 2369 | } |
2355 | 2370 | ||
2356 | /** | 2371 | /** |