vaapisink: fix initialization with "drm" display type.

Force early initializatin of the GstVaapiDisplay so that to make sure
that the sink element display object is presented first to upstream
elements, as it will be correctly featuring the requested display type
by the user.

Otherwise, we might end up in situations where a VA/X11 display is
initialized in vaapidecode, then we try VA/DRM display in vaapisink
(as requested by the "display" property), but this would cause a failure
because we cannot acquire a DRM display that was previously acquired
through another backend (e.g. VA/X11).
This commit is contained in:
Gwenole Beauchesne 2014-03-07 17:40:34 +01:00
parent eef863f82f
commit 5e5d62cac7

View file

@ -898,10 +898,14 @@ gst_vaapisink_show_frame_glx(
guint flags
)
{
GstVaapiWindowGLX * const window = GST_VAAPI_WINDOW_GLX(sink->window);
GstVaapiWindowGLX *window;
GLenum target;
GLuint texture;
if (!sink->window)
return FALSE;
window = GST_VAAPI_WINDOW_GLX(sink->window);
gst_vaapi_window_glx_make_current(window);
if (!gst_vaapisink_ensure_texture(sink, surface))
goto error_create_texture;
@ -960,6 +964,9 @@ gst_vaapisink_put_surface(
guint flags
)
{
if (!sink->window)
return FALSE;
if (!gst_vaapi_window_put_surface(sink->window, surface,
surface_rect, &sink->display_rect, flags)) {
GST_DEBUG("could not render VA surface");
@ -1004,9 +1011,6 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *src_buffer)
GST_VAAPI_PLUGIN_BASE_DISPLAY_REPLACE(sink,
gst_vaapi_video_meta_get_display(meta));
if (!sink->window)
goto error;
gst_vaapisink_ensure_rotation(sink, TRUE);
surface = gst_vaapi_video_meta_get_surface(meta);
@ -1206,6 +1210,19 @@ gst_vaapisink_get_property(
}
}
static void
gst_vaapisink_set_bus(GstElement *element, GstBus *bus)
{
/* Make sure to allocate a VA display in the sink element first,
so that upstream elements could query a display that was
allocated here, and that exactly matches what the user
requested through the "display" property */
if (!GST_ELEMENT_BUS(element) && bus)
gst_vaapisink_ensure_display(GST_VAAPISINK(element));
GST_ELEMENT_CLASS(gst_vaapisink_parent_class)->set_bus(element, bus);
}
static void
gst_vaapisink_class_init(GstVaapiSinkClass *klass)
{
@ -1240,6 +1257,7 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
basesink_class->buffer_alloc = gst_vaapisink_buffer_alloc;
#endif
element_class->set_bus = gst_vaapisink_set_bus;
gst_element_class_set_static_metadata(element_class,
"VA-API sink",
"Sink/Video",