diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2009-03-22 14:23:07 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2009-03-22 14:23:07 +0000 |
commit | 412cddeb2cf57e3117f43ae8e87962e959067691 (patch) | |
tree | 7a1a2c0d50c232631465b95b091dac6bf7010cdd /libao2 | |
parent | 9dea062bcce14e4554b052b107fec9cfadbf877a (diff) | |
download | mpv-412cddeb2cf57e3117f43ae8e87962e959067691.tar.bz2 mpv-412cddeb2cf57e3117f43ae8e87962e959067691.tar.xz |
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.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29035 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libao2')
-rw-r--r-- | libao2/ao_pcm.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/libao2/ao_pcm.c b/libao2/ao_pcm.c index bf3f224e81..5c97f05376 100644 --- a/libao2/ao_pcm.c +++ b/libao2/ao_pcm.c @@ -77,6 +77,7 @@ struct WaveHeader /* init with default values */ static struct WaveHeader wavhdr; +uint64_t data_length; static FILE *fp = NULL; @@ -162,7 +163,6 @@ static int init(int rate,int channels,int format,int flags){ 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 @@ static int init(int rate,int channels,int format,int flags){ // 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 @@ static int play(void* data,int len,int flags){ fwrite(data,len,1,fp); if(ao_pcm_waveheader) - wavhdr.data_length += len; + data_length += len; return len; } |