From 839dbcaed7ea135dcc0812de76f9ff5c1dc924f5 Mon Sep 17 00:00:00 2001 From: Hardeep Sidhu Date: Mon, 4 Jul 2005 22:50:57 +0000 Subject: Moved resume info updating to the mpeg/playback threads so that it's saved even when not in the WPS git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7018 a1c6a512-1295-4272-9138-f99709370657 --- apps/playback.c | 8 ++++++++ apps/playlist.c | 25 +++++++++++++++++++++++++ apps/playlist.h | 2 ++ apps/wps.c | 16 ---------------- 4 files changed, 35 insertions(+), 16 deletions(-) (limited to 'apps') diff --git a/apps/playback.c b/apps/playback.c index 92ef340734..7565cbcdf5 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -1320,9 +1320,12 @@ void audio_thread(void) ci.seek_time = 0; pcm_crossfade_init(); audio_play_start((int)ev.data); + playlist_update_resume_info(audio_current_track()); break ; case AUDIO_STOP: + if (playing) + playlist_update_resume_info(audio_current_track()); audio_stop_playback(); break ; @@ -1342,6 +1345,7 @@ void audio_thread(void) case AUDIO_TRACK_CHANGED: if (track_changed_callback) track_changed_callback(cur_ti); + playlist_update_resume_info(audio_current_track()); break ; case AUDIO_CODEC_DONE: @@ -1357,6 +1361,10 @@ void audio_thread(void) usb_wait_for_disconnect(&audio_queue); break ; #endif + case SYS_TIMEOUT: + if (playing) + playlist_update_resume_info(audio_current_track()); + break; } } } diff --git a/apps/playlist.c b/apps/playlist.c index 304a511c37..91ca1f640a 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -2010,6 +2010,31 @@ int playlist_get_resume_info(int *resume_index) return 0; } +/* Update resume info for current playing song. Returns -1 on error. */ +int playlist_update_resume_info(const struct mp3entry* id3) +{ + struct playlist_info* playlist = ¤t_playlist; + + if (id3) + { + if (global_settings.resume_index != playlist->index || + global_settings.resume_offset != id3->offset) + { + global_settings.resume_index = playlist->index; + global_settings.resume_offset = id3->offset; + settings_save(); + } + } + else + { + global_settings.resume_index = -1; + global_settings.resume_offset = -1; + settings_save(); + } + + return 0; +} + /* Returns index of current playing track for display purposes. This value should not be used for resume purposes as it doesn't represent the actual index into the playlist */ diff --git a/apps/playlist.h b/apps/playlist.h index 5346cc8663..eee8bf5945 100644 --- a/apps/playlist.h +++ b/apps/playlist.h @@ -23,6 +23,7 @@ #include #include "file.h" #include "kernel.h" +#include "id3.h" /* playlist data */ @@ -79,6 +80,7 @@ bool playlist_check(int steps); char *playlist_peek(int steps); int playlist_next(int steps); int playlist_get_resume_info(int *resume_index); +int playlist_update_resume_info(const struct mp3entry* id3); int playlist_get_display_index(void); int playlist_amount(void); diff --git a/apps/wps.c b/apps/wps.c index e6d7036d6f..70af303bf0 100644 --- a/apps/wps.c +++ b/apps/wps.c @@ -250,22 +250,6 @@ static bool update(void) status_draw(false); - /* save resume data */ - if ( id3 && - (global_settings.resume_offset != id3->offset || track_changed)) { - - if (!playlist_get_resume_info(&global_settings.resume_index)) - { - global_settings.resume_offset = id3->offset; - settings_save(); - } - } - else if ( !id3 && track_changed ) { - global_settings.resume_index = -1; - global_settings.resume_offset = -1; - settings_save(); - } - return retcode; } -- cgit v1.2.3