Mercurial > pt1.oyama
diff recpt1/recpt1.c @ 34:3f2487de156e
should not loop if tuner device is specified.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Thu, 05 Mar 2009 01:05:32 +0900 |
parents | f25820d90249 |
children | b17f95181af4 |
line wrap: on
line diff
--- a/recpt1/recpt1.c Tue Mar 03 17:59:17 2009 +0900 +++ b/recpt1/recpt1.c Thu Mar 05 01:05:32 2009 +0900 @@ -624,52 +624,69 @@ freq.slot = ptr->add_freq; /* open tuner */ - /* 1. specified tuner device */ + /* case 1: specified tuner device */ if(device) { tfd = open(device, O_RDONLY); if(tfd < 0) { fprintf(stderr, "Cannot open tuner device: %s\n", device); return 1; } - } - /* 2. loop around available devices */ - if(ptr->type == CHTYPE_SATELLITE) { - tuner = bsdev; - num_devs = NUM_BSDEV; + /* power on LNB */ + if(ptr->type == CHTYPE_SATELLITE) { + if(ioctl(tfd, LNB_ENABLE, 0) < 0) { + close(tfd); + fprintf(stderr, "Power on LNB failed: %s\n", device); + return 1; + } + } + + /* tune to specified channel */ + if(ioctl(tfd, SET_CHANNEL, &freq) < 0) { + close(tfd); + fprintf(stderr, "Cannot tune to the specified channel: %s\n", device); + return 1; + } } else { - tuner = isdb_t_dev; - num_devs = NUM_ISDB_T_DEV; - } + /* case 2: loop around available devices */ + if(ptr->type == CHTYPE_SATELLITE) { + tuner = bsdev; + num_devs = NUM_BSDEV; + } + else { + tuner = isdb_t_dev; + num_devs = NUM_ISDB_T_DEV; + } - for(lp = 0; lp < num_devs; lp++) { - tfd = open(tuner[lp], O_RDONLY); - if(tfd >= 0) { - /* power on LNB */ - if(ptr->type == CHTYPE_SATELLITE) { - if(ioctl(tfd, LNB_ENABLE, 0) < 0) { + for(lp = 0; lp < num_devs; lp++) { + tfd = open(tuner[lp], O_RDONLY); + if(tfd >= 0) { + /* power on LNB */ + if(ptr->type == CHTYPE_SATELLITE) { + if(ioctl(tfd, LNB_ENABLE, 0) < 0) { + close(tfd); + tfd = -1; + continue; + } + } + + /* tune to specified channel */ + if(ioctl(tfd, SET_CHANNEL, &freq) < 0) { close(tfd); + tfd = -1; continue; } + + break; /* found suitable tuner */ } - - /* tune to specified channel */ - if(ioctl(tfd, SET_CHANNEL, &freq) < 0) { - close(tfd); - continue; - } + } - break; /* found suitable tuner */ + /* all tuners cannot be used */ + if(tfd < 0) { + fprintf(stderr, "Cannot tune to the specified channel\n"); + return 1; } - close(tfd); - tfd = -1; - } - - /* all tuners cannot be used */ - if(tfd < 0) { - fprintf(stderr, "Could not tune to the specified channel\n"); - return 1; } /* show signal strength */ @@ -695,7 +712,7 @@ if(!fileless) { wfd = open(argv[optind + 2], (O_RDWR | O_CREAT | O_TRUNC), 0666); if(wfd < 0) { - fprintf(stderr, "Could not open output file: %s\n", + fprintf(stderr, "Cannot open output file: %s\n", argv[optind + 2]); return 1; } @@ -706,7 +723,7 @@ if(use_b25) { dec = b25_startup(&dopt); if(!dec) { - fprintf(stderr, "Could not start b25 decoder\n"); + fprintf(stderr, "Cannot start b25 decoder\n"); fprintf(stderr, "Fall back to encrypted recording\n"); use_b25 = 0; } @@ -756,7 +773,7 @@ /* start recording */ if(ioctl(tfd, START_REC, 0) < 0) { - fprintf(stderr, "Tuner could not start recording\n"); + fprintf(stderr, "Tuner cannot start recording\n"); return 1; }