From 31b712286721dd606940c7b557d03e3f714b9604 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 14 Jul 2013 07:59:39 -0400 Subject: 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 Tested: Michael Sevakis --- lib/rbcodec/codecs/vox.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'lib/rbcodec/codecs/vox.c') diff --git a/lib/rbcodec/codecs/vox.c b/lib/rbcodec/codecs/vox.c index 66979e2911..d84af24cfc 100644 --- a/lib/rbcodec/codecs/vox.c +++ b/lib/rbcodec/codecs/vox.c @@ -73,7 +73,8 @@ enum codec_status codec_run(void) codec_set_replaygain(ci->id3); - /* Need to save offset for later use (cleared indirectly by advance_buffer) */ + /* Need to save resume for later use (cleared indirectly by advance_buffer) */ + param = ci->id3->elapsed; bytesdone = ci->id3->offset; ci->seek_buffer(0); @@ -123,10 +124,21 @@ enum codec_status codec_run(void) ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); /* make sure we're at the correct offset */ - if (bytesdone > (uint32_t) firstblockposn) { + if (bytesdone > (uint32_t) firstblockposn || param) { + uint32_t seek_val; + int seek_mode; + + if (bytesdone) { + seek_val = bytesdone - MIN((uint32_t )firstblockposn, bytesdone); + seek_mode = PCM_SEEK_POS; + } else { + seek_val = param; + seek_mode = PCM_SEEK_TIME; + } + /* Round down to previous block */ - struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, - PCM_SEEK_POS, &read_buffer); + struct pcm_pos *newpos = codec->get_seek_pos(seek_val, seek_mode, + &read_buffer); if (newpos->pos > format.numbytes) { return CODEC_OK; -- cgit v1.2.3