1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Mohamed Tarek 2009-07-08 20:23:24 +00:00
parent 0a59e04b30
commit d259568831

View file

@ -86,56 +86,54 @@ next_track:
ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE);
/* The main decoder loop */ /* The main decoder loop */
while (1) seek_start :
{ while(packet_count)
/*if (ci->seek_time) { {
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);*/
ci->set_elapsed(ci->seek_time); for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++)
n = ci->seek_time/10; {
memset(buf,0,BUF_SIZE); ci->yield();
ci->seek_complete(); if (ci->stop_codec || ci->new_track)
}*/ goto done;
if (ci->seek_time == 1) {
while(packet_count) ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE);
{ ci->set_elapsed(0);
bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size); packet_count = rmctx.nb_packets;
consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt); rmctx.audio_pkt_cnt = 0;
if(consumed < 0) { rmctx.frame_number = 0;
DEBUGF("rm_get_packet failed\n"); 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; 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->pcmbuf_insert(outbuf, NULL, rmctx.samples_pf_pc / rmctx.nb_channels);
{ ci->set_elapsed(rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*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);
} }
goto done; packet_count -= rmctx.audio_pkt_cnt;
rmctx.audio_pkt_cnt = 0;
ci->advance_buffer(consumed);
} }
done : done :
if (ci->request_next_track()) if (ci->request_next_track())
goto next_track; goto next_track;