forked from len0rd/rockbox
Smarter check for failed packet parsing in RM. Also fixes a bug in playback where sometimes "codec failure" is splashed at the end of playback.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22880 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8d5acd64c9
commit
f0c6c88f6d
3 changed files with 56 additions and 18 deletions
|
|
@ -131,6 +131,7 @@ enum codec_status codec_main(void)
|
||||||
size_t n;
|
size_t n;
|
||||||
uint8_t *filebuf;
|
uint8_t *filebuf;
|
||||||
int retval, consumed, packet_offset;
|
int retval, consumed, packet_offset;
|
||||||
|
int playback_on = -1;
|
||||||
|
|
||||||
/* Generic codec initialisation */
|
/* Generic codec initialisation */
|
||||||
ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED);
|
ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED);
|
||||||
|
|
@ -173,10 +174,20 @@ next_track:
|
||||||
|
|
||||||
filebuf = ci->request_buffer(&n, rmctx.block_align + PACKET_HEADER_SIZE);
|
filebuf = ci->request_buffer(&n, rmctx.block_align + PACKET_HEADER_SIZE);
|
||||||
consumed = rm_get_packet(&filebuf, &rmctx, &pkt);
|
consumed = rm_get_packet(&filebuf, &rmctx, &pkt);
|
||||||
if(consumed < 0) {
|
|
||||||
DEBUGF("rm_get_packet failed\n");
|
if(consumed < 0 && playback_on != 0) {
|
||||||
return CODEC_ERROR;
|
if(playback_on == -1) {
|
||||||
|
/* Error only if packet-parsing failed and playback hadn't started */
|
||||||
|
DEBUGF("rm_get_packet failed\n");
|
||||||
|
return CODEC_ERROR;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retval = CODEC_OK;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playback_on = 1;
|
||||||
a52_decode_data(filebuf, filebuf + rmctx.block_align);
|
a52_decode_data(filebuf, filebuf + rmctx.block_align);
|
||||||
ci->advance_buffer(pkt.length);
|
ci->advance_buffer(pkt.length);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ enum codec_status codec_main(void)
|
||||||
uint16_t fs,sps,h;
|
uint16_t fs,sps,h;
|
||||||
uint32_t packet_count;
|
uint32_t packet_count;
|
||||||
int scrambling_unit_size, num_units, elapsed = 0;
|
int scrambling_unit_size, num_units, elapsed = 0;
|
||||||
|
int playback_on = -1;
|
||||||
|
|
||||||
next_track:
|
next_track:
|
||||||
if (codec_init()) {
|
if (codec_init()) {
|
||||||
|
|
@ -88,9 +89,14 @@ seek_start :
|
||||||
{
|
{
|
||||||
bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size);
|
bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size);
|
||||||
consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt);
|
consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt);
|
||||||
if(consumed < 0) {
|
if(consumed < 0 && playback_on != 0) {
|
||||||
DEBUGF("rm_get_packet failed\n");
|
if(playback_on == -1) {
|
||||||
return CODEC_ERROR;
|
/* Error only if packet-parsing failed and playback hadn't started */
|
||||||
|
DEBUGF("rm_get_packet failed\n");
|
||||||
|
return CODEC_ERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++)
|
for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++)
|
||||||
|
|
@ -123,10 +129,16 @@ seek_start :
|
||||||
ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE + consumed * num_units);
|
ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE + consumed * num_units);
|
||||||
bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size);
|
bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size);
|
||||||
consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt);
|
consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt);
|
||||||
if(consumed < 0) {
|
if(consumed < 0 && playback_on != 0) {
|
||||||
DEBUGF("rm_get_packet failed\n");
|
if(playback_on == -1) {
|
||||||
return CODEC_ERROR;
|
/* Error only if packet-parsing failed and playback hadn't started */
|
||||||
|
DEBUGF("rm_get_packet failed\n");
|
||||||
|
return CODEC_ERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet_count = rmctx.nb_packets - rmctx.audio_pkt_cnt * num_units;
|
packet_count = rmctx.nb_packets - rmctx.audio_pkt_cnt * num_units;
|
||||||
rmctx.frame_number = ((ci->seek_time)/(sps*1000*8/rmctx.bit_rate));
|
rmctx.frame_number = ((ci->seek_time)/(sps*1000*8/rmctx.bit_rate));
|
||||||
while(rmctx.audiotimestamp > (unsigned) ci->seek_time) {
|
while(rmctx.audiotimestamp > (unsigned) ci->seek_time) {
|
||||||
|
|
@ -155,6 +167,7 @@ seek_start :
|
||||||
|
|
||||||
if(datasize)
|
if(datasize)
|
||||||
ci->pcmbuf_insert(q.outSamples, q.outSamples + 1024, q.samples_per_frame / rmctx.nb_channels);
|
ci->pcmbuf_insert(q.outSamples, q.outSamples + 1024, q.samples_per_frame / rmctx.nb_channels);
|
||||||
|
playback_on = 1;
|
||||||
elapsed = rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i;
|
elapsed = rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i;
|
||||||
ci->set_elapsed(elapsed);
|
ci->set_elapsed(elapsed);
|
||||||
rmctx.frame_number++;
|
rmctx.frame_number++;
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,8 @@ enum codec_status codec_main(void)
|
||||||
int err, consumed, pkt_offset, skipped = 0;
|
int err, consumed, pkt_offset, skipped = 0;
|
||||||
uint32_t s = 0; /* sample rate */
|
uint32_t s = 0; /* sample rate */
|
||||||
unsigned char c = 0; /* channels */
|
unsigned char c = 0; /* channels */
|
||||||
|
int playback_on = -1;
|
||||||
|
|
||||||
/* Generic codec initialisation */
|
/* Generic codec initialisation */
|
||||||
ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED);
|
ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED);
|
||||||
ci->configure(DSP_SET_SAMPLE_DEPTH, 16);
|
ci->configure(DSP_SET_SAMPLE_DEPTH, 16);
|
||||||
|
|
@ -123,9 +125,14 @@ seek_start:
|
||||||
buffer = ci->request_buffer(&n,rmctx.audio_framesize + 1000);
|
buffer = ci->request_buffer(&n,rmctx.audio_framesize + 1000);
|
||||||
pkt_offset = skipped - pkt.length;
|
pkt_offset = skipped - pkt.length;
|
||||||
consumed = rm_get_packet(&buffer, &rmctx, &pkt);
|
consumed = rm_get_packet(&buffer, &rmctx, &pkt);
|
||||||
if(consumed < 0) {
|
if(consumed < 0 && playback_on != 0) {
|
||||||
DEBUGF("rm_get_packet failed\n");
|
if(playback_on == -1) {
|
||||||
return CODEC_ERROR;
|
/* Error only if packet-parsing failed and playback hadn't started */
|
||||||
|
DEBUGF("rm_get_packet failed\n");
|
||||||
|
return CODEC_ERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
skipped += pkt.length;
|
skipped += pkt.length;
|
||||||
if(pkt.timestamp > (unsigned)ci->seek_time) break;
|
if(pkt.timestamp > (unsigned)ci->seek_time) break;
|
||||||
|
|
@ -139,11 +146,18 @@ seek_start:
|
||||||
/* Request the required number of bytes from the input buffer */
|
/* Request the required number of bytes from the input buffer */
|
||||||
buffer=ci->request_buffer(&n,rmctx.audio_framesize + 1000);
|
buffer=ci->request_buffer(&n,rmctx.audio_framesize + 1000);
|
||||||
consumed = rm_get_packet(&buffer, &rmctx, &pkt);
|
consumed = rm_get_packet(&buffer, &rmctx, &pkt);
|
||||||
if(consumed < 0) {
|
|
||||||
DEBUGF("rm_get_packet failed\n");
|
if(consumed < 0 && playback_on != 0) {
|
||||||
return CODEC_ERROR;
|
if(playback_on == -1) {
|
||||||
|
/* Error only if packet-parsing failed and playback hadn't started */
|
||||||
|
DEBUGF("rm_get_packet failed\n");
|
||||||
|
return CODEC_ERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playback_on = 1;
|
||||||
if (pkt.timestamp >= ci->id3->length)
|
if (pkt.timestamp >= ci->id3->length)
|
||||||
goto done;
|
goto done;
|
||||||
/* Decode one block - returned samples will be host-endian */
|
/* Decode one block - returned samples will be host-endian */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue