From 9a5228e0f2b898367b7943d294be58caf6ce8bb3 Mon Sep 17 00:00:00 2001 From: etobi Date: Tue, 3 Sep 2013 09:48:44 +0200 Subject: Imported Upstream version 1.1.1+rev1273 --- util/gnutv/gnutv_data.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'util/gnutv/gnutv_data.c') diff --git a/util/gnutv/gnutv_data.c b/util/gnutv/gnutv_data.c index 7ac0f23..54ccdde 100644 --- a/util/gnutv/gnutv_data.c +++ b/util/gnutv/gnutv_data.c @@ -77,7 +77,7 @@ static struct pid_fd *pid_fds = NULL; static int pid_fds_count = 0; void gnutv_data_start(int _output_type, - int ffaudiofd, int _adapter_id, int _demux_id, + int ffaudiofd, int _adapter_id, int _demux_id, int buffer_size, char *outfile, char* outif, struct addrinfo *_outaddrs, int _usertp) { @@ -114,6 +114,14 @@ void gnutv_data_start(int _output_type, exit(1); } + // optionally set dvr buffer size + if (buffer_size > 0) { + if (dvbdemux_set_buffer(dvrfd, buffer_size) != 0) { + fprintf(stderr, "Failed to set DVR buffer size\n"); + exit(1); + } + } + pthread_create(&outputthread, NULL, fileoutputthread_func, NULL); break; @@ -142,6 +150,14 @@ void gnutv_data_start(int _output_type, exit(1); } + // optionally set dvr buffer size + if (buffer_size > 0) { + if (dvbdemux_set_buffer(dvrfd, buffer_size) != 0) { + fprintf(stderr, "Failed to set DVR buffer size\n"); + exit(1); + } + } + pthread_create(&outputthread, NULL, udpoutputthread_func, NULL); break; } @@ -220,19 +236,27 @@ static void *fileoutputthread_func(void* arg) pollfd.events = POLLIN|POLLPRI|POLLERR; while(!outputthread_shutdown) { - if (poll(&pollfd, 1, 1000) != 1) - continue; - if (pollfd.revents & POLLERR) { + if (poll(&pollfd, 1, 1000) == -1) { if (errno == EINTR) continue; - fprintf(stderr, "DVR device read failure\n"); + fprintf(stderr, "DVR device poll failure\n"); return 0; } + if (pollfd.revents == 0) + continue; + int size = read(dvrfd, buf, sizeof(buf)); if (size < 0) { if (errno == EINTR) continue; + + if (errno == EOVERFLOW) { + // The error flag has been cleared, next read should succeed. + fprintf(stderr, "DVR overflow\n"); + continue; + } + fprintf(stderr, "DVR device read failure\n"); return 0; } -- cgit v1.2.3