summaryrefslogtreecommitdiffstats
path: root/stream/tv.c
diff options
context:
space:
mode:
authorvoroshil <voroshil@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-09-10 17:09:35 +0000
committervoroshil <voroshil@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-09-10 17:09:35 +0000
commitdcc2e2e5ea5a3a8b055d43f859a0b6bfdcbfe31a (patch)
tree2218079ad9ec81e5acd152fd797b986de02dc8e4 /stream/tv.c
parent36a28b6f50ebaf8aa85d2a6a7b6388b842369da3 (diff)
downloadmpv-dcc2e2e5ea5a3a8b055d43f859a0b6bfdcbfe31a.tar.bz2
mpv-dcc2e2e5ea5a3a8b055d43f859a0b6bfdcbfe31a.tar.xz
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
Diffstat (limited to 'stream/tv.c')
-rw-r--r--stream/tv.c26
1 files changed, 18 insertions, 8 deletions
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);
}