Mercurial > mplayer.hg
comparison libmpdemux/dvb_tune.c @ 18561:15fbdb09330f
configurable tuning timeout
author | nicodvb |
---|---|
date | Sun, 04 Jun 2006 23:04:42 +0000 |
parents | 6ff3379a0862 |
children | 0783dd397f74 |
comparison
equal
deleted
inserted
replaced
18560:0f3dc1ba69d1 | 18561:15fbdb09330f |
---|---|
236 | 236 |
237 | 237 |
238 static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone, | 238 static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone, |
239 fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation, fe_code_rate_t HP_CodeRate, | 239 fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation, fe_code_rate_t HP_CodeRate, |
240 fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth, | 240 fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth, |
241 fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier); | 241 fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int tmout); |
242 | 242 |
243 | 243 |
244 int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone, | 244 int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone, |
245 fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval, | 245 fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval, |
246 fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate, | 246 fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate, |
247 fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier) | 247 fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout) |
248 { | 248 { |
249 int ris; | 249 int ris; |
250 | 250 |
251 mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune Freq: %lu\n", (long unsigned int) freq); | 251 mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune Freq: %lu\n", (long unsigned int) freq); |
252 | 252 |
253 ris = tune_it(priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth, LP_CodeRate, hier); | 253 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); |
254 | 254 |
255 if(ris != 0) | 255 if(ris != 0) |
256 mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune, TUNING FAILED\n"); | 256 mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune, TUNING FAILED\n"); |
257 | 257 |
258 return (ris == 0); | 258 return (ris == 0); |
336 mp_msg(MSGT_DEMUX, MSGL_V, "\n"); | 336 mp_msg(MSGT_DEMUX, MSGL_V, "\n"); |
337 } | 337 } |
338 | 338 |
339 | 339 |
340 #ifdef HAVE_DVB_HEAD | 340 #ifdef HAVE_DVB_HEAD |
341 static int check_status(int fd_frontend,struct dvb_frontend_parameters* feparams, int tuner_type, uint32_t base) | 341 static int check_status(int fd_frontend,struct dvb_frontend_parameters* feparams, int tuner_type, uint32_t base, int tmout) |
342 { | 342 { |
343 int32_t strength; | 343 int32_t strength; |
344 fe_status_t festatus; | 344 fe_status_t festatus; |
345 struct pollfd pfd[1]; | 345 struct pollfd pfd[1]; |
346 int ok=0, locks=0; | 346 int ok=0, locks=0; |
358 mp_msg(MSGT_DEMUX, MSGL_V, "Getting frontend status\n"); | 358 mp_msg(MSGT_DEMUX, MSGL_V, "Getting frontend status\n"); |
359 tm1 = tm2 = time((time_t*) NULL); | 359 tm1 = tm2 = time((time_t*) NULL); |
360 while(!ok) | 360 while(!ok) |
361 { | 361 { |
362 festatus = 0; | 362 festatus = 0; |
363 if(poll(pfd,1,3000) > 0) | 363 if(poll(pfd,1,tmout*1000) > 0) |
364 { | 364 { |
365 if (pfd[0].revents & POLLPRI) | 365 if (pfd[0].revents & POLLPRI) |
366 { | 366 { |
367 if(ioctl(fd_frontend, FE_READ_STATUS, &festatus) >= 0) | 367 if(ioctl(fd_frontend, FE_READ_STATUS, &festatus) >= 0) |
368 if(festatus & FE_HAS_LOCK) | 368 if(festatus & FE_HAS_LOCK) |
369 locks++; | 369 locks++; |
370 } | 370 } |
371 } | 371 } |
372 usleep(10000); | 372 usleep(10000); |
373 tm2 = time((time_t*) NULL); | 373 tm2 = time((time_t*) NULL); |
374 if((festatus & FE_TIMEDOUT) || (locks >= 2) || (tm2 - tm1 >= 3)) | 374 if((festatus & FE_TIMEDOUT) || (locks >= 2) || (tm2 - tm1 >= tmout)) |
375 ok = 1; | 375 ok = 1; |
376 } | 376 } |
377 | 377 |
378 if(festatus & FE_HAS_LOCK) | 378 if(festatus & FE_HAS_LOCK) |
379 { | 379 { |
424 | 424 |
425 print_status(festatus); | 425 print_status(festatus); |
426 } | 426 } |
427 else | 427 else |
428 { | 428 { |
429 mp_msg(MSGT_DEMUX, MSGL_ERR, "Not able to lock to the signal on the given frequency\n"); | 429 mp_msg(MSGT_DEMUX, MSGL_ERR, "Not able to lock to the signal on the given frequency, timeout: %d\n", tmout); |
430 return -1; | 430 return -1; |
431 } | 431 } |
432 return 0; | 432 return 0; |
433 } | 433 } |
434 | 434 |
435 #else | 435 #else |
436 | 436 |
437 static int check_status(int fd_frontend,FrontendParameters* feparams,int tuner_type,uint32_t base) | 437 static int check_status(int fd_frontend,FrontendParameters* feparams,int tuner_type,uint32_t base, int tmout) |
438 { | 438 { |
439 int i,res; | 439 int i,res; |
440 int32_t strength; | 440 int32_t strength; |
441 fe_status_t festatus; | 441 fe_status_t festatus; |
442 FrontendEvent event; | 442 FrontendEvent event; |
459 } | 459 } |
460 | 460 |
461 pfd[0].fd = fd_frontend; | 461 pfd[0].fd = fd_frontend; |
462 pfd[0].events = POLLIN | POLLPRI; | 462 pfd[0].events = POLLIN | POLLPRI; |
463 | 463 |
464 if(poll(pfd,1,10000) > 0) | 464 if(poll(pfd,1,tmout*1000) > 0) |
465 { | 465 { |
466 if (pfd[0].revents & POLLPRI) | 466 if (pfd[0].revents & POLLPRI) |
467 { | 467 { |
468 mp_msg(MSGT_DEMUX, MSGL_V, "Getting frontend event\n"); | 468 mp_msg(MSGT_DEMUX, MSGL_V, "Getting frontend event\n"); |
469 if ( ioctl(fd_frontend, FE_GET_EVENT, &event) < 0) | 469 if ( ioctl(fd_frontend, FE_GET_EVENT, &event) < 0) |
641 #endif | 641 #endif |
642 | 642 |
643 static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone, | 643 static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone, |
644 fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation, fe_code_rate_t HP_CodeRate, | 644 fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation, fe_code_rate_t HP_CodeRate, |
645 fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth, | 645 fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth, |
646 fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier) | 646 fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout) |
647 { | 647 { |
648 int res, hi_lo, dfd; | 648 int res, hi_lo, dfd; |
649 #ifdef HAVE_DVB_HEAD | 649 #ifdef HAVE_DVB_HEAD |
650 struct dvb_frontend_parameters feparams; | 650 struct dvb_frontend_parameters feparams; |
651 struct dvb_frontend_info fe_info; | 651 struct dvb_frontend_info fe_info; |
785 | 785 |
786 #ifndef HAVE_DVB_HEAD | 786 #ifndef HAVE_DVB_HEAD |
787 if (fd_sec) SecGetStatus(fd_sec, &sec_state); | 787 if (fd_sec) SecGetStatus(fd_sec, &sec_state); |
788 #endif | 788 #endif |
789 | 789 |
790 return(check_status(fd_frontend,&feparams,fe_info.type, (hi_lo ? LOF2 : LOF1))); | 790 return(check_status(fd_frontend,&feparams,fe_info.type, (hi_lo ? LOF2 : LOF1), timeout)); |
791 } | 791 } |