diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2009-07-07 02:56:01 +0300 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2009-07-07 02:56:01 +0300 |
commit | a2037a2effbd4622d0e8336245a9b14c3f886bde (patch) | |
tree | bd2face6dd36d2663197b23a33da9e9b2814f70c /libao2/ao_pcm.c | |
parent | 0c2773a709276681575d2507aa60ee85c2d0b850 (diff) | |
parent | 43079c51daa8c12b0a44e5ad8022c979dd9e8336 (diff) | |
download | mpv-a2037a2effbd4622d0e8336245a9b14c3f886bde.tar.bz2 mpv-a2037a2effbd4622d0e8336245a9b14c3f886bde.tar.xz |
Merge svn changes up to r29412
Diffstat (limited to 'libao2/ao_pcm.c')
-rw-r--r-- | libao2/ao_pcm.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libao2/ao_pcm.c b/libao2/ao_pcm.c index 8be3bdabb5..78652c7cdc 100644 --- a/libao2/ao_pcm.c +++ b/libao2/ao_pcm.c @@ -34,6 +34,10 @@ #include "mp_msg.h" #include "help_mp.h" +#ifdef __MINGW32__ +// for GetFileType to detect pipes +#include <windows.h> +#endif static const ao_info_t info = { @@ -175,7 +179,13 @@ static int init(int rate,int channels,int format,int flags){ static void uninit(int immed){ if(ao_pcm_waveheader){ /* Rewrite wave header */ - if (fseek(fp, 0, SEEK_SET) != 0) + int broken_seek = 0; +#ifdef __MINGW32__ + // Windows, in its usual idiocy "emulates" seeks on pipes so it always looks + // like they work. So we have to detect them brute-force. + broken_seek = GetFileType((HANDLE)_get_osfhandle(_fileno(fp))) != FILE_TYPE_DISK; +#endif + if (broken_seek || 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"); |