aboutsummaryrefslogtreecommitdiffstats
path: root/util/gnutv/gnutv_data.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--util/gnutv/gnutv_data.c34
1 files changed, 29 insertions, 5 deletions
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;
}