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
|
|
@ -47,6 +47,8 @@ enum codec_status codec_main(void)
|
|||
int err, consumed, pkt_offset, skipped = 0;
|
||||
uint32_t s = 0; /* sample rate */
|
||||
unsigned char c = 0; /* channels */
|
||||
int playback_on = -1;
|
||||
|
||||
/* Generic codec initialisation */
|
||||
ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED);
|
||||
ci->configure(DSP_SET_SAMPLE_DEPTH, 16);
|
||||
|
|
@ -123,9 +125,14 @@ seek_start:
|
|||
buffer = ci->request_buffer(&n,rmctx.audio_framesize + 1000);
|
||||
pkt_offset = skipped - pkt.length;
|
||||
consumed = rm_get_packet(&buffer, &rmctx, &pkt);
|
||||
if(consumed < 0) {
|
||||
DEBUGF("rm_get_packet failed\n");
|
||||
return CODEC_ERROR;
|
||||
if(consumed < 0 && playback_on != 0) {
|
||||
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;
|
||||
}
|
||||
skipped += pkt.length;
|
||||
if(pkt.timestamp > (unsigned)ci->seek_time) break;
|
||||
|
|
@ -139,11 +146,18 @@ seek_start:
|
|||
/* Request the required number of bytes from the input buffer */
|
||||
buffer=ci->request_buffer(&n,rmctx.audio_framesize + 1000);
|
||||
consumed = rm_get_packet(&buffer, &rmctx, &pkt);
|
||||
if(consumed < 0) {
|
||||
DEBUGF("rm_get_packet failed\n");
|
||||
return CODEC_ERROR;
|
||||
}
|
||||
|
||||
if(consumed < 0 && playback_on != 0) {
|
||||
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)
|
||||
goto done;
|
||||
/* Decode one block - returned samples will be host-endian */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue