plugins: check if display is set in sync

Since the context messages are sync'ed, the display assignation happens in the
same thread, hence we can know if the display was found or not as soon we call
for it.

In order to take advantage of it, gst_vaapi_video_context_prepare() receives,
as a new parameter, the address of the plugin's display, and reports back if
the display was found and set.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=757598
This commit is contained in:
Víctor Manuel Jáquez Leal 2015-10-30 12:27:16 +01:00
parent b45089f0f7
commit ef3fb4afaf
3 changed files with 23 additions and 16 deletions

View file

@ -235,11 +235,11 @@ gst_vaapi_ensure_display (GstElement * element, GstVaapiDisplayType type)
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
gst_vaapi_video_context_prepare (element);
/* Neighbour found and it updated the display */
if (gst_vaapi_plugin_base_has_display_type (plugin, type))
return TRUE;
if (gst_vaapi_video_context_prepare (element, &plugin->display)) {
/* Neighbour found and it updated the display */
if (gst_vaapi_plugin_base_has_display_type (plugin, type))
return TRUE;
}
/* If no neighboor, or application not interested, use system default */
if (plugin->gl_context)

View file

@ -178,21 +178,27 @@ found:
gst_query_unref (query);
}
void
gst_vaapi_video_context_prepare (GstElement * element)
gboolean
gst_vaapi_video_context_prepare (GstElement * element,
GstVaapiDisplay ** display_ptr)
{
g_return_if_fail (element != NULL);
g_return_val_if_fail (element != NULL, FALSE);
g_return_val_if_fail (display_ptr != NULL, FALSE);
/* 1) Check if the element already has a context of the specific
* type, i.e. it was previously set via
* gst_element_set_context(). */
/* This was already done by the caller of this function:
* gst_vaapi_ensure_display() */
* type.
*/
if (*display_ptr) {
GST_LOG_OBJECT (element, "already have a display (%p)", *display_ptr);
return TRUE;
}
_gst_context_query (element, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME);
/* The check of an usable context is done by the caller:
gst_vaapi_ensure_display() */
if (*display_ptr)
GST_LOG_OBJECT (element, "found a display (%p)", *display_ptr);
return *display_ptr != NULL;
}
/* 5) Create a context by itself and post a GST_MESSAGE_HAVE_CONTEXT message

View file

@ -42,8 +42,9 @@ gst_vaapi_video_context_get_display (GstContext * context,
GstVaapiDisplay ** display_ptr);
G_GNUC_INTERNAL
void
gst_vaapi_video_context_prepare (GstElement * element);
gboolean
gst_vaapi_video_context_prepare (GstElement * element,
GstVaapiDisplay ** display_ptr);
G_GNUC_INTERNAL
void