diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2007-04-12 11:36:12 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2007-04-12 11:36:12 +0000 |
commit | 8b9df97d96f48b06253c662691cb0b19193e2351 (patch) | |
tree | 9daacf629836e918c024e787c3b30ee254fe5718 /apps/plugins/mpegplayer/mpegplayer.c | |
parent | 9291ae50caa0aa36dced30cddc3bac2af786a81a (diff) | |
download | rockbox-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/plugins/mpegplayer/mpegplayer.c')
-rw-r--r-- | apps/plugins/mpegplayer/mpegplayer.c | 16 |
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; | |||
258 | /* TODO: Can we reduce the PCM buffer size? */ | 258 | /* TODO: Can we reduce the PCM buffer size? */ |
259 | #define PCMBUFFER_SIZE ((512*1024)-PCMBUFFER_GUARD_SIZE) | 259 | #define PCMBUFFER_SIZE ((512*1024)-PCMBUFFER_GUARD_SIZE) |
260 | #define PCMBUFFER_GUARD_SIZE (1152*4 + sizeof (struct pcm_frame_header)) | 260 | #define PCMBUFFER_GUARD_SIZE (1152*4 + sizeof (struct pcm_frame_header)) |
261 | #define MPA_MAX_FRAME_SIZE 1441 /* Largest frame with a padding byte */ | 261 | #define MPA_MAX_FRAME_SIZE 1729 /* Largest frame - MPEG1, Layer II, 384kbps, 32kHz, pad */ |
262 | #define MPABUF_SIZE (64*1024 + ALIGN_UP(MPA_MAX_FRAME_SIZE + 2*MAD_BUFFER_GUARD, 4)) | 262 | #define MPABUF_SIZE (64*1024 + ALIGN_UP(MPA_MAX_FRAME_SIZE + 2*MAD_BUFFER_GUARD, 4)) |
263 | #define LIBMPEG2BUFFER_SIZE (2*1024*1024) | 263 | #define LIBMPEG2BUFFER_SIZE (2*1024*1024) |
264 | 264 | ||
265 | /* 65536+6 is required since each PES has a 6 byte header with a 16 bit packet length field */ | 265 | /* 65536+6 is required since each PES has a 6 byte header with a 16 bit packet length field */ |
266 | #define MPEG_GUARDBUF_SIZE (64*1024+16) /* Keep a bit extra */ | 266 | #define MPEG_GUARDBUF_SIZE (64*1024+1024) /* Keep a bit extra - excessive for now */ |
267 | #define MPEG_LOW_WATERMARK (1024*1024) | 267 | #define MPEG_LOW_WATERMARK (1024*1024) |
268 | 268 | ||
269 | static void pcm_playback_play_pause(bool play); | 269 | static void pcm_playback_play_pause(bool play); |
@@ -544,6 +544,11 @@ static void get_next_data( Stream* str ) | |||
544 | header_length += *p++; | 544 | header_length += *p++; |
545 | 545 | ||
546 | p += header_length; | 546 | p += header_length; |
547 | |||
548 | if (p >= disk_buf_end) | ||
549 | { | ||
550 | p = disk_buf + (p - disk_buf_end); | ||
551 | } | ||
547 | /*rb->splash( 30, "System header" );*/ | 552 | /*rb->splash( 30, "System header" );*/ |
548 | } | 553 | } |
549 | 554 | ||
@@ -1021,8 +1026,7 @@ static void audio_thread(void) | |||
1021 | } | 1026 | } |
1022 | 1027 | ||
1023 | /** Decoding **/ | 1028 | /** Decoding **/ |
1024 | if (stream.error == 0) | 1029 | mad_stream_buffer(&stream, mpabuf, mpabuf_used); |
1025 | mad_stream_buffer(&stream, mpabuf, mpabuf_used); | ||
1026 | 1030 | ||
1027 | mad_stat = mad_frame_decode(&frame, &stream); | 1031 | mad_stat = mad_frame_decode(&frame, &stream); |
1028 | 1032 | ||
@@ -1061,16 +1065,16 @@ static void audio_thread(void) | |||
1061 | || stream.error == MAD_ERROR_BUFLEN) | 1065 | || stream.error == MAD_ERROR_BUFLEN) |
1062 | { | 1066 | { |
1063 | /* This makes the codec support partially corrupted files */ | 1067 | /* This makes the codec support partially corrupted files */ |
1064 | if (mad_errors >= 30) | 1068 | if (++mad_errors > 30) |
1065 | break; | 1069 | break; |
1066 | 1070 | ||
1067 | stream.error = 0; | 1071 | stream.error = 0; |
1068 | mad_errors++; | ||
1069 | rb->priority_yield(); | 1072 | rb->priority_yield(); |
1070 | continue; | 1073 | continue; |
1071 | } | 1074 | } |
1072 | else if (MAD_RECOVERABLE(stream.error)) | 1075 | else if (MAD_RECOVERABLE(stream.error)) |
1073 | { | 1076 | { |
1077 | stream.error = 0; | ||
1074 | rb->priority_yield(); | 1078 | rb->priority_yield(); |
1075 | continue; | 1079 | continue; |
1076 | } | 1080 | } |