diff --git a/src/dvb/dvb_fe.c b/src/dvb/dvb_fe.c index 13b2ba3..a94bcec 100644 --- a/src/dvb/dvb_fe.c +++ b/src/dvb/dvb_fe.c @@ -341,6 +341,35 @@ dvb_fe_stop(th_dvb_mux_instance_t *tdmi, int retune) #if DVB_API_VERSION >= 5 +static int check_frontend (int fe_fd, int dvr, int human_readable) { + (void)dvr; + fe_status_t status; + uint16_t snr, signal; + uint32_t ber; + int timeout = 0; + + do { + if (ioctl(fe_fd, FE_READ_STATUS, &status) == -1) + perror("FE_READ_STATUS failed"); + /* some frontends might not support all these ioctls, thus we + * avoid printing errors + */ + if (ioctl(fe_fd, FE_READ_SIGNAL_STRENGTH, &signal) == -1) + signal = -2; + if (ioctl(fe_fd, FE_READ_SNR, &snr) == -1) + snr = -2; + if (ioctl(fe_fd, FE_READ_BER, &ber) == -1) + ber = -2; + + if ((status & FE_HAS_LOCK) || (++timeout >= 10)) + break; + + usleep(1000000); + } while (1); + + return 0; +} + static struct dtv_property clear_p[] = { { .cmd = DTV_CLEAR }, }; @@ -391,7 +420,8 @@ dvb_fe_tune_s2(th_dvb_mux_instance_t *tdmi, dvb_mux_conf_t *dmc) /* do tuning now */ r = ioctl(tda->tda_fe_fd, FE_SET_PROPERTY, &_dvbs_cmdseq); - + if(1) + check_frontend (tda->tda_fe_fd, 0, 1); return r; }