# HG changeset patch # User nicodvb # Date 1149462282 0 # Node ID 15fbdb09330f1525c91d285bd654a00adcb1726a # Parent 0f3dc1ba69d1b427992b10049d19171b693b16b8 configurable tuning timeout diff -r 0f3dc1ba69d1 -r 15fbdb09330f libmpdemux/dvb_tune.c --- a/libmpdemux/dvb_tune.c Sun Jun 04 22:52:02 2006 +0000 +++ b/libmpdemux/dvb_tune.c Sun Jun 04 23:04:42 2006 +0000 @@ -238,19 +238,19 @@ static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone, fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation, fe_code_rate_t HP_CodeRate, fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth, - fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier); + fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int tmout); int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone, fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval, fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate, - fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier) + fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout) { int ris; mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune Freq: %lu\n", (long unsigned int) freq); - ris = tune_it(priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth, LP_CodeRate, hier); + ris = tune_it(priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth, LP_CodeRate, hier, timeout); if(ris != 0) mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune, TUNING FAILED\n"); @@ -338,7 +338,7 @@ #ifdef HAVE_DVB_HEAD -static int check_status(int fd_frontend,struct dvb_frontend_parameters* feparams, int tuner_type, uint32_t base) +static int check_status(int fd_frontend,struct dvb_frontend_parameters* feparams, int tuner_type, uint32_t base, int tmout) { int32_t strength; fe_status_t festatus; @@ -360,7 +360,7 @@ while(!ok) { festatus = 0; - if(poll(pfd,1,3000) > 0) + if(poll(pfd,1,tmout*1000) > 0) { if (pfd[0].revents & POLLPRI) { @@ -371,7 +371,7 @@ } usleep(10000); tm2 = time((time_t*) NULL); - if((festatus & FE_TIMEDOUT) || (locks >= 2) || (tm2 - tm1 >= 3)) + if((festatus & FE_TIMEDOUT) || (locks >= 2) || (tm2 - tm1 >= tmout)) ok = 1; } @@ -426,7 +426,7 @@ } else { - mp_msg(MSGT_DEMUX, MSGL_ERR, "Not able to lock to the signal on the given frequency\n"); + mp_msg(MSGT_DEMUX, MSGL_ERR, "Not able to lock to the signal on the given frequency, timeout: %d\n", tmout); return -1; } return 0; @@ -434,7 +434,7 @@ #else -static int check_status(int fd_frontend,FrontendParameters* feparams,int tuner_type,uint32_t base) +static int check_status(int fd_frontend,FrontendParameters* feparams,int tuner_type,uint32_t base, int tmout) { int i,res; int32_t strength; @@ -461,7 +461,7 @@ pfd[0].fd = fd_frontend; pfd[0].events = POLLIN | POLLPRI; - if(poll(pfd,1,10000) > 0) + if(poll(pfd,1,tmout*1000) > 0) { if (pfd[0].revents & POLLPRI) { @@ -643,7 +643,7 @@ static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone, fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation, fe_code_rate_t HP_CodeRate, fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth, - fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier) + fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout) { int res, hi_lo, dfd; #ifdef HAVE_DVB_HEAD @@ -787,5 +787,5 @@ if (fd_sec) SecGetStatus(fd_sec, &sec_state); #endif - return(check_status(fd_frontend,&feparams,fe_info.type, (hi_lo ? LOF2 : LOF1))); + return(check_status(fd_frontend,&feparams,fe_info.type, (hi_lo ? LOF2 : LOF1), timeout)); } diff -r 0f3dc1ba69d1 -r 15fbdb09330f libmpdemux/dvbin.c --- a/libmpdemux/dvbin.c Sun Jun 04 22:52:02 2006 +0000 +++ b/libmpdemux/dvbin.c Sun Jun 04 23:04:42 2006 +0000 @@ -64,11 +64,12 @@ int card; char *type; int vid, aid; + int timeout; char *file; } stream_defaults = { - "", 1, "", 0, 0, NULL + "", 1, "", 0, 0, 3, NULL }; #define ST_OFF(f) M_ST_OFF(struct stream_priv_s, f) @@ -80,6 +81,7 @@ {"type", ST_OFF(type), CONF_TYPE_STRING, 0, 0 ,0, NULL}, {"vid", ST_OFF(vid), CONF_TYPE_INT, 0, 0 ,0, NULL}, {"aid", ST_OFF(aid), CONF_TYPE_INT, 0, 0 ,0, NULL}, + {"timeout",ST_OFF(timeout), CONF_TYPE_INT, M_OPT_RANGE, 1, 30, NULL}, {"file", ST_OFF(file), CONF_TYPE_STRING, 0, 0 ,0, NULL}, {"hostname", ST_OFF(prog), CONF_TYPE_STRING, 0, 0, 0, NULL }, @@ -102,6 +104,7 @@ {"type", "DVB card type is autodetected and can't be overridden\n", CONF_TYPE_PRINT, CONF_NOCFG, 0 ,0, NULL}, {"vid", &stream_defaults.vid, CONF_TYPE_INT, 0, 0 ,0, NULL}, {"aid", &stream_defaults.aid, CONF_TYPE_INT, 0, 0 ,0, NULL}, + {"timeout", &stream_defaults.timeout, CONF_TYPE_INT, M_OPT_RANGE, 1, 30, NULL}, {"file", &stream_defaults.file, CONF_TYPE_STRING, 0, 0 ,0, NULL}, {NULL, NULL, 0, 0, 0, 0, NULL} @@ -119,7 +122,7 @@ extern int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone, fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval, fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate, - fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier); + fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout); extern char *dvb_dvrdev[4], *dvb_demuxdev[4], *dvb_frontenddev[4]; static dvb_config_t *dvb_config = NULL; @@ -560,7 +563,7 @@ if(do_tuning) if (! dvb_tune(priv, channel->freq, channel->pol, channel->srate, channel->diseqc, channel->tone, - channel->inv, channel->mod, channel->gi, channel->trans, channel->bw, channel->cr, channel->cr_lp, channel->hier)) + channel->inv, channel->mod, channel->gi, channel->trans, channel->bw, channel->cr, channel->cr_lp, channel->hier, priv->timeout)) return 0; @@ -733,6 +736,7 @@ return STREAM_ERROR; } priv->card = p->card - 1; + priv->timeout = p->timeout; tuner_type = priv->config->cards[priv->card].type; diff -r 0f3dc1ba69d1 -r 15fbdb09330f libmpdemux/dvbin.h --- a/libmpdemux/dvbin.h Sun Jun 04 22:52:02 2006 +0000 +++ b/libmpdemux/dvbin.h Sun Jun 04 23:04:42 2006 +0000 @@ -99,6 +99,7 @@ stream_t *stream; char new_tuning[256], prev_tuning[256]; int retry; + int timeout; } dvb_priv_t;