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
This commit is contained in:
Thomas Martitz 2009-05-31 19:19:34 +00:00
parent 9067c915ad
commit de2d99a177
3 changed files with 32 additions and 12 deletions

View file

@ -655,6 +655,8 @@ static const struct plugin_api rockbox_api = {
playlist_sync, playlist_sync,
playlist_remove_all_tracks, playlist_remove_all_tracks,
playlist_create, playlist_create,
playlist_insert_track,
playlist_shuffle,
}; };
int plugin_load(const char* plugin, const void* parameter) int plugin_load(const char* plugin, const void* parameter)

View file

@ -128,7 +128,7 @@ void* plugin_get_buffer(size_t *buffer_size);
#define PLUGIN_MAGIC 0x526F634B /* RocK */ #define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */ /* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 154 #define PLUGIN_API_VERSION 155
/* update this to latest version if a change to the api struct breaks /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
@ -817,6 +817,9 @@ struct plugin_api {
void (*playlist_sync)(struct playlist_info* playlist); void (*playlist_sync)(struct playlist_info* playlist);
int (*playlist_remove_all_tracks)(struct playlist_info *playlist); int (*playlist_remove_all_tracks)(struct playlist_info *playlist);
int (*playlist_create)(const char *dir, const char *file); int (*playlist_create)(const char *dir, const char *file);
int (*playlist_insert_track)(struct playlist_info* playlist,
const char *filename, int position, bool queue, bool sync);
int (*playlist_shuffle)(int random_seed, int start_index);
}; };
/* plugin header */ /* plugin header */

View file

@ -2330,27 +2330,42 @@ void select_prev_track(void)
*/ */
void start_playback(void) void start_playback(void)
{ {
static int old_playlist = -1; static int old_playlist = -1, old_shuffle = 0;
if (center_slide.slide_index == old_playlist) int count = 0;
int position = selected_track;
int shuffle = rb->global_settings->playlist_shuffle;
/* reuse existing playlist if possible
* regenerate if shuffle is on or changed, since playlist index and
* selected track are "out of sync" */
if (!shuffle && center_slide.slide_index == old_playlist
&& (old_shuffle == shuffle))
{ {
rb->playlist_start(selected_track, 0); goto play;
} }
/* First, replace the current playlist with a new one */ /* First, replace the current playlist with a new one */
else if ((rb->playlist_remove_all_tracks(NULL) == 0) && else if (rb->playlist_remove_all_tracks(NULL) == 0
(rb->playlist_create(PLUGIN_DEMOS_DIR, NULL) == 0)) && rb->playlist_create(NULL, NULL) == 0)
{ {
int count = 0;
do { do {
if (rb->playlist_add(get_track_filename(count)) != 0) rb->yield();
if (rb->playlist_insert_track(NULL, get_track_filename(count),
PLAYLIST_INSERT_LAST, false, true) < 0)
break; break;
} while(++count < track_count); } while(++count < track_count);
rb->playlist_sync(NULL); rb->playlist_sync(NULL);
rb->playlist_start(selected_track, 0);
} }
else
return;
if (rb->global_settings->playlist_shuffle)
position = rb->playlist_shuffle(*rb->current_tick, selected_track);
play:
/* TODO: can we adjust selected_track if !play_selected ?
* if shuffle, we can't predict the playing track easily, and for either
* case the track list doesn't get auto scrolled*/
rb->playlist_start(position, 0);
old_playlist = center_slide.slide_index; old_playlist = center_slide.slide_index;
old_shuffle = shuffle;
} }
/** /**