shithub: sox

Download patch

ref: 356439161f99dafc9e2b36ce23abbc6833708ea4
parent: dc233c9e4ac8a30c3f4a4c41060b876ae70dcbdf
author: idigdoug <idigdoug>
date: Wed Dec 23 02:31:10 EST 2009

Use conio.h for interactive console with MinGW. Adds HAVE_CONIO_H config setting, enabled by default for MSVC and MinGW.

--- a/msvc9/Sox/soxconfig.h
+++ b/msvc9/Sox/soxconfig.h
@@ -79,6 +79,7 @@
 #define HAVE_WAVPACK_H 1
 #define STATIC_WAVPACK 1
 
+#define HAVE_CONIO_H 1
 #define HAVE_FSEEKI64 1
 #define HAVE_FCNTL_H 1
 #define HAVE_IO_H 1
--- a/src/sox.c
+++ b/src/sox.c
@@ -95,9 +95,14 @@
   #define TIME_FRAC 1e3
 #endif
 
-#ifdef _MSC_VER
+#if !defined(HAVE_CONIO_H) && !defined(HAVE_TERMIOS_H) && (defined(_MSC_VER) || defined(__MINGW32__))
+#define HAVE_CONIO_H 1
+#endif
+
+#ifdef HAVE_CONIO_H
 /* _kbhit and _getch */
 #include <conio.h>
+#undef HAVE_TERMIOS_H
 #endif
 
 /*#define MORE_INTERACTIVE 1*/
@@ -1175,7 +1180,7 @@
   select(fileno(stdin) + 1, &fdset, NULL, NULL, &time_val);
   return FD_ISSET(fileno(stdin), &fdset);
 }
-#elif !defined(_MSC_VER)
+#elif !defined(HAVE_CONIO_H)
 #define kbhit() 0
 #endif
 
@@ -1232,7 +1237,7 @@
 {
   (void)client_data;
   if (interactive) while (kbhit()) {
-#ifdef _MSC_VER
+#ifdef HAVE_CONIO_H
     int ch = _getch();
 #else
     int ch = getchar();
@@ -1642,7 +1647,7 @@
 
   optimize_trim();
 
-#if defined(HAVE_TERMIOS_H) || defined(_MSC_VER)
+#if defined(HAVE_TERMIOS_H) || defined(HAVE_CONIO_H)
   /* so we can be fully interactive. */
   if (show_progress && !interactive && is_player && stdin_is_a_tty) {
 #ifdef HAVE_TERMIOS_H