diff options
author | etobi <git@e-tobi.net> | 2013-09-03 09:48:44 +0200 |
---|---|---|
committer | etobi <git@e-tobi.net> | 2013-09-03 09:48:44 +0200 |
commit | 9a5228e0f2b898367b7943d294be58caf6ce8bb3 (patch) | |
tree | 8145575f8f67c126b81e607d47613f34add97393 /util/gnutv | |
parent | ab959d7b4194715870128e616b8e29d4a101e488 (diff) | |
download | linux-dvb-apps-upstream/1.1.1+rev1273.tar.gz |
Imported Upstream version 1.1.1+rev1273upstream/1.1.1+rev1273
Diffstat (limited to 'util/gnutv')
-rw-r--r-- | util/gnutv/gnutv.c | 12 | ||||
-rw-r--r-- | util/gnutv/gnutv_data.c | 34 | ||||
-rw-r--r-- | util/gnutv/gnutv_data.h | 2 |
3 files changed, 41 insertions, 7 deletions
diff --git a/util/gnutv/gnutv.c b/util/gnutv/gnutv.c index 62f19be..f824c65 100644 --- a/util/gnutv/gnutv.c +++ b/util/gnutv/gnutv.c @@ -66,6 +66,7 @@ void usage(void) " * C-MULTI - Big Dish - Multipoint LNBf, 3700 to 4200 MHz,\n" " Dual LO, H:5150MHz, V:5750MHz.\n" " * One of the sec definitions from the secfile if supplied\n" + " -buffer <size> Custom DVR buffer size\n" " -out decoder Output to hardware decoder (default)\n" " decoderabypass Output to hardware decoder using audio bypass\n" " dvr Output stream to dvr device\n" @@ -124,6 +125,7 @@ int main(int argc, char *argv[]) struct gnutv_ca_params gnutv_ca_params; int ffaudiofd = -1; int usertp = 0; + int buffer_size = 0; while(argpos != argc) { if (!strcmp(argv[argpos], "-h")) { @@ -167,6 +169,14 @@ int main(int argc, char *argv[]) usage(); secid = argv[argpos+1]; argpos+=2; + } else if (!strcmp(argv[argpos], "-buffer")) { + if ((argc - argpos) < 2) + usage(); + if (sscanf(argv[argpos+1], "%i", &buffer_size) != 1) + usage(); + if (buffer_size < 0) + usage(); + argpos+=2; } else if (!strcmp(argv[argpos], "-out")) { if ((argc - argpos) < 2) usage(); @@ -320,7 +330,7 @@ int main(int argc, char *argv[]) gnutv_dvb_start(&gnutv_dvb_params); // start the data stuff - gnutv_data_start(output_type, ffaudiofd, adapter_id, demux_id, outfile, outif, outaddrs, usertp); + gnutv_data_start(output_type, ffaudiofd, adapter_id, demux_id, buffer_size, outfile, outif, outaddrs, usertp); } // the UI 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; } diff --git a/util/gnutv/gnutv_data.h b/util/gnutv/gnutv_data.h index 8e47e3a..94c55c9 100644 --- a/util/gnutv/gnutv_data.h +++ b/util/gnutv/gnutv_data.h @@ -26,7 +26,7 @@ #include <netdb.h> extern 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); extern void gnutv_data_stop(void); |