--- ximagesink.c.orig	2006-11-29 21:09:20.000000000 +0200
+++ ximagesink.c	2006-12-08 12:46:27.000000000 +0200
@@ -1274,6 +1275,8 @@
     gst_x_overlay_prepare_xwindow_id (GST_X_OVERLAY (ximagesink));
   }
 
+  g_mutex_lock (ximagesink->flow_lock);
+
   /* Creating our window and our image */
   g_assert (GST_VIDEO_SINK_WIDTH (ximagesink) > 0);
   g_assert (GST_VIDEO_SINK_HEIGHT (ximagesink) > 0);
@@ -1281,6 +1284,8 @@
     ximagesink->xwindow = gst_ximagesink_xwindow_new (ximagesink,
         GST_VIDEO_SINK_WIDTH (ximagesink), GST_VIDEO_SINK_HEIGHT (ximagesink));
   }
+  
+  g_mutex_unlock (ximagesink->flow_lock);
 
   /* If our ximage has changed we destroy it, next chain iteration will create
      a new one */
