static const guint g_display_types =
(1U << GST_VAAPI_DISPLAY_TYPE_X11) | (1U << GST_VAAPI_DISPLAY_TYPE_GLX);
-static inline const gchar *
-get_default_display_name (void)
+static gboolean
+parse_display_name (const gchar * name, guint * len_ptr, guint * id_ptr,
+ guint * screen_ptr)
{
- static const gchar *g_display_name;
+ gulong len, id = 0, screen = 0;
+ gchar *end;
- if (!g_display_name)
- g_display_name = getenv ("DISPLAY");
- return g_display_name;
+ end = strchr (name, ':');
+ len = end ? end - name : strlen (name);
+
+ if (end) {
+ id = strtoul (&end[1], &end, 10);
+ if (*end == '.')
+ screen = strtoul (&end[1], &end, 10);
+ if (*end != '\0')
+ return FALSE;
+ }
+
+ if (len_ptr)
+ *len_ptr = len;
+ if (id_ptr)
+ *id_ptr = id;
+ if (screen_ptr)
+ *screen_ptr = screen;
+ return TRUE;
}
static gint
compare_display_name (gconstpointer a, gconstpointer b)
{
const GstVaapiDisplayInfo *const info = a;
- const gchar *cached_name = info->display_name, *cached_name_end;
- const gchar *tested_name = b, *tested_name_end;
- guint cached_name_length, tested_name_length;
+ const gchar *const cached_name = info->display_name;
+ const gchar *const tested_name = b;
+ guint cached_name_length, cached_id;
+ guint tested_name_length, tested_id;
g_return_val_if_fail (cached_name, FALSE);
g_return_val_if_fail (tested_name, FALSE);
- cached_name_end = strchr (cached_name, ':');
- if (cached_name_end)
- cached_name_length = cached_name_end - cached_name;
- else
- cached_name_length = strlen (cached_name);
-
- tested_name_end = strchr (tested_name, ':');
- if (tested_name_end)
- tested_name_length = tested_name_end - tested_name;
- else
- tested_name_length = strlen (tested_name);
-
+ if (!parse_display_name (cached_name, &cached_name_length, &cached_id, NULL))
+ return FALSE;
+ if (!parse_display_name (tested_name, &tested_name_length, &tested_id, NULL))
+ return FALSE;
if (cached_name_length != tested_name_length)
return FALSE;
if (strncmp (cached_name, tested_name, cached_name_length) != 0)
return FALSE;
-
- /* XXX: handle screen number? */
+ if (cached_id != tested_id)
+ return FALSE;
return TRUE;
}
+static inline const gchar *
+get_default_display_name (void)
+{
+ static const gchar *g_display_name;
+
+ if (!g_display_name)
+ g_display_name = getenv ("DISPLAY");
+ return g_display_name;
+}
+
/* Reconstruct a display name without our prefix */
static const gchar *
get_display_name (GstVaapiDisplayX11 * display)