summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/smaf.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 /lib/rbcodec/codecs/smaf.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 'lib/rbcodec/codecs/smaf.c')
-rw-r--r--lib/rbcodec/codecs/smaf.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/rbcodec/codecs/smaf.c b/lib/rbcodec/codecs/smaf.c
index d56aa0a860..e4ec6342b2 100644
--- a/lib/rbcodec/codecs/smaf.c
+++ b/lib/rbcodec/codecs/smaf.c
@@ -360,7 +360,8 @@ enum codec_status codec_run(void)
360 360
361 codec_set_replaygain(ci->id3); 361 codec_set_replaygain(ci->id3);
362 362
363 /* Need to save offset for later use (cleared indirectly by advance_buffer) */ 363 /* Need to save resume for later use (cleared indirectly by advance_buffer) */
364 param = ci->id3->elapsed;
364 bytesdone = ci->id3->offset; 365 bytesdone = ci->id3->offset;
365 366
366 decodedsamples = 0; 367 decodedsamples = 0;
@@ -408,11 +409,21 @@ enum codec_status codec_run(void)
408 ci->seek_buffer(firstblockposn); 409 ci->seek_buffer(firstblockposn);
409 410
410 /* make sure we're at the correct offset */ 411 /* make sure we're at the correct offset */
411 if (bytesdone > (uint32_t) firstblockposn) 412 if (bytesdone > (uint32_t) firstblockposn || param) {
412 { 413 uint32_t seek_val;
414 int seek_mode;
415
416 if (bytesdone) {
417 seek_val = bytesdone - MIN((uint32_t) firstblockposn, bytesdone);
418 seek_mode = PCM_SEEK_POS;
419 } else {
420 seek_val = param;
421 seek_mode = PCM_SEEK_TIME;
422 }
423
413 /* Round down to previous block */ 424 /* Round down to previous block */
414 struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, 425 struct pcm_pos *newpos = codec->get_seek_pos(seek_val, seek_mode,
415 PCM_SEEK_POS, &read_buffer); 426 &read_buffer);
416 427
417 if (newpos->pos > format.numbytes) 428 if (newpos->pos > format.numbytes)
418 return CODEC_OK; 429 return CODEC_OK;