detect inotify availability
authorFneufneu <fneufneu@xbmc.org>
Wed, 9 Mar 2011 17:16:26 +0000 (18:16 +0100)
committerFneufneu <fneufneu@xbmc.org>
Wed, 9 Mar 2011 17:16:26 +0000 (18:16 +0100)
actually we only uses inotify to find out when
lircd is stopped, which at least on FreeBSD it will also find out
by receiving an eof from the socket fd so we can actually just
disable the inotify code.

in configure: check sys/inotfy.h header
in LIRC.cpp: use HAVE_INOTIFY

configure.in
xbmc/input/linux/LIRC.cpp

index 3525c33..7ecc2f0 100644 (file)
@@ -475,6 +475,9 @@ AC_CHECK_SIZEOF([size_t])
 # Add top source directory for all builds so we can use config.h
 INCLUDES="$INCLUDES -I\$(abs_top_srcdir)"
 
+# Check inotify availability
+AC_CHECK_HEADER([sys/inotify.h], AC_DEFINE([HAVE_INOTIFY],[1],[Define if we have inotify]),)
+
 # Checks for boost headers using CXX instead of CC
 AC_LANG_PUSH([C++])
 AC_CHECK_HEADER([boost/shared_ptr.hpp],, AC_MSG_ERROR($missing_library))
index c0c63f1..9638f34 100644 (file)
 *
 */
 
+#include "config.h"
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#ifdef HAVE_INOTIFY
 #include <sys/inotify.h>
+#endif
 #include <limits.h>
 #include <unistd.h>
 #include "LIRC.h"
@@ -91,12 +94,14 @@ void CRemoteControl::Disconnect()
       close(m_fd);
     m_fd = -1;
     m_file = NULL;
+#ifdef HAVE_INOTIFY
     if (m_inotify_wd >= 0) {
       inotify_rm_watch(m_inotify_fd, m_inotify_wd);
       m_inotify_wd = -1;
     }
     if (m_inotify_fd >= 0)
       close(m_inotify_fd);
+#endif
 
     m_inReply = false;
     m_nrSending = 0;
@@ -147,6 +152,7 @@ void CRemoteControl::Initialize()
         {
           if ((m_file = fdopen(m_fd, "r+")) != NULL)
           {
+#ifdef HAVE_INOTIFY
             // Setup inotify so we can disconnect if lircd is restarted
             if ((m_inotify_fd = inotify_init()) >= 0)
             {
@@ -167,6 +173,10 @@ void CRemoteControl::Initialize()
                 }
               }
             }
+#else
+            m_bInitialized = true;
+            CLog::Log(LOGINFO, "LIRC %s: sucessfully started", __FUNCTION__);
+#endif
           }
           else
             CLog::Log(LOGERROR, "LIRC %s: fdopen failed: %s", __FUNCTION__, strerror(errno));
@@ -205,6 +215,7 @@ void CRemoteControl::Initialize()
 }
 
 bool CRemoteControl::CheckDevice() {
+#ifdef HAVE_INOTIFY
   if (m_inotify_fd < 0 || m_inotify_wd < 0)
     return true; // inotify wasn't setup for some reason, assume all is well
   int bufsize = sizeof(struct inotify_event) + PATH_MAX;
@@ -219,6 +230,7 @@ bool CRemoteControl::CheckDevice() {
     }
     i += sizeof(struct inotify_event)+e->len;
   }
+#endif
   return true;
 }