diff options
Diffstat (limited to 'apps/codecs')
-rw-r--r-- | apps/codecs/a52_rm.c | 11 | ||||
-rw-r--r-- | apps/codecs/atrac3_rm.c | 12 | ||||
-rw-r--r-- | apps/codecs/cook.c | 10 | ||||
-rw-r--r-- | apps/codecs/raac.c | 10 |
4 files changed, 41 insertions, 2 deletions
diff --git a/apps/codecs/a52_rm.c b/apps/codecs/a52_rm.c index 32b66d2826..1fe7312e03 100644 --- a/apps/codecs/a52_rm.c +++ b/apps/codecs/a52_rm.c @@ -131,7 +131,8 @@ enum codec_status codec_main(void) size_t n; uint8_t *filebuf; int retval, consumed, packet_offset; - int playback_on = -1; + int playback_on = -1; + size_t resume_offset = ci->id3->offset; /* Generic codec initialisation */ ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); @@ -155,6 +156,14 @@ next_track: ci->memset(&pkt,0,sizeof(RMPacket)); init_rm(&rmctx); + /* check for a mid-track resume and force a seek time accordingly */ + if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { + resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; + /* put number of subpackets to skip in resume_offset */ + resume_offset /= (rmctx.block_align + PACKET_HEADER_SIZE); + ci->seek_time = (int)resume_offset * ((rmctx.block_align * 8 * 1000)/rmctx.bit_rate); + } + /* Seek to the first packet */ ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE ); diff --git a/apps/codecs/atrac3_rm.c b/apps/codecs/atrac3_rm.c index 75c0d1581b..d3e00c0e6f 100644 --- a/apps/codecs/atrac3_rm.c +++ b/apps/codecs/atrac3_rm.c @@ -45,6 +45,7 @@ enum codec_status codec_main(void) uint32_t packet_count; int scrambling_unit_size, num_units, elapsed = 0; int playback_on = -1; + size_t resume_offset = ci->id3->offset; next_track: if (codec_init()) { @@ -80,6 +81,15 @@ next_track: return CODEC_ERROR; } + /* check for a mid-track resume and force a seek time accordingly */ + if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { + resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; + num_units = (int)resume_offset / scrambling_unit_size; + /* put number of subpackets to skip in resume_offset */ + resume_offset /= (sps + PACKET_HEADER_SIZE); + ci->seek_time = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate); + } + ci->set_elapsed(0); ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); @@ -98,7 +108,7 @@ seek_start : else goto done; } - + for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++) { ci->yield(); diff --git a/apps/codecs/cook.c b/apps/codecs/cook.c index c9039a480c..5f91d244ff 100644 --- a/apps/codecs/cook.c +++ b/apps/codecs/cook.c @@ -45,6 +45,7 @@ enum codec_status codec_main(void) uint16_t fs,sps,h; uint32_t packet_count; int scrambling_unit_size, num_units; + size_t resume_offset = ci->id3->offset; next_track: if (codec_init()) { @@ -79,6 +80,15 @@ next_track: DEBUGF("failed to initialize cook decoder\n"); return CODEC_ERROR; } + + /* check for a mid-track resume and force a seek time accordingly */ + if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { + resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; + num_units = (int)resume_offset / scrambling_unit_size; + /* put number of subpackets to skip in resume_offset */ + resume_offset /= (sps + PACKET_HEADER_SIZE); + ci->seek_time = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate); + } ci->set_elapsed(0); ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); diff --git a/apps/codecs/raac.c b/apps/codecs/raac.c index b886136bd9..516828093d 100644 --- a/apps/codecs/raac.c +++ b/apps/codecs/raac.c @@ -48,6 +48,7 @@ enum codec_status codec_main(void) uint32_t s = 0; /* sample rate */ unsigned char c = 0; /* channels */ int playback_on = -1; + size_t resume_offset = ci->id3->offset; /* Generic codec initialisation */ ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); @@ -91,6 +92,15 @@ next_track: err = CODEC_ERROR; goto done; } + + /* check for a mid-track resume and force a seek time accordingly */ + if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { + resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; + /* put number of subpackets to skip in resume_offset */ + resume_offset /= (rmctx.block_align + PACKET_HEADER_SIZE); + ci->seek_time = (int)resume_offset * ((rmctx.block_align * 8 * 1000)/rmctx.bit_rate); + } + ci->id3->frequency = s; ci->set_elapsed(0); ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); |