Commit ab863321 authored by Josh Coalson's avatar Josh Coalson
Browse files

observe padding byte requirement when writing test WAVEs

parent a9414544
......@@ -612,7 +612,8 @@ foo:
static FLAC__bool generate_wav(const char *filename, unsigned sample_rate, unsigned channels, unsigned bytes_per_sample, unsigned samples)
{
const unsigned size = channels * bytes_per_sample * samples;
const unsigned true_size = channels * bytes_per_sample * samples;
const unsigned padded_size = (true_size + 1) & (~1u);
FILE *f;
unsigned i;
......@@ -620,7 +621,7 @@ static FLAC__bool generate_wav(const char *filename, unsigned sample_rate, unsig
return false;
if(fwrite("RIFF", 1, 4, f) < 4)
goto foo;
if(!write_little_endian_uint32(f, size + 36))
if(!write_little_endian_uint32(f, padded_size + 36))
goto foo;
if(fwrite("WAVEfmt \020\000\000\000\001\000", 1, 14, f) < 14)
goto foo;
......@@ -636,12 +637,15 @@ static FLAC__bool generate_wav(const char *filename, unsigned sample_rate, unsig
goto foo;
if(fwrite("data", 1, 4, f) < 4)
goto foo;
if(!write_little_endian_uint32(f, size))
if(!write_little_endian_uint32(f, true_size))
goto foo;
for(i = 0; i < size; i++)
for(i = 0; i < true_size; i++)
if(fputc(i, f) == EOF)
goto foo;
for( ; i < padded_size; i++)
if(fputc(0, f) == EOF)
goto foo;
fclose(f);
return true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment