Mercurial > mplayer.hg
changeset 29000:60d414c856b5
Print a warning if ao_pcm wrote more data than what can be specified in the
WAV header (ca. 2GB currently) or if it can not update the header at all.
author | reimar |
---|---|
date | Sun, 22 Mar 2009 14:23:07 +0000 |
parents | f4a95c0acaab |
children | 1bb13b69cc9e |
files | libao2/ao_pcm.c |
diffstat | 1 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libao2/ao_pcm.c Sun Mar 22 13:19:58 2009 +0000 +++ b/libao2/ao_pcm.c Sun Mar 22 14:23:07 2009 +0000 @@ -77,6 +77,7 @@ /* init with default values */ static struct WaveHeader wavhdr; +uint64_t data_length; static FILE *fp = NULL; @@ -162,7 +163,6 @@ if(fp) { if(ao_pcm_waveheader){ /* Reserve space for wave header */ fwrite(&wavhdr,sizeof(wavhdr),1,fp); - wavhdr.file_length=wavhdr.data_length=0; } return 1; } @@ -174,11 +174,17 @@ // close audio device static void uninit(int immed){ - if(ao_pcm_waveheader && fseek(fp, 0, SEEK_SET) == 0){ /* Write wave header */ - wavhdr.file_length = wavhdr.data_length + sizeof(wavhdr) - 8; + if(ao_pcm_waveheader){ /* Rewrite wave header */ + if (fseek(fp, 0, SEEK_SET) != 0) + mp_msg(MSGT_AO, MSGL_ERR, "Could not seek to start, WAV size headers not updated!\n"); + else if (data_length > 0x7ffff000) + mp_msg(MSGT_AO, MSGL_ERR, "File larger than allowed for WAV files, may play truncated!\n"); + else { + wavhdr.file_length = data_length + sizeof(wavhdr) - 8; wavhdr.file_length = le2me_32(wavhdr.file_length); - wavhdr.data_length = le2me_32(wavhdr.data_length); + wavhdr.data_length = le2me_32(data_length); fwrite(&wavhdr,sizeof(wavhdr),1,fp); + } } fclose(fp); if (ao_outputfilename) @@ -241,7 +247,7 @@ fwrite(data,len,1,fp); if(ao_pcm_waveheader) - wavhdr.data_length += len; + data_length += len; return len; }