From fd883f1e7201ee7cde585088bfaa457ea3ae2108 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Thu, 21 Aug 2008 04:18:12 +0000 Subject: [PATCH] Fixed bug when writing AVI files with more than one RIFF chunk. Added missing chdman error messages when extracting to an AVI file. --- src/lib/util/aviio.c | 4 +++- src/tools/chdman.c | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/util/aviio.c b/src/lib/util/aviio.c index d664c8214ab..3504352f79a 100644 --- a/src/lib/util/aviio.c +++ b/src/lib/util/aviio.c @@ -1719,8 +1719,10 @@ static avi_error chunk_write(avi_file *file, UINT32 type, const void *data, UINT UINT32 written; /* if we are getting too big, split the RIFF */ + /* note that we ignore writes before the current RIFF base, as those are assumed to be + overwrites of a chunk from the previous RIFF */ if ((file->riffbase == 0 && file->writeoffs + length + compute_idx1_size(file) >= MAX_RIFF_SIZE) || - file->writeoffs + length - file->riffbase >= MAX_RIFF_SIZE) + (file->writeoffs >= file->riffbase && file->writeoffs + length - file->riffbase >= MAX_RIFF_SIZE)) { /* close the movi list */ avierr = chunk_close(file); diff --git a/src/tools/chdman.c b/src/tools/chdman.c index 068c919c8d6..f5af8f22b40 100644 --- a/src/tools/chdman.c +++ b/src/tools/chdman.c @@ -1553,7 +1553,10 @@ static int do_extractav(int argc, char *argv[], int param) { avierr = avi_append_sound_samples(avi, chnum, avconfig.audio[chnum], numsamples, 0); if (avierr != AVIERR_NONE) + { + fprintf(stderr, "Error writing samples for hunk %d to AVI file: %s\n", firstframe + framenum, avi_error_string(avierr)); goto cleanup; + } } /* write video */ @@ -1561,7 +1564,10 @@ static int do_extractav(int argc, char *argv[], int param) { avierr = avi_append_video_frame_yuy16(avi, fullbitmap); if (avierr != AVIERR_NONE) + { + fprintf(stderr, "Error writing video for hunk %d to AVI file: %s\n", firstframe + framenum, avi_error_string(avierr)); goto cleanup; + } } } progress(TRUE, "Extraction complete! \n");