]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Android build fixes
authorBenEfrati <ben1189@gmail.com>
Sat, 5 Sep 2015 07:22:27 +0000 (10:22 +0300)
committerJaroslav Kysela <perex@perex.cz>
Mon, 14 Sep 2015 18:24:26 +0000 (20:24 +0200)
src/descrambler/capmt.c
src/dvr/dvr_rec.c
src/http.c
src/input/mpegts/iptv/iptv_rtsp.c
src/input/mpegts/mpegts_mux.c
src/satip/rtp.c
src/timeshift/timeshift_reader.c
src/tvheadend.h
src/wrappers.c

index 4a567f0d67ea32ce69876720a4b856cef38dc2aa..e6e7f110aeed7d9e380aa7f203f943f3f2aef070 100644 (file)
@@ -617,7 +617,7 @@ capmt_write_msg(capmt_t *capmt, int adapter, int sid, const uint8_t *buf, size_t
   res = send(fd, buf, len, MSG_DONTWAIT);
   if (res < len) {
 #if ENABLE_ANDROID
-    tvhlog(LOG_DEBUG, "capmt", "%s: Message send failed to socket %i (%li)", capmt_name(capmt), fd, res); // Android bug, ssize_t is long int
+    tvhlog(LOG_DEBUG, "capmt", "%s: Message send failed to socket %i (%li)", capmt_name(capmt), fd, (long int)res); // Android bug, ssize_t is long int
 #else
     tvhlog(LOG_DEBUG, "capmt", "%s: Message send failed to socket %i (%zi)", capmt_name(capmt), fd, res);
 #endif
index 6968d6c432503f5513d9c581ee9d8bd6cca94ea4..0a2df9ec3c182b5e1cfaa3a84726f1c7b0e00f78 100644 (file)
 #include <sys/stat.h>
 #include <libgen.h> /* basename */
 
-#if ENABLE_ANDROID
-#include <sys/vfs.h>
-#define statvfs statfs
-#define fstatvfs fstatfs
-#else
-#include <sys/statvfs.h>
-#endif
-
 #include "htsstr.h"
 
 #include "tvheadend.h"
 
 #include "muxer.h"
 
+#if ENABLE_ANDROID
+#include <sys/vfs.h>
+#define statvfs statfs
+#define fstatvfs fstatfs
+#else
+#include <sys/statvfs.h>
+#endif
+
 /**
  *
  */
index 9f3883dd6be68102c01af3963bd68e4f2881a8be..fc783e85ebd90b3f4a08ee6be9296c221083aaff 100644 (file)
 #include "notify.h"
 #include "channels.h"
 
+#if ENABLE_ANDROID
+#include <sys/socket.h>
+#endif
+
 void *http_server;
 
 static http_path_list_t http_paths;
index 08e44d762101854e3af3157feee7e7e10834dd92..de5415e8461c1abb8f7fc931f1c865424b76bba0 100644 (file)
@@ -21,6 +21,9 @@
 #include "iptv_private.h"
 #include "iptv_rtcp.h"
 #include "http.h"
+#if ENABLE_ANDROID
+#include <sys/socket.h>
+#endif
 
 typedef struct {
   http_client_t *hc;
index e77f0cfb5853b084b94acd11d828e16b2c3664e5..4fd7376859c8c94dc1bf9d31fd9a6862413bb96a 100644 (file)
@@ -30,7 +30,6 @@
 #include <assert.h>
 
 static void mpegts_mux_scan_timeout ( void *p );
-
 /* ****************************************************************************
  * Mux instance (input linkage)
  * ***************************************************************************/
index cf3b8c6069125154050b72ca027519ccd5f0f85a..d216ee7c5847233f9322ed77a617a53c480758d0 100644 (file)
@@ -23,6 +23,9 @@
 #include "input.h"
 #include "streaming.h"
 #include "satip/server.h"
+#if ENABLE_ANDROID
+#include <sys/socket.h>
+#endif
 
 #define RTP_PACKETS 128
 #define RTP_PAYLOAD (7*188+12)
index 9a1a1bbd73ecf4a0b3b5e8dd6ed07075b6117702..162ec781ed220a1f6dc97191d88c52b8fe9fbff0 100644 (file)
@@ -350,7 +350,7 @@ static int _timeshift_read
       if (tsf->rfd < 0)
         return -1;
     }
-    tvhtrace("timeshift", "ts %d seek to %jd (fd %i)", ts->id, tsf->roff, tsf->rfd);
+    tvhtrace("timeshift", "ts %d seek to %jd (fd %i)", ts->id, (intmax_t)tsf->roff, tsf->rfd);
     if (tsf->rfd >= 0)
       if ((off = lseek(tsf->rfd, tsf->roff, SEEK_SET)) != tsf->roff)
         tvherror("timeshift", "seek to %s failed (off %"PRId64" != %"PRId64"): %s",
@@ -366,7 +366,7 @@ static int _timeshift_read
       return -1;
     }
 #if ENABLE_ANDROID
-    tvhtrace("timeshift", "ts %d read msg %p (%ld)", ts->id, *sm, r);  // Android bug, ssize_t is long int
+    tvhtrace("timeshift", "ts %d read msg %p (%ld)", ts->id, *sm, (long int)r);  // Android bug, ssize_t is long int
 #else
     tvhtrace("timeshift", "ts %d read msg %p (%zd)", ts->id, *sm, r);
 #endif
@@ -374,7 +374,7 @@ static int _timeshift_read
     /* Incomplete */
     if (r == 0) {
       if (tsf->rfd >= 0) {
-        tvhtrace("timeshift", "ts %d seek to %jd (fd %i) (incomplete)", ts->id, tsf->roff, tsf->rfd);
+        tvhtrace("timeshift", "ts %d seek to %jd (fd %i) (incomplete)", ts->id, (intmax_t)tsf->roff, tsf->rfd);
         if ((off = lseek(tsf->rfd, ooff, SEEK_SET)) != ooff)
           tvherror("timeshift", "seek to %s failed (off %"PRId64" != %"PRId64"): %s",
                    tsf->path, (int64_t)ooff, (int64_t)off, strerror(errno));
index b184d564f4915d35dee07f656e071078145c7a59..8e6c97d703ac556b0207fce4198c0041ff53adbd 100644 (file)
@@ -53,6 +53,8 @@
 
 #if ENABLE_ANDROID
 #define S_IEXEC S_IXUSR
+#define epoll_create1(EPOLL_CLOEXEC) epoll_create(n)
+#define inotify_init1(IN_CLOEXEC) inotify_init()
 #include <time64.h>
 // 32-bit Android has only timegm64() and not timegm().
 // We replicate the behaviour of timegm() when the result overflows time_t.
index 4a204a496676980db18459e14fe82d82ece031e0..2d472f76810eb9b311f698a95c22094954bc30a4 100644 (file)
 #include <pthread_np.h>
 #endif
 
+#if ENABLE_ANDROID
+int
+pthread_mutex_timedlock
+  ( pthread_mutex_t *mutex, struct timespec *timeout )
+{
+  struct timeval timenow;
+  struct timespec sleepytime;
+  int retcode;
+
+  /* This is just to avoid a completely busy wait */
+  sleepytime.tv_sec = 0;
+  sleepytime.tv_nsec = 10000000; /* 10ms */
+
+  while ((retcode = pthread_mutex_trylock (mutex)) == EBUSY) {
+    gettimeofday (&timenow, NULL);
+
+    if (timenow.tv_sec >= timeout->tv_sec &&
+       (timenow.tv_usec * 1000) >= timeout->tv_nsec)
+      return ETIMEDOUT;
+
+    nanosleep (&sleepytime, NULL);
+  }
+
+  return retcode;
+}
+#endif
+
 int
 tvh_open(const char *pathname, int flags, mode_t mode)
 {