Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Android build fixes
  • Loading branch information
BenEfrati authored and perexg committed Sep 14, 2015
1 parent e537902 commit 857a7fb
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/descrambler/capmt.c
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/dvr/dvr_rec.c
Expand Up @@ -24,14 +24,6 @@
#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"
Expand All @@ -49,6 +41,14 @@

#include "muxer.h"

#if ENABLE_ANDROID
#include <sys/vfs.h>
#define statvfs statfs
#define fstatvfs fstatfs
#else
#include <sys/statvfs.h>
#endif

/**
*
*/
Expand Down
4 changes: 4 additions & 0 deletions src/http.c
Expand Up @@ -39,6 +39,10 @@
#include "notify.h"
#include "channels.h"

#if ENABLE_ANDROID
#include <sys/socket.h>
#endif

void *http_server;

static http_path_list_t http_paths;
Expand Down
3 changes: 3 additions & 0 deletions src/input/mpegts/iptv/iptv_rtsp.c
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/input/mpegts/mpegts_mux.c
Expand Up @@ -30,7 +30,6 @@
#include <assert.h>

static void mpegts_mux_scan_timeout ( void *p );

/* ****************************************************************************
* Mux instance (input linkage)
* ***************************************************************************/
Expand Down
3 changes: 3 additions & 0 deletions src/satip/rtp.c
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/timeshift/timeshift_reader.c
Expand Up @@ -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",
Expand All @@ -366,15 +366,15 @@ 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

/* 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));
Expand Down
2 changes: 2 additions & 0 deletions src/tvheadend.h
Expand Up @@ -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.
Expand Down
27 changes: 27 additions & 0 deletions src/wrappers.c
Expand Up @@ -16,6 +16,33 @@
#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)
{
Expand Down

0 comments on commit 857a7fb

Please sign in to comment.