summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-04-12 11:36:12 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-04-12 11:36:12 +0000
commit8b9df97d96f48b06253c662691cb0b19193e2351 (patch)
tree9daacf629836e918c024e787c3b30ee254fe5718 /apps
parent9291ae50caa0aa36dced30cddc3bac2af786a81a (diff)
downloadrockbox-8b9df97d96f48b06253c662691cb0b19193e2351.tar.gz
rockbox-8b9df97d96f48b06253c662691cb0b19193e2351.zip
mpegplayer: Recover from audio stream errors better. Correct some sizes. Add some needed extra guard buffer. Add in an important additional wrap check. Stream demuxer needs work on when it looks ahead in the stream and it should wrap though.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13123 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index 0903da69e4..37723df7a6 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -258,12 +258,12 @@ volatile int videostatus IBSS_ATTR;
/* TODO: Can we reduce the PCM buffer size? */
#define PCMBUFFER_SIZE ((512*1024)-PCMBUFFER_GUARD_SIZE)
#define PCMBUFFER_GUARD_SIZE (1152*4 + sizeof (struct pcm_frame_header))
-#define MPA_MAX_FRAME_SIZE 1441 /* Largest frame with a padding byte */
+#define MPA_MAX_FRAME_SIZE 1729 /* Largest frame - MPEG1, Layer II, 384kbps, 32kHz, pad */
#define MPABUF_SIZE (64*1024 + ALIGN_UP(MPA_MAX_FRAME_SIZE + 2*MAD_BUFFER_GUARD, 4))
#define LIBMPEG2BUFFER_SIZE (2*1024*1024)
/* 65536+6 is required since each PES has a 6 byte header with a 16 bit packet length field */
-#define MPEG_GUARDBUF_SIZE (64*1024+16) /* Keep a bit extra */
+#define MPEG_GUARDBUF_SIZE (64*1024+1024) /* Keep a bit extra - excessive for now */
#define MPEG_LOW_WATERMARK (1024*1024)
static void pcm_playback_play_pause(bool play);
@@ -544,6 +544,11 @@ static void get_next_data( Stream* str )
header_length += *p++;
p += header_length;
+
+ if (p >= disk_buf_end)
+ {
+ p = disk_buf + (p - disk_buf_end);
+ }
/*rb->splash( 30, "System header" );*/
}
@@ -1021,8 +1026,7 @@ static void audio_thread(void)
}
/** Decoding **/
- if (stream.error == 0)
- mad_stream_buffer(&stream, mpabuf, mpabuf_used);
+ mad_stream_buffer(&stream, mpabuf, mpabuf_used);
mad_stat = mad_frame_decode(&frame, &stream);
@@ -1061,16 +1065,16 @@ static void audio_thread(void)
|| stream.error == MAD_ERROR_BUFLEN)
{
/* This makes the codec support partially corrupted files */
- if (mad_errors >= 30)
+ if (++mad_errors > 30)
break;
stream.error = 0;
- mad_errors++;
rb->priority_yield();
continue;
}
else if (MAD_RECOVERABLE(stream.error))
{
+ stream.error = 0;
rb->priority_yield();
continue;
}