From 3d290a162cde580c49609bffb0e177922c08b3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Fri, 24 May 2013 05:04:01 -0400 Subject: [PATCH] plugins: add gst_vaapi_create_display() helper. https://bugzilla.gnome.org/show_bug.cgi?id=703235 Signed-off-by: Gwenole Beauchesne --- gst/vaapi/gstvaapipluginutil.c | 49 ++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/gst/vaapi/gstvaapipluginutil.c b/gst/vaapi/gstvaapipluginutil.c index fe7b2b7656..86d28eecc1 100644 --- a/gst/vaapi/gstvaapipluginutil.c +++ b/gst/vaapi/gstvaapipluginutil.c @@ -86,6 +86,34 @@ static const DisplayMap g_display_map[] = { { NULL, } }; +static GstVaapiDisplay * +gst_vaapi_create_display(GstVaapiDisplayType *display_type) +{ + GstVaapiDisplay *display = NULL; + const DisplayMap *m; + + for (m = g_display_map; m->type_str != NULL; m++) { + if (*display_type != GST_VAAPI_DISPLAY_TYPE_ANY && + *display_type != m->type) + continue; + + display = m->create_display(NULL); + if (display) { + /* FIXME: allocator should return NULL if an error occurred */ + if (gst_vaapi_display_get_display(display)) { + *display_type = m->type; + break; + } + gst_vaapi_display_unref(display); + display = NULL; + } + + if (display_type != GST_VAAPI_DISPLAY_TYPE_ANY) + break; + } + return display; +} + gboolean gst_vaapi_ensure_display( gpointer element, @@ -95,7 +123,6 @@ gst_vaapi_ensure_display( { GstVaapiDisplay *display; GstVideoContext *context; - const DisplayMap *m; g_return_val_if_fail(GST_IS_VIDEO_CONTEXT(element), FALSE); g_return_val_if_fail(display_ptr != NULL, FALSE); @@ -115,25 +142,7 @@ gst_vaapi_ensure_display( return TRUE; /* If no neighboor, or application not interested, use system default */ - for (m = g_display_map; m->type_str != NULL; m++) { - if (display_type != GST_VAAPI_DISPLAY_TYPE_ANY && - display_type != m->type) - continue; - - display = m->create_display(NULL); - if (display) { - /* FIXME: allocator should return NULL if an error occurred */ - if (gst_vaapi_display_get_display(display)) { - display_type = m->type; - break; - } - gst_vaapi_display_unref(display); - display = NULL; - } - - if (display_type != GST_VAAPI_DISPLAY_TYPE_ANY) - break; - } + display = gst_vaapi_create_display(&display_type); if (display_ptr) *display_ptr = display;