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:
parent
0a59e04b30
commit
d259568831
1 changed files with 42 additions and 44 deletions
|
@ -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) {
|
||||
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);*/
|
||||
|
||||
ci->set_elapsed(ci->seek_time);
|
||||
n = ci->seek_time/10;
|
||||
memset(buf,0,BUF_SIZE);
|
||||
ci->seek_complete();
|
||||
}*/
|
||||
|
||||
while(packet_count)
|
||||
for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++)
|
||||
{
|
||||
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");
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue