ref: 20bcf2b2fb377db07b134490cecefd7fc8f521c7
parent: c8f56d17352951f5d200a8424da6b6a1ddd9354b
author: Gregory Maxwell <[email protected]>
date: Tue Jun 12 06:50:03 EDT 2012
On WIN32 fseek() returns 0 on pipes, use GetFileType() to detect them.
--- a/src/audio-in.c
+++ b/src/audio-in.c
@@ -40,6 +40,8 @@
#ifdef WIN32
# include <malloc.h>
+# include <windows.h> /*GetFileType()*/
+# include <io.h> /*_get_osfhandle()*/
#else
# ifdef HAVE_ALLOCA_H
# include <alloca.h>
@@ -588,7 +590,12 @@
{
opt->total_samples_per_channel = len/(format.channels*samplesize);
}
+#ifdef WIN32
+ /*On Mingw/Win32 fseek() returns zero on pipes.*/
+ else if (opt->ignorelength==1 || ((GetFileType((HANDLE)_get_osfhandle(fileno(in)))&~FILE_TYPE_REMOTE)!=FILE_TYPE_DISK))
+#else
else if (opt->ignorelength==1)
+#endif
{
opt->total_samples_per_channel = 0;
}