From: gn64_jp Date: Fri, 17 Feb 2012 13:21:40 +0000 (+0000) Subject: fix tunerec X-Git-Url: http://git.osdn.net/view?p=rec10%2Frec10-git.git;a=commitdiff_plain;h=fc9f3fc7f1d02c8eff5a5f026d7a0fa4a814cdf9;ds=sidebyside fix tunerec git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@922 4e526526-5e11-4fc0-8910-f8fd03428081 --- diff --git a/tunerec/tunerec.c b/tunerec/tunerec.c index c4a6688..f3f3328 100755 --- a/tunerec/tunerec.c +++ b/tunerec/tunerec.c @@ -7,7 +7,6 @@ #include #include #include -#include #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) @@ -29,7 +28,7 @@ static int search(int adapter_nr,struct channel *ch) fe_status_t status; sprintf(file, "/dev/dvb/adapter%d/frontend0", adapter_nr); - if ((fd = open(file, (O_RDWR | O_CREAT | O_TRUNC), 0666)) < 0) { + if ((fd = open(file, O_RDWR)) < 0) { perror("open"); return -1; } @@ -115,42 +114,11 @@ static int track(int adapter_nr) close(fd); return -1; } -} -void record(int adapter_nr, char* output, int rectime) { - int fin, fout; - char input[256]; - time_t start_time, current_time; - char buf[1316]; - ssize_t rt, wt; - int size_remain; - - fout = open(output, (O_WRONLY | O_CREAT | O_TRUNC)); - if ( fout < 0 ) { - printf("output file open failed\n"); - return; - } - sprintf(input, "/dev/dvb/adapter%d/dvr0", adapter_nr); - start_time = time(NULL); - fin = open(input, (O_RDONLY)); - while ( rt = read(fin, buf, 1316) ) { - while ( wt = write(fout, buf, rt) ) { - rt -= wt; - if ( rt == 0 ) break; - if ( wt == 0 ) { - printf("output file write failed\n"); - goto error; - } - } - current_time = time(NULL); - if ( current_time - start_time > rectime ) { - break; - } - } + while (1) + sleep(3); - error: - close(fin); - close(fout); + /* never returns */ } int main(int argc, char *argv[]) { @@ -159,7 +127,6 @@ int main(int argc, char *argv[]) { int channel_freq; int fd; int ret; - int rectime; if (argc <= 2) { fprintf(stderr, "Usage: %s adapter_nr freq [tsid]\n", argv[0]); @@ -169,12 +136,9 @@ int main(int argc, char *argv[]) { adapter_nr = strtol(argv[1], NULL, 0); channel_freq = strtol(argv[2], NULL, 10); channel_id=0; - if (argc >= 4){ + if (argc == 4){ channel_id = strtol(argv[3], NULL, 10); } - if ( argc == 5 ) { - rectime = atoi(argv[4]); - } struct channel ch1 ={0,"",channel_freq,channel_id}; ch = &ch1; //struct channel ch;//{ 1, "NHK BS-1", 1318000, 0x40f1 } @@ -184,7 +148,6 @@ int main(int argc, char *argv[]) { return 1; ret = track(adapter_nr); - record(adapter_nr, argv[3], rectime); close(fd); return ret < 0;