summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/flac.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/flac.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/flac.c')
-rw-r--r--lib/rbcodec/codecs/flac.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/rbcodec/codecs/flac.c b/lib/rbcodec/codecs/flac.c
index 3390c24a2c..eab6e7c2bc 100644
--- a/lib/rbcodec/codecs/flac.c
+++ b/lib/rbcodec/codecs/flac.c
@@ -468,7 +468,8 @@ enum codec_status codec_run(void)
468 return CODEC_ERROR; 468 return CODEC_ERROR;
469 } 469 }
470 470
471 /* Need to save offset for later use (cleared indirectly by flac_init) */ 471 /* Need to save resume for later use (cleared indirectly by flac_init) */
472 elapsedtime = ci->id3->elapsed;
472 samplesdone = ci->id3->offset; 473 samplesdone = ci->id3->offset;
473 474
474 if (!flac_init(&fc,ci->id3->first_frame_offset)) { 475 if (!flac_init(&fc,ci->id3->first_frame_offset)) {
@@ -481,9 +482,16 @@ enum codec_status codec_run(void)
481 STEREO_MONO : STEREO_NONINTERLEAVED); 482 STEREO_MONO : STEREO_NONINTERLEAVED);
482 codec_set_replaygain(ci->id3); 483 codec_set_replaygain(ci->id3);
483 484
484 flac_seek_offset(&fc, samplesdone); 485 if (samplesdone || !elapsedtime) {
485 samplesdone=fc.samplenumber+fc.blocksize; 486 flac_seek_offset(&fc, samplesdone);
486 elapsedtime=((uint64_t)samplesdone*1000)/(ci->id3->frequency); 487 samplesdone=fc.samplenumber+fc.blocksize;
488 elapsedtime=((uint64_t)samplesdone*1000)/(ci->id3->frequency);
489 }
490 else if (!flac_seek(&fc,(uint32_t)((uint64_t)elapsedtime
491 *ci->id3->frequency/1000))) {
492 elapsedtime = 0;
493 }
494
487 ci->set_elapsed(elapsedtime); 495 ci->set_elapsed(elapsedtime);
488 496
489 /* The main decoding loop */ 497 /* The main decoding loop */