mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
display: drop internal NAME_PREFIX, store the real display name.
Always store a valid display name/device path, instead of adding a particular prefix. i.e. make it simply a strdup(), or "" if it was initially NULL.
This commit is contained in:
parent
71ab07d9c6
commit
b40cd3b382
3 changed files with 11 additions and 83 deletions
|
@ -39,17 +39,8 @@
|
|||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
||||
#define NAME_PREFIX "DRM:"
|
||||
#define NAME_PREFIX_LENGTH 4
|
||||
|
||||
static const guint g_display_types = 1U << GST_VAAPI_DISPLAY_TYPE_DRM;
|
||||
|
||||
static inline gboolean
|
||||
is_device_path(const gchar *device_path)
|
||||
{
|
||||
return strncmp(device_path, NAME_PREFIX, NAME_PREFIX_LENGTH) == 0;
|
||||
}
|
||||
|
||||
/* Get default device path. Actually, the first match in the DRM subsystem */
|
||||
static const gchar *
|
||||
get_default_device_path(GstVaapiDisplay *display)
|
||||
|
@ -113,13 +104,7 @@ get_device_path(GstVaapiDisplay *display)
|
|||
GST_VAAPI_DISPLAY_DRM_PRIVATE(display);
|
||||
const gchar *device_path = priv->device_path;
|
||||
|
||||
if (!device_path)
|
||||
return NULL;
|
||||
|
||||
g_return_val_if_fail(is_device_path(device_path), NULL);
|
||||
|
||||
device_path += NAME_PREFIX_LENGTH;
|
||||
if (*device_path == '\0')
|
||||
if (!device_path || *device_path == '\0')
|
||||
return NULL;
|
||||
return device_path;
|
||||
}
|
||||
|
@ -139,7 +124,7 @@ set_device_path(GstVaapiDisplay *display, const gchar *device_path)
|
|||
if (!device_path)
|
||||
return FALSE;
|
||||
}
|
||||
priv->device_path = g_strdup_printf("%s%s", NAME_PREFIX, device_path);
|
||||
priv->device_path = g_strdup(device_path);
|
||||
return priv->device_path != NULL;
|
||||
}
|
||||
|
||||
|
@ -198,7 +183,7 @@ set_device_path_from_fd(GstVaapiDisplay *display, gint drm_device)
|
|||
continue;
|
||||
|
||||
path = udev_device_get_devnode(device);
|
||||
priv->device_path = g_strdup_printf("%s%s", NAME_PREFIX, path);
|
||||
priv->device_path = g_strdup(path);
|
||||
udev_device_unref(device);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -33,17 +33,8 @@
|
|||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
||||
#define NAME_PREFIX "WLD:"
|
||||
#define NAME_PREFIX_LENGTH 4
|
||||
|
||||
static const guint g_display_types = 1U << GST_VAAPI_DISPLAY_TYPE_WAYLAND;
|
||||
|
||||
static inline gboolean
|
||||
is_display_name(const gchar *display_name)
|
||||
{
|
||||
return strncmp(display_name, NAME_PREFIX, NAME_PREFIX_LENGTH) == 0;
|
||||
}
|
||||
|
||||
static inline const gchar *
|
||||
get_default_display_name(void)
|
||||
{
|
||||
|
@ -73,13 +64,10 @@ compare_display_name(gconstpointer a, gconstpointer b)
|
|||
const gchar *tested_name = b;
|
||||
guint cached_name_length, tested_name_length;
|
||||
|
||||
if (!cached_name || !is_display_name(cached_name))
|
||||
return FALSE;
|
||||
cached_name += NAME_PREFIX_LENGTH;
|
||||
cached_name_length = get_display_name_length(cached_name);
|
||||
g_return_val_if_fail(cached_name, FALSE);
|
||||
g_return_val_if_fail(tested_name, FALSE);
|
||||
|
||||
g_return_val_if_fail(tested_name && is_display_name(tested_name), FALSE);
|
||||
tested_name += NAME_PREFIX_LENGTH;
|
||||
cached_name_length = get_display_name_length(cached_name);
|
||||
tested_name_length = get_display_name_length(tested_name);
|
||||
|
||||
/* XXX: handle screen number and default WAYLAND_DISPLAY name */
|
||||
|
@ -90,29 +78,6 @@ compare_display_name(gconstpointer a, gconstpointer b)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/* Reconstruct a display name without our prefix */
|
||||
static const gchar *
|
||||
get_display_name(GstVaapiDisplayWayland *display)
|
||||
{
|
||||
GstVaapiDisplayWaylandPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(display);
|
||||
const gchar *display_name = priv->display_name;
|
||||
|
||||
if (!display_name)
|
||||
return NULL;
|
||||
|
||||
if (is_display_name(display_name)) {
|
||||
display_name += NAME_PREFIX_LENGTH;
|
||||
if (*display_name == '\0')
|
||||
return NULL;
|
||||
return display_name;
|
||||
}
|
||||
|
||||
/* XXX: this should not happen */
|
||||
g_assert(0 && "display name without prefix");
|
||||
return display_name;
|
||||
}
|
||||
|
||||
/* Mangle display name with our prefix */
|
||||
static gboolean
|
||||
set_display_name(GstVaapiDisplay *display, const gchar *display_name)
|
||||
|
@ -127,7 +92,7 @@ set_display_name(GstVaapiDisplay *display, const gchar *display_name)
|
|||
if (!display_name)
|
||||
display_name = "";
|
||||
}
|
||||
priv->display_name = g_strdup_printf("%s%s", NAME_PREFIX, display_name);
|
||||
priv->display_name = g_strdup(display_name);
|
||||
return priv->display_name != NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,19 +39,10 @@
|
|||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
||||
#define NAME_PREFIX "X11:"
|
||||
#define NAME_PREFIX_LENGTH 4
|
||||
|
||||
static const guint g_display_types =
|
||||
(1U << GST_VAAPI_DISPLAY_TYPE_X11) |
|
||||
(1U << GST_VAAPI_DISPLAY_TYPE_GLX);
|
||||
|
||||
static inline gboolean
|
||||
is_display_name(const gchar *display_name)
|
||||
{
|
||||
return strncmp(display_name, NAME_PREFIX, NAME_PREFIX_LENGTH) == 0;
|
||||
}
|
||||
|
||||
static inline const gchar *
|
||||
get_default_display_name(void)
|
||||
{
|
||||
|
@ -70,18 +61,15 @@ compare_display_name(gconstpointer a, gconstpointer b)
|
|||
const gchar *tested_name = b, *tested_name_end;
|
||||
guint cached_name_length, tested_name_length;
|
||||
|
||||
if (!cached_name || !is_display_name(cached_name))
|
||||
return FALSE;
|
||||
g_return_val_if_fail(tested_name && is_display_name(tested_name), FALSE);
|
||||
g_return_val_if_fail(cached_name, FALSE);
|
||||
g_return_val_if_fail(tested_name, FALSE);
|
||||
|
||||
cached_name += NAME_PREFIX_LENGTH;
|
||||
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 += NAME_PREFIX_LENGTH;
|
||||
tested_name_end = strchr(tested_name, ':');
|
||||
if (tested_name_end)
|
||||
tested_name_length = tested_name_end - tested_name;
|
||||
|
@ -104,18 +92,8 @@ get_display_name(GstVaapiDisplayX11 *display)
|
|||
GstVaapiDisplayX11Private * const priv = &display->priv;
|
||||
const gchar *display_name = priv->display_name;
|
||||
|
||||
if (!display_name)
|
||||
if (!display_name || *display_name == '\0')
|
||||
return NULL;
|
||||
|
||||
if (is_display_name(display_name)) {
|
||||
display_name += NAME_PREFIX_LENGTH;
|
||||
if (*display_name == '\0')
|
||||
return NULL;
|
||||
return display_name;
|
||||
}
|
||||
|
||||
/* XXX: this should not happen */
|
||||
g_assert(0 && "display name without prefix");
|
||||
return display_name;
|
||||
}
|
||||
|
||||
|
@ -132,7 +110,7 @@ set_display_name(GstVaapiDisplayX11 *display, const gchar *display_name)
|
|||
if (!display_name)
|
||||
display_name = "";
|
||||
}
|
||||
priv->display_name = g_strdup_printf("%s%s", NAME_PREFIX, display_name);
|
||||
priv->display_name = g_strdup(display_name);
|
||||
return priv->display_name != NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue