From: Andre Noll Date: Sun, 30 Nov 2008 14:13:35 +0000 (+0100) Subject: wav: Only create wav header if there is output available. X-Git-Tag: v0.3.3~5 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=1be5197226174d8e8ffdab8ac89fca0b4f8d601b wav: Only create wav header if there is output available. Due to recent changes to filter_chain.c, the convert functions of all activated filters are called even if there is no output availabe since the ogg vorbis decoder needs this. However, this change broke the wav filter: wav_convert() is now called even if the previous filter (e.g. oggdec) has not yet determined the format of the input stream. This caused the wav filter to write out an invalid wav header with 0 channels. Fix it by not doing anything unless wav_convert() gets called with non-empty input. --- diff --git a/wav.c b/wav.c index 4933afd4..c03c21dc 100644 --- a/wav.c +++ b/wav.c @@ -48,6 +48,7 @@ static void make_wav_header(unsigned int channels, unsigned int samplerate, int bytespersec = channels * samplerate * BITS / 8; int align = channels * BITS / 8; + assert(channels); PARA_DEBUG_LOG("writing wave header: %d channels, %d KHz\n", channels, samplerate); memset(headbuf, 0, WAV_HEADER_LEN); memcpy(headbuf, "RIFF", 4); @@ -71,6 +72,8 @@ static ssize_t wav_convert(char *inbuf, size_t len, struct filter_node *fn) int *bof = fn->private_data; if (*bof) { + if (!len) + return 0; make_wav_header(fn->fc->channels, fn->fc->samplerate, fn); fn->loaded = WAV_HEADER_LEN; *bof = 0;