aboutsummaryrefslogtreecommitdiffstats
path: root/util/gnutv/gnutv_data.c
diff options
context:
space:
mode:
authoretobi <git@e-tobi.net>2013-09-03 09:48:44 +0200
committeretobi <git@e-tobi.net>2013-09-03 09:48:44 +0200
commit9a5228e0f2b898367b7943d294be58caf6ce8bb3 (patch)
tree8145575f8f67c126b81e607d47613f34add97393 /util/gnutv/gnutv_data.c
parentab959d7b4194715870128e616b8e29d4a101e488 (diff)
downloadlinux-dvb-apps-upstream/1.1.1+rev1273.tar.gz
Imported Upstream version 1.1.1+rev1273upstream/1.1.1+rev1273
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;
}