summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/playback.c8
-rw-r--r--apps/playlist.c25
-rw-r--r--apps/playlist.h2
-rw-r--r--apps/wps.c16
-rw-r--r--firmware/mpeg.c19
5 files changed, 53 insertions, 17 deletions
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 = &current_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 <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);
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;
}
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 9e61e02e00..db8994c3bc 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -92,7 +92,7 @@ extern char* playlist_peek(int steps);
extern bool playlist_check(int steps);
extern int playlist_next(int steps);
extern int playlist_amount(void);
-extern void update_file_pos( int id, int pos );
+extern int playlist_update_resume_info(const struct mp3entry* id3);
/* list of tracks in memory */
#define MAX_TRACK_ENTRIES (1<<4) /* Must be power of 2 */
@@ -872,6 +872,8 @@ static void update_playlist(void)
if (playlist_next(playlist_amount()) < 0)
is_playing = false;
}
+
+ playlist_update_resume_info(audio_current_track());
}
static void track_change(void)
@@ -1036,6 +1038,11 @@ static void mpeg_thread(void)
{
queue_wait_w_tmo(&mpeg_queue, &ev, 0);
}
+ else if (playing)
+ {
+ /* periodically update resume info */
+ queue_wait_w_tmo(&mpeg_queue, &ev, HZ/2);
+ }
else
{
DEBUGF("S R:%x W:%x SW:%x\n",
@@ -1108,6 +1115,10 @@ static void mpeg_thread(void)
DEBUGF("MPEG_STOP\n");
is_playing = false;
paused = false;
+
+ if (playing)
+ playlist_update_resume_info(audio_current_track());
+
stop_playing();
mpeg_stop_done = true;
break;
@@ -1120,6 +1131,7 @@ static void mpeg_thread(void)
pause_tick = current_tick;
pause_track = current_track_counter;
mp3_play_pause(false);
+ playlist_update_resume_info(audio_current_track());
break;
case MPEG_RESUME:
@@ -1564,6 +1576,11 @@ static void mpeg_thread(void)
init_recording_done = true;
break;
#endif /* #if CONFIG_HWCODEC == MAS3587F */
+
+ case SYS_TIMEOUT:
+ if (playing)
+ playlist_update_resume_info(audio_current_track());
+ break;
}
#if CONFIG_HWCODEC == MAS3587F
}