summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMohamed Tarek <mt@rockbox.org>2009-07-08 20:23:24 +0000
committerMohamed Tarek <mt@rockbox.org>2009-07-08 20:23:24 +0000
commitd2595688319fefe8e6af2b6fb25b7bd4ba4a87a2 (patch)
tree5fead8ae0c5c343726dacb3b1cd945bd03b14556 /apps
parent0a59e04b307f7a5f86724173095ce493d1958774 (diff)
downloadrockbox-d2595688319fefe8e6af2b6fb25b7bd4ba4a87a2.zip
rockbox-d2595688319fefe8e6af2b6fb25b7bd4ba4a87a2.tar.gz
rockbox-d2595688319fefe8e6af2b6fb25b7bd4ba4a87a2.tar.bz2
rockbox-d2595688319fefe8e6af2b6fb25b7bd4ba4a87a2.tar.xz
Add the ability to seek to the start of the track.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21728 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs/cook.c90
1 files changed, 44 insertions, 46 deletions
diff --git a/apps/codecs/cook.c b/apps/codecs/cook.c
index 451fe34..b23e523 100644
--- a/apps/codecs/cook.c
+++ b/apps/codecs/cook.c
@@ -86,56 +86,54 @@ next_track:
ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE);
/* The main decoder loop */
- while (1)
- {
- /*if (ci->seek_time) {
-
- ci->set_elapsed(ci->seek_time);
- n = ci->seek_time/10;
- memset(buf,0,BUF_SIZE);
- ci->seek_complete();
- }*/
-
- while(packet_count)
- {
- bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size);
- consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt);
- if(consumed < 0) {
- DEBUGF("rm_get_packet failed\n");
+seek_start :
+ while(packet_count)
+ {
+ bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size);
+ consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt);
+ if(consumed < 0) {
+ DEBUGF("rm_get_packet failed\n");
+ return CODEC_ERROR;
+ }
+ /*DEBUGF(" version = %d\n"
+ " length = %d\n"
+ " stream = %d\n"
+ " timestamp= %d\n",pkt.version,pkt.length,pkt.stream_number,pkt.timestamp);*/
+
+ for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++)
+ {
+ ci->yield();
+ if (ci->stop_codec || ci->new_track)
+ goto done;
+ if (ci->seek_time == 1) {
+ ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE);
+ ci->set_elapsed(0);
+ packet_count = rmctx.nb_packets;
+ rmctx.audio_pkt_cnt = 0;
+ rmctx.frame_number = 0;
+ ci->seek_complete();
+ goto seek_start;
+ }
+
+ res = cook_decode_frame(&rmctx,&q, outbuf, &datasize, pkt.frames[i], rmctx.block_align);
+ rmctx.frame_number++;
+
+ /* skip the first two frames; no valid audio */
+ if(rmctx.frame_number < 3) continue;
+
+ if(res != rmctx.block_align) {
+ DEBUGF("codec error\n");
return CODEC_ERROR;
}
- /*DEBUGF(" version = %d\n"
- " length = %d\n"
- " stream = %d\n"
- " timestamp= %d\n",pkt.version,pkt.length,pkt.stream_number,pkt.timestamp);*/
-
- for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++)
- {
- ci->yield();
- if (ci->stop_codec || ci->new_track)
- goto done;
-
- res = cook_decode_frame(&rmctx,&q, outbuf, &datasize, pkt.frames[i], rmctx.block_align);
- rmctx.frame_number++;
-
- /* skip the first two frames; no valid audio */
- if(rmctx.frame_number < 3) continue;
-
- if(res != rmctx.block_align) {
- DEBUGF("codec error\n");
- return CODEC_ERROR;
- }
-
- ci->pcmbuf_insert(outbuf, NULL, rmctx.samples_pf_pc / rmctx.nb_channels);
- ci->set_elapsed(rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i);
- }
- packet_count -= rmctx.audio_pkt_cnt;
- rmctx.audio_pkt_cnt = 0;
- ci->advance_buffer(consumed);
+
+ ci->pcmbuf_insert(outbuf, NULL, rmctx.samples_pf_pc / rmctx.nb_channels);
+ ci->set_elapsed(rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i);
}
- goto done;
-
+ packet_count -= rmctx.audio_pkt_cnt;
+ rmctx.audio_pkt_cnt = 0;
+ ci->advance_buffer(consumed);
}
+
done :
if (ci->request_next_track())
goto next_track;