From b98924208bd3724d9ad66085a802b5e18cad7ef6 Mon Sep 17 00:00:00 2001 From: Carl-Anton Ingmarsson Date: Sun, 27 Mar 2011 20:09:52 +0200 Subject: [PATCH] vdpausink: fix bug where we didn't setup vdpau on a user set window --- sys/vdpau/gstvdpsink.c | 75 +++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/sys/vdpau/gstvdpsink.c b/sys/vdpau/gstvdpsink.c index 43afc559a0..31a3d5926d 100644 --- a/sys/vdpau/gstvdpsink.c +++ b/sys/vdpau/gstvdpsink.c @@ -158,20 +158,54 @@ gst_vdp_sink_window_set_title (VdpSink * vdp_sink, } } +static void +gst_vdp_sink_window_setup_vdpau (VdpSink * vdp_sink, GstVdpWindow * window) +{ + GstVdpDevice *device = vdp_sink->device; + VdpStatus status; + VdpColor color = { 0, }; + + status = device->vdp_presentation_queue_target_create_x11 (device->device, + window->win, &window->target); + if (status != VDP_STATUS_OK) { + GST_ELEMENT_ERROR (vdp_sink, RESOURCE, READ, + ("Could not create presentation target"), + ("Error returned from vdpau was: %s", + device->vdp_get_error_string (status))); + } + + status = + device->vdp_presentation_queue_create (device->device, window->target, + &window->queue); + if (status != VDP_STATUS_OK) { + GST_ELEMENT_ERROR (vdp_sink, RESOURCE, READ, + ("Could not create presentation queue"), + ("Error returned from vdpau was: %s", + device->vdp_get_error_string (status))); + } + + status = + device->vdp_presentation_queue_set_background_color (window->queue, + &color); + if (status != VDP_STATUS_OK) { + GST_ELEMENT_ERROR (vdp_sink, RESOURCE, READ, + ("Could not set background color"), + ("Error returned from vdpau was: %s", + device->vdp_get_error_string (status))); + } +} + /* This function handles a GstVdpWindow creation */ static GstVdpWindow * gst_vdp_sink_window_new (VdpSink * vdp_sink, gint width, gint height) { - GstVdpWindow *window = NULL; GstVdpDevice *device = vdp_sink->device; + GstVdpWindow *window = NULL; Window root; gint screen_num; gulong black; - VdpStatus status; - VdpColor color = { 0, }; - g_return_val_if_fail (GST_IS_VDP_SINK (vdp_sink), NULL); window = g_new0 (GstVdpWindow, 1); @@ -218,35 +252,7 @@ gst_vdp_sink_window_new (VdpSink * vdp_sink, gint width, gint height) g_mutex_unlock (vdp_sink->x_lock); gst_vdp_sink_window_decorate (vdp_sink, window); - - status = device->vdp_presentation_queue_target_create_x11 (device->device, - window->win, &window->target); - if (status != VDP_STATUS_OK) { - GST_ELEMENT_ERROR (vdp_sink, RESOURCE, READ, - ("Could not create presentation target"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); - } - - status = - device->vdp_presentation_queue_create (device->device, window->target, - &window->queue); - if (status != VDP_STATUS_OK) { - GST_ELEMENT_ERROR (vdp_sink, RESOURCE, READ, - ("Could not create presentation queue"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); - } - - status = - device->vdp_presentation_queue_set_background_color (window->queue, - &color); - if (status != VDP_STATUS_OK) { - GST_ELEMENT_ERROR (vdp_sink, RESOURCE, READ, - ("Could not set background color"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); - } + gst_vdp_sink_window_setup_vdpau (vdp_sink, window); gst_x_overlay_got_window_handle (GST_X_OVERLAY (vdp_sink), (guintptr) window->win); @@ -1161,8 +1167,9 @@ gst_vdp_sink_set_window_handle (GstXOverlay * overlay, guintptr window_handle) StructureNotifyMask | PointerMotionMask | KeyPressMask | KeyReleaseMask); } - g_mutex_unlock (vdp_sink->x_lock); + + gst_vdp_sink_window_setup_vdpau (vdp_sink, window); } if (window)