summaryrefslogtreecommitdiff
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)
1320 ci.seek_time = 0; 1320 ci.seek_time = 0;
1321 pcm_crossfade_init(); 1321 pcm_crossfade_init();
1322 audio_play_start((int)ev.data); 1322 audio_play_start((int)ev.data);
1323 playlist_update_resume_info(audio_current_track());
1323 break ; 1324 break ;
1324 1325
1325 case AUDIO_STOP: 1326 case AUDIO_STOP:
1327 if (playing)
1328 playlist_update_resume_info(audio_current_track());
1326 audio_stop_playback(); 1329 audio_stop_playback();
1327 break ; 1330 break ;
1328 1331
@@ -1342,6 +1345,7 @@ void audio_thread(void)
1342 case AUDIO_TRACK_CHANGED: 1345 case AUDIO_TRACK_CHANGED:
1343 if (track_changed_callback) 1346 if (track_changed_callback)
1344 track_changed_callback(cur_ti); 1347 track_changed_callback(cur_ti);
1348 playlist_update_resume_info(audio_current_track());
1345 break ; 1349 break ;
1346 1350
1347 case AUDIO_CODEC_DONE: 1351 case AUDIO_CODEC_DONE:
@@ -1357,6 +1361,10 @@ void audio_thread(void)
1357 usb_wait_for_disconnect(&audio_queue); 1361 usb_wait_for_disconnect(&audio_queue);
1358 break ; 1362 break ;
1359#endif 1363#endif
1364 case SYS_TIMEOUT:
1365 if (playing)
1366 playlist_update_resume_info(audio_current_track());
1367 break;
1360 } 1368 }
1361 } 1369 }
1362} 1370}
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)
2010 return 0; 2010 return 0;
2011} 2011}
2012 2012
2013/* Update resume info for current playing song. Returns -1 on error. */
2014int playlist_update_resume_info(const struct mp3entry* id3)
2015{
2016 struct playlist_info* playlist = &current_playlist;
2017
2018 if (id3)
2019 {
2020 if (global_settings.resume_index != playlist->index ||
2021 global_settings.resume_offset != id3->offset)
2022 {
2023 global_settings.resume_index = playlist->index;
2024 global_settings.resume_offset = id3->offset;
2025 settings_save();
2026 }
2027 }
2028 else
2029 {
2030 global_settings.resume_index = -1;
2031 global_settings.resume_offset = -1;
2032 settings_save();
2033 }
2034
2035 return 0;
2036}
2037
2013/* Returns index of current playing track for display purposes. This value 2038/* Returns index of current playing track for display purposes. This value
2014 should not be used for resume purposes as it doesn't represent the actual 2039 should not be used for resume purposes as it doesn't represent the actual
2015 index into the playlist */ 2040 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 @@
23#include <stdbool.h> 23#include <stdbool.h>
24#include "file.h" 24#include "file.h"
25#include "kernel.h" 25#include "kernel.h"
26#include "id3.h"
26 27
27/* playlist data */ 28/* playlist data */
28 29
@@ -79,6 +80,7 @@ bool playlist_check(int steps);
79char *playlist_peek(int steps); 80char *playlist_peek(int steps);
80int playlist_next(int steps); 81int playlist_next(int steps);
81int playlist_get_resume_info(int *resume_index); 82int playlist_get_resume_info(int *resume_index);
83int playlist_update_resume_info(const struct mp3entry* id3);
82int playlist_get_display_index(void); 84int playlist_get_display_index(void);
83int playlist_amount(void); 85int playlist_amount(void);
84 86
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)
250 250
251 status_draw(false); 251 status_draw(false);
252 252
253 /* save resume data */
254 if ( id3 &&
255 (global_settings.resume_offset != id3->offset || track_changed)) {
256
257 if (!playlist_get_resume_info(&global_settings.resume_index))
258 {
259 global_settings.resume_offset = id3->offset;
260 settings_save();
261 }
262 }
263 else if ( !id3 && track_changed ) {
264 global_settings.resume_index = -1;
265 global_settings.resume_offset = -1;
266 settings_save();
267 }
268
269 return retcode; 253 return retcode;
270} 254}
271 255
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);
92extern bool playlist_check(int steps); 92extern bool playlist_check(int steps);
93extern int playlist_next(int steps); 93extern int playlist_next(int steps);
94extern int playlist_amount(void); 94extern int playlist_amount(void);
95extern void update_file_pos( int id, int pos ); 95extern int playlist_update_resume_info(const struct mp3entry* id3);
96 96
97/* list of tracks in memory */ 97/* list of tracks in memory */
98#define MAX_TRACK_ENTRIES (1<<4) /* Must be power of 2 */ 98#define MAX_TRACK_ENTRIES (1<<4) /* Must be power of 2 */
@@ -872,6 +872,8 @@ static void update_playlist(void)
872 if (playlist_next(playlist_amount()) < 0) 872 if (playlist_next(playlist_amount()) < 0)
873 is_playing = false; 873 is_playing = false;
874 } 874 }
875
876 playlist_update_resume_info(audio_current_track());
875} 877}
876 878
877static void track_change(void) 879static void track_change(void)
@@ -1036,6 +1038,11 @@ static void mpeg_thread(void)
1036 { 1038 {
1037 queue_wait_w_tmo(&mpeg_queue, &ev, 0); 1039 queue_wait_w_tmo(&mpeg_queue, &ev, 0);
1038 } 1040 }
1041 else if (playing)
1042 {
1043 /* periodically update resume info */
1044 queue_wait_w_tmo(&mpeg_queue, &ev, HZ/2);
1045 }
1039 else 1046 else
1040 { 1047 {
1041 DEBUGF("S R:%x W:%x SW:%x\n", 1048 DEBUGF("S R:%x W:%x SW:%x\n",
@@ -1108,6 +1115,10 @@ static void mpeg_thread(void)
1108 DEBUGF("MPEG_STOP\n"); 1115 DEBUGF("MPEG_STOP\n");
1109 is_playing = false; 1116 is_playing = false;
1110 paused = false; 1117 paused = false;
1118
1119 if (playing)
1120 playlist_update_resume_info(audio_current_track());
1121
1111 stop_playing(); 1122 stop_playing();
1112 mpeg_stop_done = true; 1123 mpeg_stop_done = true;
1113 break; 1124 break;
@@ -1120,6 +1131,7 @@ static void mpeg_thread(void)
1120 pause_tick = current_tick; 1131 pause_tick = current_tick;
1121 pause_track = current_track_counter; 1132 pause_track = current_track_counter;
1122 mp3_play_pause(false); 1133 mp3_play_pause(false);
1134 playlist_update_resume_info(audio_current_track());
1123 break; 1135 break;
1124 1136
1125 case MPEG_RESUME: 1137 case MPEG_RESUME:
@@ -1564,6 +1576,11 @@ static void mpeg_thread(void)
1564 init_recording_done = true; 1576 init_recording_done = true;
1565 break; 1577 break;
1566#endif /* #if CONFIG_HWCODEC == MAS3587F */ 1578#endif /* #if CONFIG_HWCODEC == MAS3587F */
1579
1580 case SYS_TIMEOUT:
1581 if (playing)
1582 playlist_update_resume_info(audio_current_track());
1583 break;
1567 } 1584 }
1568#if CONFIG_HWCODEC == MAS3587F 1585#if CONFIG_HWCODEC == MAS3587F
1569 } 1586 }