summaryrefslogtreecommitdiffstats
path: root/apps/playlist.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-07-14 07:59:39 -0400
committerMichael Sevakis <jethead71@rockbox.org>2014-03-10 04:12:30 +0100
commit31b712286721dd606940c7b557d03e3f714b9604 (patch)
tree8c4a4cc32e9000ea721ebb23aa3c0129ca97bf53 /apps/playlist.c
parentdda54b85daa83b7803b4fb189ab45859f96ff3f9 (diff)
downloadrockbox-31b712286721dd606940c7b557d03e3f714b9604.tar.gz
rockbox-31b712286721dd606940c7b557d03e3f714b9604.zip
Implement time-based resume and playback start.
This complements offset-based resume and playback start funcionality. The implementation is global on both HWCODEC and SWCODEC. Basically, if either the specified elapsed or offset are non-zero, it indicates a mid-track resume. To resume by time only, set elapsed to nonzero and offset to zero. To resume by offset only, set offset to nonzero and elapsed to zero. Which one the codec uses and which has priority is up to the codec; however, using an elapsed time covers more cases: * Codecs not able to use an offset such as VGM or other atomic formats * Starting playback at a nonzero elapsed time from a source that contains no offset, such as a cuesheet The change re-versions pretty much everything from tagcache to nvram. Change-Id: Ic7aebb24e99a03ae99585c5e236eba960d163f38 Reviewed-on: http://gerrit.rockbox.org/516 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested: Michael Sevakis <jethead71@rockbox.org>
Diffstat (limited to 'apps/playlist.c')
-rwxr-xr-xapps/playlist.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 9c895bfd67..0e73781238 100755
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -621,7 +621,7 @@ static int create_and_play_dir(int direction, bool play_last)
#if (CONFIG_CODEC == SWCODEC)
current_playlist.started = true;
#else
- playlist_start(index, 0);
+ playlist_start(index, 0, 0);
#endif
}
@@ -2565,7 +2565,8 @@ unsigned int playlist_get_filename_crc32(struct playlist_info *playlist,
}
/* resume a playlist track with the given crc_32 of the track name. */
-void playlist_resume_track(int start_index, unsigned int crc, int offset)
+void playlist_resume_track(int start_index, unsigned int crc,
+ unsigned long elapsed, unsigned long offset)
{
int i;
unsigned int tmp_crc;
@@ -2573,7 +2574,7 @@ void playlist_resume_track(int start_index, unsigned int crc, int offset)
tmp_crc = playlist_get_filename_crc32(playlist, start_index);
if (tmp_crc == crc)
{
- playlist_start(start_index, offset);
+ playlist_start(start_index, elapsed, offset);
return;
}
@@ -2582,17 +2583,18 @@ void playlist_resume_track(int start_index, unsigned int crc, int offset)
tmp_crc = playlist_get_filename_crc32(playlist, i);
if (tmp_crc == crc)
{
- playlist_start(i, offset);
+ playlist_start(i, elapsed, offset);
return;
}
}
/* If we got here the file wasnt found, so start from the beginning */
- playlist_start(0,0);
+ playlist_start(0, 0, 0);
}
/* start playing current playlist at specified index/offset */
-void playlist_start(int start_index, int offset)
+void playlist_start(int start_index, unsigned long elapsed,
+ unsigned long offset)
{
struct playlist_info* playlist = &current_playlist;
@@ -2605,7 +2607,7 @@ void playlist_start(int start_index, int offset)
playlist->started = true;
sync_control(playlist, false);
- audio_play(offset);
+ audio_play(elapsed, offset);
}
/* Returns false if 'steps' is out of bounds, else true */
@@ -2723,7 +2725,7 @@ int playlist_next(int steps)
#if CONFIG_CODEC == SWCODEC
playlist->started = true;
#else
- playlist_start(0, 0);
+ playlist_start(0, 0, 0);
#endif
playlist->index = 0;
index = 0;
@@ -2801,11 +2803,13 @@ int playlist_update_resume_info(const struct mp3entry* id3)
if (id3)
{
if (global_status.resume_index != playlist->index ||
+ global_status.resume_elapsed != id3->elapsed ||
global_status.resume_offset != id3->offset)
{
unsigned int crc = crc_32(id3->path, strlen(id3->path), -1);
global_status.resume_index = playlist->index;
global_status.resume_crc32 = crc;
+ global_status.resume_elapsed = id3->elapsed;
global_status.resume_offset = id3->offset;
status_save();
}
@@ -2814,6 +2818,7 @@ int playlist_update_resume_info(const struct mp3entry* id3)
{
global_status.resume_index = -1;
global_status.resume_crc32 = -1;
+ global_status.resume_elapsed = -1;
global_status.resume_offset = -1;
status_save();
}