From 63a76c9dd0da2ec28a64e21fbf018c13f5b713a0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Fri, 29 Sep 2017 15:07:47 +0200 Subject: [PATCH] libs: display: delay getting screen resolution Instead of extracting the screen resolution at GstVaapiDisplay creation, this patch delay it until the screen size is requested for first time. https://bugzilla.gnome.org/show_bug.cgi?id=782212 --- gst-libs/gst/vaapi/gstvaapidisplay.c | 32 ++++++++++++++++++++++++++----- gst-libs/gst/vaapi/gstvaapidisplay_priv.h | 1 + 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.c b/gst-libs/gst/vaapi/gstvaapidisplay.c index 30abf91..0e80f9c 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay.c +++ b/gst-libs/gst/vaapi/gstvaapidisplay.c @@ -783,6 +783,25 @@ gst_vaapi_display_calculate_pixel_aspect_ratio (GstVaapiDisplay * display) } static void +gst_vaapi_display_ensure_screen_resolution (GstVaapiDisplay * display) +{ + GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display); + const GstVaapiDisplayClass *const klass = + GST_VAAPI_DISPLAY_GET_CLASS (display); + + if (priv->got_scrres) + return; + + if (klass->get_size) + klass->get_size (display, &priv->width, &priv->height); + if (klass->get_size_mm) + klass->get_size_mm (display, &priv->width_mm, &priv->height_mm); + + gst_vaapi_display_calculate_pixel_aspect_ratio (display); + priv->got_scrres = TRUE; +} + +static void gst_vaapi_display_destroy (GstVaapiDisplay * display) { GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display); @@ -869,11 +888,6 @@ gst_vaapi_display_create_unlocked (GstVaapiDisplay * display, return FALSE; priv->display = info.va_display; priv->native_display = info.native_display; - if (klass->get_size) - klass->get_size (display, &priv->width, &priv->height); - if (klass->get_size_mm) - klass->get_size_mm (display, &priv->width_mm, &priv->height_mm); - gst_vaapi_display_calculate_pixel_aspect_ratio (display); break; } if (!priv->display) @@ -1379,6 +1393,8 @@ gst_vaapi_display_get_width (GstVaapiDisplay * display) { g_return_val_if_fail (display != NULL, 0); + gst_vaapi_display_ensure_screen_resolution (display); + return GST_VAAPI_DISPLAY_GET_PRIVATE (display)->width; } @@ -1395,6 +1411,8 @@ gst_vaapi_display_get_height (GstVaapiDisplay * display) { g_return_val_if_fail (display != NULL, 0); + gst_vaapi_display_ensure_screen_resolution (display); + return GST_VAAPI_DISPLAY_GET_PRIVATE (display)->height; } @@ -1412,6 +1430,8 @@ gst_vaapi_display_get_size (GstVaapiDisplay * display, guint * pwidth, { g_return_if_fail (GST_VAAPI_DISPLAY (display)); + gst_vaapi_display_ensure_screen_resolution (display); + if (pwidth) *pwidth = GST_VAAPI_DISPLAY_GET_PRIVATE (display)->width; @@ -1433,6 +1453,8 @@ gst_vaapi_display_get_pixel_aspect_ratio (GstVaapiDisplay * display, { g_return_if_fail (display != NULL); + gst_vaapi_display_ensure_screen_resolution (display); + if (par_n) *par_n = GST_VAAPI_DISPLAY_GET_PRIVATE (display)->par_n; diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_priv.h b/gst-libs/gst/vaapi/gstvaapidisplay_priv.h index 20b2bce..7f96208 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay_priv.h +++ b/gst-libs/gst/vaapi/gstvaapidisplay_priv.h @@ -128,6 +128,7 @@ struct _GstVaapiDisplayPrivate guint use_foreign_display:1; guint has_vpp:1; guint has_profiles:1; + guint got_scrres:1; }; /** -- 2.7.4