diff --git a/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c b/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c index 3530654f1f..10f34323d0 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c @@ -1119,16 +1119,14 @@ gst_va_av1_dec_register (GstPlugin * plugin, GstVaDevice * device, type_info.class_data = cdata; - type_name = g_strdup ("GstVaAV1Dec"); - feature_name = g_strdup ("vaav1dec"); - /* The first decoder to be registered should use a constant name, * like vaav1dec, for any additional decoders, we create unique * names, using inserting the render device name. */ - if (g_type_from_name (type_name)) { + if (device->index == 0) { + type_name = g_strdup ("GstVaAV1Dec"); + feature_name = g_strdup ("vaav1dec"); + } else { gchar *basename = g_path_get_basename (device->render_device_path); - g_free (type_name); - g_free (feature_name); type_name = g_strdup_printf ("GstVa%sAV1Dec", basename); feature_name = g_strdup_printf ("va%sav1dec", basename); cdata->description = basename; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvadevice.c b/subprojects/gst-plugins-bad/sys/va/gstvadevice.c index 33ab55ae73..832fc0ccbb 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvadevice.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvadevice.c @@ -42,7 +42,8 @@ gst_va_device_free (GstVaDevice * device) } static GstVaDevice * -gst_va_device_new (GstVaDisplay * display, const gchar * render_device_path) +gst_va_device_new (GstVaDisplay * display, const gchar * render_device_path, + gint index) { GstVaDevice *device = g_new0 (GstVaDevice, 1); @@ -52,6 +53,7 @@ gst_va_device_new (GstVaDisplay * display, const gchar * render_device_path) /* take ownership */ device->display = display; device->render_device_path = g_strdup (render_device_path); + device->index = index; return device; } @@ -61,7 +63,7 @@ compare_device_path (gconstpointer a, gconstpointer b, gpointer user_data) { const GstVaDevice *pa = a, *pb = b; - return strcmp (pa->render_device_path, pb->render_device_path); + return g_strcmp0 (pa->render_device_path, pb->render_device_path); } #if HAVE_GUDEV @@ -71,6 +73,7 @@ gst_va_device_find_devices (void) GUdevClient *client; GList *udev_devices, *dev; GQueue devices = G_QUEUE_INIT; + gint i = 0; client = g_udev_client_new (NULL); udev_devices = g_udev_client_query_by_subsystem (client, "drm"); @@ -90,7 +93,7 @@ gst_va_device_find_devices (void) continue; GST_INFO ("Found VA-API device: %s", path); - g_queue_push_head (&devices, gst_va_device_new (dpy, path)); + g_queue_push_head (&devices, gst_va_device_new (dpy, path, i++)); } g_queue_sort (&devices, compare_device_path, NULL); @@ -106,7 +109,7 @@ gst_va_device_find_devices (void) GstVaDisplay *dpy; GQueue devices = G_QUEUE_INIT; gchar path[64]; - guint i; + guint i, j = 0; for (i = 0; i < 8; i++) { g_snprintf (path, sizeof (path), "/dev/dri/renderD%d", 128 + i); @@ -117,7 +120,7 @@ gst_va_device_find_devices (void) continue; GST_INFO ("Found VA-API device: %s", path); - g_queue_push_head (&devices, gst_va_device_new (dpy, path)); + g_queue_push_head (&devices, gst_va_device_new (dpy, path, j++)); } g_queue_sort (&devices, compare_device_path, NULL); diff --git a/subprojects/gst-plugins-bad/sys/va/gstvadevice.h b/subprojects/gst-plugins-bad/sys/va/gstvadevice.h index 662acd377a..2ed498cf6b 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvadevice.h +++ b/subprojects/gst-plugins-bad/sys/va/gstvadevice.h @@ -36,6 +36,7 @@ typedef struct GstVaDisplay *display; gchar *render_device_path; + gint index; } GstVaDevice; GType gst_va_device_get_type (void); diff --git a/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c b/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c index d92a626039..559c5d5057 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c @@ -1034,16 +1034,14 @@ gst_va_h264_dec_register (GstPlugin * plugin, GstVaDevice * device, type_info.class_data = cdata; - type_name = g_strdup ("GstVaH264Dec"); - feature_name = g_strdup ("vah264dec"); - /* The first decoder to be registered should use a constant name, * like vah264dec, for any additional decoders, we create unique * names, using inserting the render device name. */ - if (g_type_from_name (type_name)) { + if (device->index == 0) { + type_name = g_strdup ("GstVaH264Dec"); + feature_name = g_strdup ("vah264dec"); + } else { gchar *basename = g_path_get_basename (device->render_device_path); - g_free (type_name); - g_free (feature_name); type_name = g_strdup_printf ("GstVa%sH264Dec", basename); feature_name = g_strdup_printf ("va%sh264dec", basename); cdata->description = basename; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c b/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c index f93d87ee61..17120cb593 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c @@ -3814,21 +3814,20 @@ gst_va_h264_enc_register (GstPlugin * plugin, GstVaDevice * device, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED); type_info.class_data = cdata; - if (entrypoint == VAEntrypointEncSlice) { - type_name = g_strdup ("GstVaH264Enc"); - feature_name = g_strdup ("vah264enc"); - } else { - type_name = g_strdup ("GstVaH264LPEnc"); - feature_name = g_strdup ("vah264lpenc"); - } /* The first encoder to be registered should use a constant name, * like vah264enc, for any additional encoders, we create unique * names, using inserting the render device name. */ - if (g_type_from_name (type_name)) { + if (device->index == 0) { + if (entrypoint == VAEntrypointEncSlice) { + type_name = g_strdup ("GstVaH264Enc"); + feature_name = g_strdup ("vah264enc"); + } else { + type_name = g_strdup ("GstVaH264LPEnc"); + feature_name = g_strdup ("vah264lpenc"); + } + } else { gchar *basename = g_path_get_basename (device->render_device_path); - g_free (type_name); - g_free (feature_name); if (entrypoint == VAEntrypointEncSlice) { type_name = g_strdup_printf ("GstVa%sH264Enc", basename); feature_name = g_strdup_printf ("va%sh264enc", basename); diff --git a/subprojects/gst-plugins-bad/sys/va/gstvah265dec.c b/subprojects/gst-plugins-bad/sys/va/gstvah265dec.c index 3cf526af88..45b6c78b7e 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvah265dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvah265dec.c @@ -1380,16 +1380,14 @@ gst_va_h265_dec_register (GstPlugin * plugin, GstVaDevice * device, type_info.class_data = cdata; - type_name = g_strdup ("GstVaH265Dec"); - feature_name = g_strdup ("vah265dec"); - /* The first decoder to be registered should use a constant name, * like vah265dec, for any additional decoders, we create unique * names, using inserting the render device name. */ - if (g_type_from_name (type_name)) { + if (device->index == 0) { + type_name = g_strdup ("GstVaH265Dec"); + feature_name = g_strdup ("vah265dec"); + } else { gchar *basename = g_path_get_basename (device->render_device_path); - g_free (type_name); - g_free (feature_name); type_name = g_strdup_printf ("GstVa%sH265Dec", basename); feature_name = g_strdup_printf ("va%sh265dec", basename); cdata->description = basename; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvah265enc.c b/subprojects/gst-plugins-bad/sys/va/gstvah265enc.c index 8a7034da0d..6d6537cdc3 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvah265enc.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvah265enc.c @@ -5292,21 +5292,20 @@ gst_va_h265_enc_register (GstPlugin * plugin, GstVaDevice * device, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED); type_info.class_data = cdata; - if (entrypoint == VAEntrypointEncSlice) { - type_name = g_strdup ("GstVaH265Enc"); - feature_name = g_strdup ("vah265enc"); - } else { - type_name = g_strdup ("GstVaH265LPEnc"); - feature_name = g_strdup ("vah265lpenc"); - } /* The first encoder to be registered should use a constant name, * like vah265enc, for any additional encoders, we create unique * names, using inserting the render device name. */ - if (g_type_from_name (type_name)) { + if (device->index == 0) { + if (entrypoint == VAEntrypointEncSlice) { + type_name = g_strdup ("GstVaH265Enc"); + feature_name = g_strdup ("vah265enc"); + } else { + type_name = g_strdup ("GstVaH265LPEnc"); + feature_name = g_strdup ("vah265lpenc"); + } + } else { gchar *basename = g_path_get_basename (device->render_device_path); - g_free (type_name); - g_free (feature_name); if (entrypoint == VAEntrypointEncSlice) { type_name = g_strdup_printf ("GstVa%sH265Enc", basename); feature_name = g_strdup_printf ("va%sh265enc", basename); @@ -5315,6 +5314,7 @@ gst_va_h265_enc_register (GstPlugin * plugin, GstVaDevice * device, feature_name = g_strdup_printf ("va%sh265lpenc", basename); } cdata->description = basename; + /* lower rank for non-first device */ if (rank > 0) rank--; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c b/subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c index a6e5a3f06c..2a00cb6643 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c @@ -623,16 +623,15 @@ gst_va_jpeg_dec_register (GstPlugin * plugin, GstVaDevice * device, type_info.class_data = cdata; - type_name = g_strdup ("GstVaJpegDec"); - feature_name = g_strdup ("vajpegdec"); /* The first decoder to be registered should use a constant name, * like vajpegdec, for any additional decoders, we create unique * names, using inserting the render device name. */ - if (g_type_from_name (type_name)) { + if (device->index == 0) { + type_name = g_strdup ("GstVaJpegDec"); + feature_name = g_strdup ("vajpegdec"); + } else { gchar *basename = g_path_get_basename (device->render_device_path); - g_free (type_name); - g_free (feature_name); type_name = g_strdup_printf ("GstVa%sJpegDec", basename); feature_name = g_strdup_printf ("va%sjpegdec", basename); cdata->description = basename; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c b/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c index 69be39c47c..06020e4910 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c @@ -712,16 +712,14 @@ gst_va_mpeg2_dec_register (GstPlugin * plugin, GstVaDevice * device, type_info.class_data = cdata; - type_name = g_strdup ("GstVaMpeg2Dec"); - feature_name = g_strdup ("vampeg2dec"); - /* The first decoder to be registered should use a constant name, * like vampeg2dec, for any additional decoders, we create unique * names, using inserting the render device name. */ - if (g_type_from_name (type_name)) { + if (device->index == 0) { + type_name = g_strdup ("GstVaMpeg2Dec"); + feature_name = g_strdup ("vampeg2dec"); + } else { gchar *basename = g_path_get_basename (device->render_device_path); - g_free (type_name); - g_free (feature_name); type_name = g_strdup_printf ("GstVa%sMpeg2Dec", basename); feature_name = g_strdup_printf ("va%smpeg2dec", basename); cdata->description = basename; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c b/subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c index 50d721d6a4..0b782317ba 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c @@ -581,16 +581,14 @@ gst_va_vp8_dec_register (GstPlugin * plugin, GstVaDevice * device, type_info.class_data = cdata; - type_name = g_strdup ("GstVaVp8Dec"); - feature_name = g_strdup ("vavp8dec"); - /* The first decoder to be registered should use a constant name, * like vavp8dec, for any additional decoders, we create unique * names, using inserting the render device name. */ - if (g_type_from_name (type_name)) { + if (device->index == 0) { + type_name = g_strdup ("GstVaVp8Dec"); + feature_name = g_strdup ("vavp8dec"); + } else { gchar *basename = g_path_get_basename (device->render_device_path); - g_free (type_name); - g_free (feature_name); type_name = g_strdup_printf ("GstVa%sVp8Dec", basename); feature_name = g_strdup_printf ("va%svp8dec", basename); cdata->description = basename; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c b/subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c index 45807f5c9a..136de0ca66 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c @@ -740,16 +740,14 @@ gst_va_vp9_dec_register (GstPlugin * plugin, GstVaDevice * device, type_info.class_data = cdata; - type_name = g_strdup ("GstVaVp9Dec"); - feature_name = g_strdup ("vavp9dec"); - /* The first decoder to be registered should use a constant name, * like vavp9dec, for any additional decoders, we create unique * names, using inserting the render device name. */ - if (g_type_from_name (type_name)) { + if (device->index == 0) { + type_name = g_strdup ("GstVaVp9Dec"); + feature_name = g_strdup ("vavp9dec"); + } else { gchar *basename = g_path_get_basename (device->render_device_path); - g_free (type_name); - g_free (feature_name); type_name = g_strdup_printf ("GstVa%sVp9Dec", basename); feature_name = g_strdup_printf ("va%svp9dec", basename); cdata->description = basename;