Apply similar fix from writing float data to WAVEX files without a peak chunk.

This commit is contained in:
Erik de Castro Lopo 2007-12-28 01:38:33 +11:00
parent a6f3f957c4
commit c215c0fc85
3 changed files with 19 additions and 3 deletions

View File

@ -13,6 +13,9 @@
* src/aiff.c tests/header_test.tpl
Apply similar fix to above for AIFF files.
* src/wav.c tests/header_test.tpl
Apply similar fix to above for WAVEX files.
2007-12-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/ogg.c

View File

@ -961,14 +961,16 @@ wav_write_header (SF_PRIVATE *psf, int calc_length)
} /* wav_write_header */
static int
wavex_write_header (SF_PRIVATE *psf, int calc_length)
{ sf_count_t current ;
int fmt_size, k, subformat, add_fact_chunk = SF_FALSE ;
int fmt_size, k, subformat, add_fact_chunk = SF_FALSE, has_data = SF_FALSE ;
current = psf_ftell (psf) ;
if (current > psf->dataoffset)
has_data = SF_TRUE ;
if (calc_length)
{ psf->filelength = psf_get_filelen (psf) ;
@ -1136,9 +1138,12 @@ wavex_write_header (SF_PRIVATE *psf, int calc_length)
if (psf->error)
return psf->error ;
if (has_data && psf->dataoffset != psf->headindex)
return psf->error = SFE_INTERNAL ;
psf->dataoffset = psf->headindex ;
if (current < psf->dataoffset)
if (! has_data)
psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
else if (current > 0)
psf_fseek (psf, current, SEEK_SET) ;

View File

@ -87,6 +87,14 @@ main (int argc, char *argv [])
update_seek_double_test ("header_double.wav", SF_FORMAT_WAV) ;
header_shrink_test ("header_shrink.wav", SF_FORMAT_WAV) ;
extra_header_test ("extra.wav", SF_FORMAT_WAV) ;
update_header_test ("header.wavex", SF_FORMAT_WAVEX) ;
update_seek_short_test ("header_short.wavex", SF_FORMAT_WAVEX) ;
update_seek_int_test ("header_int.wavex", SF_FORMAT_WAVEX) ;
update_seek_float_test ("header_float.wavex", SF_FORMAT_WAVEX) ;
update_seek_double_test ("header_double.wavex", SF_FORMAT_WAVEX) ;
header_shrink_test ("header_shrink.wavex", SF_FORMAT_WAVEX) ;
extra_header_test ("extra.wavex", SF_FORMAT_WAVEX) ;
test_count++ ;
} ;