Index: sys/xvimage/xvimagesink.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/sys/xvimage/xvimagesink.c,v
retrieving revision 1.171
diff -u -p -u -p -r1.171 xvimagesink.c
--- sys/xvimage/xvimagesink.c	24 Nov 2006 08:35:23 -0000	1.171
+++ sys/xvimage/xvimagesink.c	9 Dec 2006 11:06:15 -0000
@@ -674,12 +674,16 @@ gst_xvimagesink_xvimage_put (GstXvImageS
   gboolean draw_border = FALSE;
 
   g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
-  g_return_if_fail (xvimagesink->xwindow != NULL);
 
   /* We take the flow_lock. If expose is in there we don't want to run
      concurrently from the data flow thread */
   g_mutex_lock (xvimagesink->flow_lock);
 
+  if (xvimagesink->xwindow == NULL) {
+    g_mutex_unlock (xvimagesink->flow_lock);
+    return;
+  }
+
   /* Draw borders when displaying the first frame. After this
      draw borders only on expose event. */
   if (!xvimagesink->cur_image) {
@@ -2321,17 +2325,21 @@ gst_xvimagesink_set_xwindow_id (GstXOver
 
   g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
 
+  g_mutex_lock (xvimagesink->flow_lock);
+
   /* If we already use that window return */
-  if (xvimagesink->xwindow && (xwindow_id == xvimagesink->xwindow->win))
+  if (xvimagesink->xwindow && (xwindow_id == xvimagesink->xwindow->win)) {
+    g_mutex_unlock (xvimagesink->flow_lock);
     return;
+  }
 
   /* If the element has not initialized the X11 context try to do so */
   if (!xvimagesink->xcontext &&
-      !(xvimagesink->xcontext = gst_xvimagesink_xcontext_get (xvimagesink)))
+      !(xvimagesink->xcontext = gst_xvimagesink_xcontext_get (xvimagesink))) {
     /* we have thrown a GST_ELEMENT_ERROR now */
+    g_mutex_unlock (xvimagesink->flow_lock);
     return;
-
-  g_mutex_lock (xvimagesink->flow_lock);
+  }
 
   gst_xvimagesink_update_colorbalance (xvimagesink);
 
