forked from len0rd/rockbox
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
This commit is contained in:
parent
3fd775b7d1
commit
839dbcaed7
5 changed files with 53 additions and 17 deletions
|
@ -1320,9 +1320,12 @@ void audio_thread(void)
|
||||||
ci.seek_time = 0;
|
ci.seek_time = 0;
|
||||||
pcm_crossfade_init();
|
pcm_crossfade_init();
|
||||||
audio_play_start((int)ev.data);
|
audio_play_start((int)ev.data);
|
||||||
|
playlist_update_resume_info(audio_current_track());
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case AUDIO_STOP:
|
case AUDIO_STOP:
|
||||||
|
if (playing)
|
||||||
|
playlist_update_resume_info(audio_current_track());
|
||||||
audio_stop_playback();
|
audio_stop_playback();
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
|
@ -1342,6 +1345,7 @@ void audio_thread(void)
|
||||||
case AUDIO_TRACK_CHANGED:
|
case AUDIO_TRACK_CHANGED:
|
||||||
if (track_changed_callback)
|
if (track_changed_callback)
|
||||||
track_changed_callback(cur_ti);
|
track_changed_callback(cur_ti);
|
||||||
|
playlist_update_resume_info(audio_current_track());
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case AUDIO_CODEC_DONE:
|
case AUDIO_CODEC_DONE:
|
||||||
|
@ -1357,6 +1361,10 @@ void audio_thread(void)
|
||||||
usb_wait_for_disconnect(&audio_queue);
|
usb_wait_for_disconnect(&audio_queue);
|
||||||
break ;
|
break ;
|
||||||
#endif
|
#endif
|
||||||
|
case SYS_TIMEOUT:
|
||||||
|
if (playing)
|
||||||
|
playlist_update_resume_info(audio_current_track());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2010,6 +2010,31 @@ int playlist_get_resume_info(int *resume_index)
|
||||||
return 0;
|
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
|
/* 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
|
should not be used for resume purposes as it doesn't represent the actual
|
||||||
index into the playlist */
|
index into the playlist */
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
#include "id3.h"
|
||||||
|
|
||||||
/* playlist data */
|
/* playlist data */
|
||||||
|
|
||||||
|
@ -79,6 +80,7 @@ bool playlist_check(int steps);
|
||||||
char *playlist_peek(int steps);
|
char *playlist_peek(int steps);
|
||||||
int playlist_next(int steps);
|
int playlist_next(int steps);
|
||||||
int playlist_get_resume_info(int *resume_index);
|
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_get_display_index(void);
|
||||||
int playlist_amount(void);
|
int playlist_amount(void);
|
||||||
|
|
||||||
|
|
16
apps/wps.c
16
apps/wps.c
|
@ -250,22 +250,6 @@ static bool update(void)
|
||||||
|
|
||||||
status_draw(false);
|
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;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ extern char* playlist_peek(int steps);
|
||||||
extern bool playlist_check(int steps);
|
extern bool playlist_check(int steps);
|
||||||
extern int playlist_next(int steps);
|
extern int playlist_next(int steps);
|
||||||
extern int playlist_amount(void);
|
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 */
|
/* list of tracks in memory */
|
||||||
#define MAX_TRACK_ENTRIES (1<<4) /* Must be power of 2 */
|
#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)
|
if (playlist_next(playlist_amount()) < 0)
|
||||||
is_playing = false;
|
is_playing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playlist_update_resume_info(audio_current_track());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void track_change(void)
|
static void track_change(void)
|
||||||
|
@ -1036,6 +1038,11 @@ static void mpeg_thread(void)
|
||||||
{
|
{
|
||||||
queue_wait_w_tmo(&mpeg_queue, &ev, 0);
|
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
|
else
|
||||||
{
|
{
|
||||||
DEBUGF("S R:%x W:%x SW:%x\n",
|
DEBUGF("S R:%x W:%x SW:%x\n",
|
||||||
|
@ -1108,6 +1115,10 @@ static void mpeg_thread(void)
|
||||||
DEBUGF("MPEG_STOP\n");
|
DEBUGF("MPEG_STOP\n");
|
||||||
is_playing = false;
|
is_playing = false;
|
||||||
paused = false;
|
paused = false;
|
||||||
|
|
||||||
|
if (playing)
|
||||||
|
playlist_update_resume_info(audio_current_track());
|
||||||
|
|
||||||
stop_playing();
|
stop_playing();
|
||||||
mpeg_stop_done = true;
|
mpeg_stop_done = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1120,6 +1131,7 @@ static void mpeg_thread(void)
|
||||||
pause_tick = current_tick;
|
pause_tick = current_tick;
|
||||||
pause_track = current_track_counter;
|
pause_track = current_track_counter;
|
||||||
mp3_play_pause(false);
|
mp3_play_pause(false);
|
||||||
|
playlist_update_resume_info(audio_current_track());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MPEG_RESUME:
|
case MPEG_RESUME:
|
||||||
|
@ -1564,6 +1576,11 @@ static void mpeg_thread(void)
|
||||||
init_recording_done = true;
|
init_recording_done = true;
|
||||||
break;
|
break;
|
||||||
#endif /* #if CONFIG_HWCODEC == MAS3587F */
|
#endif /* #if CONFIG_HWCODEC == MAS3587F */
|
||||||
|
|
||||||
|
case SYS_TIMEOUT:
|
||||||
|
if (playing)
|
||||||
|
playlist_update_resume_info(audio_current_track());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#if CONFIG_HWCODEC == MAS3587F
|
#if CONFIG_HWCODEC == MAS3587F
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue