diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2008-02-01 02:17:09 +0000 |
---|---|---|
committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2008-02-01 02:17:09 +0000 |
commit | 3123c1c76b8eb9e6236f9d17dc6e283281495def (patch) | |
tree | ad795409d18959729dcc7f0163914bcc6fcf4fd4 | |
parent | d865cc45e9f9c9d9e1dfeef714cf7221d39fb3e8 (diff) | |
download | xine-lib-3123c1c76b8eb9e6236f9d17dc6e283281495def.tar.gz xine-lib-3123c1c76b8eb9e6236f9d17dc6e283281495def.tar.bz2 |
Fallback to auto-detect when the specified Xv port is unavailable or unusable.
-rw-r--r-- | src/video_out/video_out_xv.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index da679d088..61b2638ec 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -1137,8 +1137,25 @@ static void xv_update_xv_pitch_alignment(void *this_gen, xine_cfg_entry_t *entry } static int xv_open_port (xv_driver_t *this, XvPortID port) { - return ! xv_check_yv12(this->display, port) + int ret; + x11_InstallXErrorHandler (this); + ret = ! xv_check_yv12(this->display, port) && XvGrabPort(this->display, port, 0) == Success; + x11_DeInstallXErrorHandler (this); + return ret; +} + +static unsigned int +xv_find_adaptor_by_port (int port, unsigned int adaptors, + XvAdaptorInfo *adaptor_info) +{ + unsigned int an; + for (an = 0; an < adaptors; an++) + if (adaptor_info[an].type & XvImageMask) + if (port >= adaptor_info[an].base_id && + port < adaptor_info[an].base_id + adaptor_info[an].num_ports) + return an; + return 0; /* shouldn't happen */ } static XvPortID xv_autodetect_port(xv_driver_t *this, @@ -1221,8 +1238,13 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * 10, NULL, NULL); if (xv_port != 0) { - if (! xv_open_port(this, xv_port)) - xv_port = 0; + if (! xv_open_port(this, xv_port)) { + xprintf(class->xine, XINE_VERBOSITY_NONE, + _("%s: could not open Xv port %d - autodetecting\n"), + LOG_MODULE, xv_port); + xv_port = xv_autodetect_port(this, adaptors, adaptor_info, &adaptor_num); + } else + adaptor_num = xv_find_adaptor_by_port (xv_port, adaptors, adaptor_info); } else xv_port = xv_autodetect_port(this, adaptors, adaptor_info, &adaptor_num); |