diff options
author | cinap_lenrek <cinap_lenrek@rei2.9hal> | 2011-11-17 22:26:53 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@rei2.9hal> | 2011-11-17 22:26:53 +0100 |
commit | 79172e71e6be93d7902f9dd58ae5beb527cf52a6 (patch) | |
tree | 5c0066a3bc31bc119575057258779eea92e3a9b9 /sys/src | |
parent | 251c3cd70ab1b8a574832cfbe306490ba5055010 (diff) |
games/mp3dec: dont give up too soon on stream errors
Diffstat (limited to 'sys/src')
-rw-r--r-- | sys/src/games/mp3dec/main.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/sys/src/games/mp3dec/main.c b/sys/src/games/mp3dec/main.c index 5530f6b35..34d61b546 100644 --- a/sys/src/games/mp3dec/main.c +++ b/sys/src/games/mp3dec/main.c @@ -9,6 +9,7 @@ char *name; vlong offset; int rate = 44100; +int debug = 0; char *outfile; int vfd; /* /dev/volume */ @@ -149,12 +150,17 @@ output(void *data, struct mad_header const* header, struct mad_pcm *pcm) static enum mad_flow error(void *data, struct mad_stream *stream, struct mad_frame *frame) { - if(stream->error == MAD_ERROR_LOSTSYNC) - return MAD_FLOW_CONTINUE; - sysfatal("%s:#%lld: %s", - name, offset-(stream->bufend-stream->next_frame), - mad_stream_errorstr(stream)); - return 0; + if(stream->error == MAD_ERROR_LOSTSYNC){ + if(memcmp(stream->this_frame, "TAG", 3)==0){ + mad_stream_skip(stream, 128); + return MAD_FLOW_CONTINUE; + } + } + if(debug) + fprint(2, "%s:#%lld: %s\n", + name, offset-(stream->bufend-stream->next_frame), + mad_stream_errorstr(stream)); + return MAD_FLOW_CONTINUE; } void @@ -171,7 +177,7 @@ play(int fd, char *nam) void usage(void) { - fprint(2, "usage: mp3dec [-o outfile] [file...]\n"); + fprint(2, "usage: mp3dec [ -d ] [ -o outfile ] [ file ... ]\n"); exits("usage"); } @@ -185,6 +191,9 @@ main(int argc, char **argv) case 'o': outfile = EARGF(usage()); break; + case 'd': + debug++; + break; default: usage(); }ARGEND |