From dcc2e2e5ea5a3a8b055d43f859a0b6bfdcbfe31a Mon Sep 17 00:00:00 2001 From: voroshil Date: Mon, 10 Sep 2007 17:09:35 +0000 Subject: Implementation of tv:// driver autodetection. If user did not specify driver directly, all available drivers will be probed (in order: v4l2,v4l1,bsdbt848,dummy). In most cases first probed driver will be successfully autodetected and used. Autodetection will be disabled if user specified driver directly (in command line or config). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24423 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/tv.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'stream/tv.c') diff --git a/stream/tv.c b/stream/tv.c index 58a05ba8f8..d6c380c5f9 100644 --- a/stream/tv.c +++ b/stream/tv.c @@ -52,17 +52,18 @@ extern tvi_info_t tvi_info_v4l2; extern tvi_info_t tvi_info_bsdbt848; #endif +/** List of drivers in autodetection order */ static const tvi_info_t* tvi_driver_list[]={ - &tvi_info_dummy, -#ifdef HAVE_TV_V4L1 - &tvi_info_v4l, -#endif #ifdef HAVE_TV_V4L2 &tvi_info_v4l2, #endif +#ifdef HAVE_TV_V4L1 + &tvi_info_v4l, +#endif #ifdef HAVE_TV_BSDBT848 &tvi_info_bsdbt848, #endif + &tvi_info_dummy, NULL }; @@ -560,7 +561,7 @@ static tvi_handle_t *tv_begin(tv_param_t* tv_param) { int i; tvi_handle_t* h; - if(!strcmp(tv_param->driver,"help")){ + if(tv_param->driver && !strcmp(tv_param->driver,"help")){ mp_msg(MSGT_TV,MSGL_INFO,MSGTR_TV_AvailableDrivers); for(i=0;tvi_driver_list[i];i++){ mp_msg(MSGT_TV,MSGL_INFO," %s\t%s",tvi_driver_list[i]->short_name,tvi_driver_list[i]->name); @@ -572,20 +573,29 @@ static tvi_handle_t *tv_begin(tv_param_t* tv_param) } for(i=0;tvi_driver_list[i];i++){ - if (!strcmp(tvi_driver_list[i]->short_name, tv_param->driver)){ + if (!tv_param->driver || !strcmp(tvi_driver_list[i]->short_name, tv_param->driver)){ h=tvi_driver_list[i]->tvi_init(tv_param); - if(!h) return NULL; + //Requested driver initialization failed + if (!h && tv_param->driver) + return NULL; + //Driver initialization failed during autodetection process. + if (!h) + continue; h->tv_param=tv_param; mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_DriverInfo, tvi_driver_list[i]->short_name, tvi_driver_list[i]->name, tvi_driver_list[i]->author, tvi_driver_list[i]->comment?tvi_driver_list[i]->comment:""); + tv_param->driver=strdup(tvi_driver_list[i]->short_name); return h; } } - mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_NoSuchDriver, tv_param->driver); + if(tv_param->driver) + mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_NoSuchDriver, tv_param->driver); + else + mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_DriverAutoDetectionFailed); return(NULL); } -- cgit v1.2.3