diff --git a/src/descrambler/capmt.c b/src/descrambler/capmt.c index 4a567f0d67..e6e7f110ae 100644 --- a/src/descrambler/capmt.c +++ b/src/descrambler/capmt.c @@ -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 diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index aac4a2a795..e5ccd77a19 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -24,14 +24,6 @@ #include #include /* basename */ -#if ENABLE_ANDROID -#include -#define statvfs statfs -#define fstatvfs fstatfs -#else -#include -#endif - #include "htsstr.h" #include "tvheadend.h" @@ -49,6 +41,14 @@ #include "muxer.h" +#if ENABLE_ANDROID +#include +#define statvfs statfs +#define fstatvfs fstatfs +#else +#include +#endif + /** * */ diff --git a/src/http.c b/src/http.c index 9f3883dd6b..fc783e85eb 100644 --- a/src/http.c +++ b/src/http.c @@ -39,6 +39,10 @@ #include "notify.h" #include "channels.h" +#if ENABLE_ANDROID +#include +#endif + void *http_server; static http_path_list_t http_paths; diff --git a/src/input/mpegts/iptv/iptv_rtsp.c b/src/input/mpegts/iptv/iptv_rtsp.c index 08e44d7621..de5415e846 100644 --- a/src/input/mpegts/iptv/iptv_rtsp.c +++ b/src/input/mpegts/iptv/iptv_rtsp.c @@ -21,6 +21,9 @@ #include "iptv_private.h" #include "iptv_rtcp.h" #include "http.h" +#if ENABLE_ANDROID +#include +#endif typedef struct { http_client_t *hc; diff --git a/src/input/mpegts/mpegts_mux.c b/src/input/mpegts/mpegts_mux.c index b446b844d3..419adee164 100644 --- a/src/input/mpegts/mpegts_mux.c +++ b/src/input/mpegts/mpegts_mux.c @@ -30,7 +30,6 @@ #include static void mpegts_mux_scan_timeout ( void *p ); - /* **************************************************************************** * Mux instance (input linkage) * ***************************************************************************/ diff --git a/src/satip/rtp.c b/src/satip/rtp.c index 00d71a31f7..9af55a9234 100644 --- a/src/satip/rtp.c +++ b/src/satip/rtp.c @@ -23,6 +23,9 @@ #include "input.h" #include "streaming.h" #include "satip/server.h" +#if ENABLE_ANDROID +#include +#endif #define RTP_PACKETS 128 #define RTP_PAYLOAD (7*188+12) diff --git a/src/timeshift/timeshift_reader.c b/src/timeshift/timeshift_reader.c index 9a1a1bbd73..162ec781ed 100644 --- a/src/timeshift/timeshift_reader.c +++ b/src/timeshift/timeshift_reader.c @@ -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)); diff --git a/src/tvheadend.h b/src/tvheadend.h index 8b9976f688..74546420b6 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -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 // 32-bit Android has only timegm64() and not timegm(). // We replicate the behaviour of timegm() when the result overflows time_t. diff --git a/src/wrappers.c b/src/wrappers.c index 4a204a4966..3d9e10cf7d 100644 --- a/src/wrappers.c +++ b/src/wrappers.c @@ -16,6 +16,32 @@ #include #endif +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; +} + int tvh_open(const char *pathname, int flags, mode_t mode) {