]> git.sesse.net Git - vlc/blobdiff - modules/video_output/xcb/xvideo.c
Move x11-display config to core
[vlc] / modules / video_output / xcb / xvideo.c
index 6c6ea5feb362b334ae3fca8a31b517bceaf22f9c..a16cb6be0e58413500019680875cecfeb18e55c6 100644 (file)
 #include <vlc_plugin.h>
 #include <vlc_vout_display.h>
 #include <vlc_picture_pool.h>
+#include <vlc_dialog.h>
 
 #include "xcb_vlc.h"
 
-#define DISPLAY_TEXT N_("X11 display")
-#define DISPLAY_LONGTEXT N_( \
-    "X11 hardware display to use. By default, VLC will " \
-    "use the value of the DISPLAY environment variable.")
-
 #define ADAPTOR_TEXT N_("XVideo adaptor number")
 #define ADAPTOR_LONGTEXT N_( \
     "XVideo hardware adaptor to use. By default, VLC will " \
@@ -66,9 +62,6 @@ vlc_module_begin ()
     set_capability ("vout display", 155)
     set_callbacks (Open, Close)
 
-    add_string ("x11-display", NULL, NULL,
-                DISPLAY_TEXT, DISPLAY_LONGTEXT, true)
-        add_deprecated_alias ("xvideo-display")
     add_integer ("xvideo-adaptor", -1, NULL,
                  ADAPTOR_TEXT, ADAPTOR_LONGTEXT, true)
     add_bool ("x11-shm", true, NULL, SHM_TEXT, SHM_LONGTEXT, true)
@@ -269,6 +262,19 @@ FindFormat (vout_display_t *vd,
             msg_Warn (vd, "incompatible size %ux%u -> %"PRIu32"x%"PRIu32,
                       fmt->i_width, fmt->i_height,
                       i->width, i->height);
+            var_Create (vd->p_libvlc, "xvideo-resolution-error", VLC_VAR_BOOL);
+            if (!var_GetBool (vd->p_libvlc, "xvideo-resolution-error"))
+            {
+                dialog_FatalWait (vd, _("Video acceleration not available"),
+                    _("Your video output acceleration driver does not support "
+                      "the required resolution: %ux%u pixels. The maximum "
+                      "supported resolution is %"PRIu32"x%"PRIu32".\n"
+                      "Video output acceleration will be disabled. However, "
+                      "rendering videos with overly large resolution "
+                      "may cause severe performance degration."),
+                                  width, height, i->width, i->height);
+                var_SetBool (vd->p_libvlc, "xvideo-resolution-error", true);
+            }
             free (i);
             continue;
         }
@@ -292,41 +298,32 @@ static int Open (vlc_object_t *obj)
     vd->sys = p_sys;
 
     /* Connect to X */
-    xcb_connection_t *conn = Connect (obj);
-    if (conn == NULL)
+    xcb_connection_t *conn;
+    const xcb_screen_t *screen;
+    uint8_t depth;
+    p_sys->embed = GetWindow (vd, &conn, &screen, &depth, &p_sys->shm);
+    if (p_sys->embed == NULL)
     {
         free (p_sys);
         return VLC_EGENERIC;
     }
+
     p_sys->conn = conn;
+    p_sys->att = NULL;
+    p_sys->pool = NULL;
 
     if (!CheckXVideo (vd, conn))
     {
         msg_Warn (vd, "Please enable XVideo 2.2 for faster video display");
-        xcb_disconnect (conn);
-        free (p_sys);
-        return VLC_EGENERIC;
-    }
-
-    const xcb_screen_t *screen;
-    uint8_t depth;
-    p_sys->embed = GetWindow (vd, conn, &screen, &depth, &p_sys->shm);
-    if (p_sys->embed == NULL)
-    {
-        xcb_disconnect (conn);
-        free (p_sys);
-        return VLC_EGENERIC;
+        goto error;
     }
 
-    /* */
-    p_sys->att = NULL;
-    p_sys->pool = NULL;
     p_sys->window = xcb_generate_id (conn);
 
     /* Cache adaptors infos */
     xcb_xv_query_adaptors_reply_t *adaptors =
         xcb_xv_query_adaptors_reply (conn,
-            xcb_xv_query_adaptors (conn, p_sys->embed->handle.xid), NULL);
+            xcb_xv_query_adaptors (conn, p_sys->embed->xid), NULL);
     if (adaptors == NULL)
         goto error;
 
@@ -450,7 +447,7 @@ static int Open (vlc_object_t *obj)
             xcb_void_cookie_t c;
 
             c = xcb_create_window_checked (conn, f->depth, p_sys->window,
-                 p_sys->embed->handle.xid, 0, 0, 1, 1, 0,
+                 p_sys->embed->xid, 0, 0, 1, 1, 0,
                  XCB_WINDOW_CLASS_INPUT_OUTPUT, f->visual,
                  XCB_CW_EVENT_MASK, &mask);
 
@@ -557,8 +554,8 @@ static void Close (vlc_object_t *obj)
     }
 
     free (p_sys->att);
-    vout_display_DeleteWindow (vd, p_sys->embed);
     xcb_disconnect (p_sys->conn);
+    vout_display_DeleteWindow (vd, p_sys->embed);
     free (p_sys);
 }
 
@@ -698,7 +695,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
     {
         const vout_display_cfg_t *cfg;
         const video_format_t *source;
-        bool is_forced;
+        bool is_forced = false;
 
         if (query == VOUT_DISPLAY_CHANGE_SOURCE_ASPECT
          || query == VOUT_DISPLAY_CHANGE_SOURCE_CROP)
@@ -748,7 +745,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
     /* Hide the mouse. It will be send when
      * vout_display_t::info.b_hide_mouse is false */
     case VOUT_DISPLAY_HIDE_MOUSE:
-        xcb_change_window_attributes (p_sys->conn, p_sys->embed->handle.xid,
+        xcb_change_window_attributes (p_sys->conn, p_sys->embed->xid,
                                   XCB_CW_CURSOR, &(uint32_t){ p_sys->cursor });
         return VLC_SUCCESS;
     case VOUT_DISPLAY_RESET_PICTURES: