Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Mar 2011 21:48:22 +0100
From:      Juergen Lock <nox@jelal.kn-bremen.de>
To:        freebsd-multimedia@FreeBSD.org
Cc:        decke@FreeBSD.org
Subject:   patch: xbmc and lirc
Message-ID:  <20110305204822.GA28311@triton8.kn-bremen.de>

next in thread | raw e-mail | index | archive | help
Hi!

 So the xbmc port atm doesn't build its lirc client code because
that code uses inotify() which is a Linuxism.  Today I took a closer
look and found it actually 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.  Did that, added an autoconf check
for good measure, and that got lirc working. :)

 I've put the patch here:

	http://people.freebsd.org/~nox/dvb/xbmc/patch-xbmc-lirc.txt

(the first hunk is actually redundant, instead you should just
remove files/patch-guilib__common__Makefile.in - I'll add the
patch without it at the end.)

 The mceusb remote works as is then with webcamd, for dvb tuner
remotes supported by the Linux code webcamd uses you can start
with this ~/.xbmc/userdata/Lircmap.xml :

	http://people.freebsd.org/~nox/dvb/xbmc/Lircmap.xml

note the comments at the beginning, you may need to remap
important buttons for your particular remote.  Also see here:

	http://wiki.xbmc.org/index.php?title=HOW-TO_setup_Lirc_to_talk_to_XBMC

 And here comes the patch.  Enjoy, :)
	Juergen

--- guilib/system.h.orig
+++ guilib/system.h
@@ -135,9 +135,7 @@
 #define HAS_GLX
 #define HAS_LINUX_NETWORK
 #define HAS_SDL_AUDIO
-#if !defined(__FreeBSD__)
 #define HAS_LIRC
-#endif
 #define HAS_SDL_WIN_EVENTS
 #ifdef HAVE_LIBPULSE
 #define HAS_PULSEAUDIO
--- configure.in.orig
+++ configure.in
@@ -516,7 +516,7 @@ AC_FUNC_STRFTIME
 AC_FUNC_STRTOD
 AC_FUNC_UTIME_NULL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([atexit dup2 fdatasync floor fs_stat_dev ftime ftruncate getcwd gethostbyaddr gethostbyname gethostname getpagesize getpass gettimeofday inet_ntoa lchown localeconv memchr memmove memset mkdir modf munmap pow rmdir select setenv setlocale socket sqrt strcasecmp strchr strcspn strdup strerror strncasecmp strpbrk strrchr strspn strstr strtol strtoul sysinfo tzset utime])
+AC_CHECK_FUNCS([atexit dup2 fdatasync floor fs_stat_dev ftime ftruncate getcwd gethostbyaddr gethostbyname gethostname getpagesize getpass gettimeofday inet_ntoa inotify lchown localeconv memchr memmove memset mkdir modf munmap pow rmdir select setenv setlocale socket sqrt strcasecmp strchr strcspn strdup strerror strncasecmp strpbrk strrchr strspn strstr strtol strtoul sysinfo tzset utime])
 
 # Check for various sizes
 AC_CHECK_SIZEOF([int])
--- guilib/common/LIRC.cpp.orig
+++ guilib/common/LIRC.cpp
@@ -19,11 +19,14 @@
 *
 */
 
+#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"
@@ -92,12 +95,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;
@@ -148,6 +153,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)
             {
@@ -168,6 +174,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));
@@ -206,6 +216,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;
@@ -220,6 +231,7 @@ bool CRemoteControl::CheckDevice() {
     }
     i += sizeof(struct inotify_event)+e->len;
   }
+#endif
   return true;
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110305204822.GA28311>