diff options
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/playback.c | 8 | ||||
| -rw-r--r-- | apps/playlist.c | 25 | ||||
| -rw-r--r-- | apps/playlist.h | 2 | ||||
| -rw-r--r-- | apps/wps.c | 16 |
4 files changed, 35 insertions, 16 deletions
diff --git a/apps/playback.c b/apps/playback.c index 92ef340..7565cbc 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 304a511..91ca1f6 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 5346cc8..eee8bf5 100644 --- a/apps/playlist.h +++ b/apps/playlist.h @@ -23,6 +23,7 @@ #include <stdbool.h> #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); @@ -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; } |