[xiph-commits] r12218 - in trunk/vorbis-tools: . ogg123

conrad at svn.xiph.org conrad at svn.xiph.org
Sat Dec 16 17:08:58 PST 2006


Author: conrad
Date: 2006-12-16 17:08:55 -0800 (Sat, 16 Dec 2006)
New Revision: 12218

Modified:
   trunk/vorbis-tools/configure.ac
   trunk/vorbis-tools/ogg123/remote.c
Log:
ogg123: use select (if available) when waiting for remote control input. Adds
a check to configure.ac for select, defining HAVE_SELECT


Modified: trunk/vorbis-tools/configure.ac
===================================================================
--- trunk/vorbis-tools/configure.ac	2006-12-17 00:32:14 UTC (rev 12217)
+++ trunk/vorbis-tools/configure.ac	2006-12-17 01:08:55 UTC (rev 12218)
@@ -252,7 +252,7 @@
 
 AC_FUNC_ALLOCA
 AM_ICONV
-AC_CHECK_FUNCS(atexit on_exit fcntl)
+AC_CHECK_FUNCS(atexit on_exit fcntl select)
 AM_LANGINFO_CODESET
 
 dnl --------------------------------------------------

Modified: trunk/vorbis-tools/ogg123/remote.c
===================================================================
--- trunk/vorbis-tools/ogg123/remote.c	2006-12-17 00:32:14 UTC (rev 12217)
+++ trunk/vorbis-tools/ogg123/remote.c	2006-12-17 01:08:55 UTC (rev 12218)
@@ -28,6 +28,10 @@
 #include <pthread.h>
 #include <semaphore.h>
 
+#if HAVE_SELECT
+#include <sys/select.h>
+#endif
+
 #include "ogg123.h"
 #include "format.h"
 
@@ -127,6 +131,10 @@
   int ignore = 0;
   char buf[MAXBUF+1];
   char *b;
+
+#if HAVE_SELECT
+  fd_set fd;
+#endif
   
   buf[MAXBUF]=0;
 
@@ -135,7 +143,13 @@
     buf[0] = 0;
     send_log("Waiting for input: ...");
 
-    while (fgets(buf, MAXBUF, stdin) == NULL);
+#if HAVE_SELECT
+    FD_ZERO(&fd);
+    FD_SET(0,&fd);
+    select (1, &fd, NULL, NULL, NULL);
+#endif
+
+    fgets(buf, MAXBUF, stdin);
     buf[strlen(buf)-1] = 0;
 
     /* Lock on */



More information about the commits mailing list