fix define
authorThomas Vander Stichele <thomas@apestaart.org>
Tue, 11 Nov 2003 11:12:20 +0000 (11:12 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Tue, 11 Nov 2003 11:12:20 +0000 (11:12 +0000)
Original commit message from CVS:
fix define

sys/ximage/ximagesink.c
sys/ximage/ximagesink.h

index c5b4c2b..0b4fb07 100644 (file)
@@ -36,6 +36,12 @@ static GstElementDetails gst_ximagesink_details = GST_ELEMENT_DETAILS (
   "Julien Moutte <julien@moutte.net>"
 );
 
+enum
+{
+  ARG_0,
+  ARG_DISPLAY_NAME
+};
+
 /* Default template - initiated with class struct to allow gst-register to work
    without X running */
 GST_PAD_TEMPLATE_FACTORY (gst_ximagesink_sink_template_factory,
@@ -74,30 +80,18 @@ gst_ximagesink_interface_init (GstInterfaceClass *klass)
 }
 
 static void
-gst_ximagesink_navigation_send_event (GstNavigation *navigation, GstStructure *structure)
+gst_ximagesink_navigation_send_event (GstNavigation *navigation, GstCaps *caps)
 {
   GstXImageSink *ximagesink = GST_XIMAGESINK (navigation);
-  XWindowAttributes attr;
   GstEvent *event;
-  double x, y;
-
-  g_mutex_lock (ximagesink->x_lock);
-  XGetWindowAttributes (ximagesink->xcontext->disp,
-      ximagesink->xwindow->win, &attr);
-  g_mutex_unlock (ximagesink->x_lock);
 
   event = gst_event_new (GST_EVENT_NAVIGATION);
-  event->event_data.structure.structure = structure;
-  if(gst_structure_get_double(structure, "pointer_x", &x)){
-    x *= ximagesink->width;
-    x /= attr.width;
-    gst_structure_set(structure, "pointer_x", G_TYPE_DOUBLE, x, NULL);
-  }
-  if(gst_structure_get_double(structure, "pointer_y", &y)){
-    y *= ximagesink->height;
-    y /= attr.height;
-    gst_structure_set(structure, "pointer_y", G_TYPE_DOUBLE, y, NULL);
-  }
+  /*GST_EVENT_TIMESTAMP (event) = 0;*/
+  event->event_data.caps.caps = caps;
+
+  /* FIXME 
+   * Obviously, the pointer x,y coordinates need to be adjusted by the
+   * window size and relation to the bounding window. */
 
   gst_pad_send_event (gst_pad_get_peer (ximagesink->sinkpad), event);
 }
@@ -110,7 +104,6 @@ gst_ximagesink_navigation_init (GstNavigationInterface *iface)
 
 /* X11 stuff */
 
-/* This function handles GstXImage creation depending on XShm availability */
 static GstXImage *
 gst_ximagesink_ximage_new (GstXImageSink *ximagesink, gint width, gint height)
 {
@@ -127,9 +120,22 @@ gst_ximagesink_ximage_new (GstXImageSink *ximagesink, gint width, gint height)
   
   g_mutex_lock (ximagesink->x_lock);
 
-  ximage->size =  (ximagesink->xcontext->bpp / 8) * ximage->width * ximage->height;
+  GstXImage *ximage = NULL;
+  
+  g_return_val_if_fail (ximagesink != NULL, NULL);
+  g_return_val_if_fail (GST_IS_XIMAGESINK (ximagesink), NULL);
+  
+  ximage = g_new0 (GstXImage, 1);
   
-#ifdef HAVE_XSHM
+  ximage->width = width;
+  ximage->height = height;
+  ximage->data = NULL;
+  
+  g_mutex_lock (ximagesink->x_lock);
+
+  ximage->size = (ximagesink->xcontext->bpp / 8) * ximage->width * ximage->height;
+  
+#ifdef HAVE_SHM
   if (ximagesink->xcontext->use_xshm)
     {
       ximage->ximage = XShmCreateImage (ximagesink->xcontext->disp,
@@ -170,7 +176,9 @@ gst_ximagesink_ximage_new (GstXImageSink *ximagesink, gint width, gint height)
                                  ximage->width, ximage->height,
                                  ximagesink->xcontext->bpp,
                                  ximage->width * (ximagesink->xcontext->bpp / 8));
-#endif /* HAVE_XSHM */
+    
+  GST_DEBUG ("ximagesink creating an image without XShm");
+#endif /* HAVE_SHM */
   
   if (ximage->ximage)
     {
@@ -201,7 +209,7 @@ gst_ximagesink_ximage_destroy (GstXImageSink *ximagesink, GstXImage *ximage)
   
   g_mutex_lock (ximagesink->x_lock);
   
-#ifdef HAVE_XSHM
+#ifdef HAVE_SHM
   if (ximagesink->xcontext->use_xshm)
     {
       if (ximage->SHMInfo.shmaddr)
@@ -224,7 +232,7 @@ gst_ximagesink_ximage_destroy (GstXImageSink *ximagesink, GstXImage *ximage)
 #else
   if (ximage->ximage)
     XDestroyImage (ximage->ximage);
-#endif /* HAVE_XSHM */ 
+#endif /* HAVE_SHM */ 
   
   g_mutex_unlock (ximagesink->x_lock);
   
@@ -251,7 +259,7 @@ gst_ximagesink_ximage_put (GstXImageSink *ximagesink, GstXImage *ximage)
   x = MAX (0, (attr.width - ximage->width) / 2);
   y = MAX (0, (attr.height - ximage->height) / 2);
 
-#ifdef HAVE_XSHM
+#ifdef HAVE_SHM
   if (ximagesink->xcontext->use_xshm)
     {  
       XShmPutImage (ximagesink->xcontext->disp, ximagesink->xwindow->win, 
@@ -269,9 +277,9 @@ gst_ximagesink_ximage_put (GstXImageSink *ximagesink, GstXImage *ximage)
   XPutImage (ximagesink->xcontext->disp, ximagesink->xwindow->win, 
              ximagesink->xwindow->gc, ximage->ximage,  
              0, 0, x, y, ximage->width, ximage->height);
-#endif /* HAVE_XSHM */
+#endif /* HAVE_SHM */
   
-  XSync(ximagesink->xcontext->disp, FALSE);
+  XSync (ximagesink->xcontext->disp, FALSE);
   
   g_mutex_unlock (ximagesink->x_lock);
 }
@@ -450,10 +458,10 @@ gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
   g_mutex_unlock (ximagesink->x_lock);
 }
 
-/* This function get the X Display and global infos about it. Everything is
+/* This function gets the X Display and global infos about it. Everything is
    stored in our object and will be cleaned when the object is disposed. Note
    here that caps for supported format are generated without any window or 
-   image creation */
+   image creation. */
 static GstXContext *
 gst_ximagesink_xcontext_get (GstXImageSink *ximagesink)
 {
@@ -507,7 +515,7 @@ gst_ximagesink_xcontext_get (GstXImageSink *ximagesink)
     
   xcontext->endianness = (ImageByteOrder (xcontext->disp) == LSBFirst) ? G_LITTLE_ENDIAN:G_BIG_ENDIAN;
   
-#ifdef HAVE_XSHM
+#ifdef HAVE_SHM
   /* Search for XShm extension support */
   if (XQueryExtension (xcontext->disp, "MIT-SHM", &i, &i, &i))
     {
@@ -519,7 +527,7 @@ gst_ximagesink_xcontext_get (GstXImageSink *ximagesink)
       xcontext->use_xshm = FALSE;
       GST_DEBUG ("ximagesink is not using XShm extension");
     }
-#endif /* HAVE_XSHM */
+#endif /* HAVE_SHM */
   
   /* What the hell is that ? */
   if (xcontext->endianness == G_LITTLE_ENDIAN && xcontext->depth == 24)
@@ -564,116 +572,133 @@ gst_ximagesink_xcontext_clear (GstXImageSink *ximagesink)
   
   XCloseDisplay (ximagesink->xcontext->disp);
   
-  g_mutex_unlock (ximagesink->x_lock);
+    GstClockID id = gst_clock_new_single_shot_id (ximagesink->clock, time);
+    gst_element_clock_wait (GST_ELEMENT (ximagesink), id, NULL);
+    gst_clock_id_free (id);
+  }
   
-  ximagesink->xcontext = NULL;
+  /* If we have a pool and the image is from this pool, simply put it. */
+  if ( (ximagesink->bufferpool) &&
+       (GST_BUFFER_BUFFERPOOL (buf) == ximagesink->bufferpool) )
+    gst_ximagesink_ximage_put (ximagesink, GST_BUFFER_POOL_PRIVATE (buf));
+  else /* Else we have to copy the data into our private image, */
+    {  /* if we have one... */
+      if (ximagesink->ximage)
+        {
+          memcpy (ximagesink->ximage->ximage->data, 
+                  GST_BUFFER_DATA (buf), 
+                  MIN (GST_BUFFER_SIZE (buf), ximagesink->ximage->size));
+          gst_ximagesink_ximage_put (ximagesink, ximagesink->ximage);
+        }
+      else /* No image available. Something went wrong during capsnego ! */
+        {
+          gst_buffer_unref (buf);
+          gst_element_error (GST_ELEMENT (ximagesink), "no image to draw");
+          return;
+        }
+    }
+  
+  gst_buffer_unref (buf);
 }
 
-/* Element stuff */
-
-static GstCaps *
-gst_ximagesink_getcaps (GstPad *pad, GstCaps *caps)
+static void
+gst_ximagesink_get_property (GObject *object, guint prop_id,
+                             GValue *value, GParamSpec *pspec)
 {
   GstXImageSink *ximagesink;
-  
-  ximagesink = GST_XIMAGESINK (gst_pad_get_parent (pad));
-  
-  if (ximagesink->xcontext)
-    return gst_caps_copy (ximagesink->xcontext->caps);
+                                                                                
+  g_return_if_fail (GST_IS_XIMAGESINK (object));
+                                                                                
+  ximagesink = GST_XIMAGESINK (object);
 
-  return GST_CAPS_NEW ("ximagesink_rgbsink", "video/x-raw-rgb",
-                       "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT),
-                       "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
-                       "height", GST_PROPS_INT_RANGE (0, G_MAXINT));
+  switch (prop_id)
 }
 
-static GstPadLinkReturn
-gst_ximagesink_sinkconnect (GstPad *pad, GstCaps *caps)
+static void
+gst_ximagesink_set_clock (GstElement *element, GstClock *clock)
 {
   GstXImageSink *ximagesink;
 
-  ximagesink = GST_XIMAGESINK (gst_pad_get_parent (pad));
-
-  /* we are not going to act on variable caps */
-  if (!GST_CAPS_IS_FIXED (caps))
-    return GST_PAD_LINK_DELAYED;
-  if (GST_CAPS_IS_CHAINED (caps))
-    return GST_PAD_LINK_DELAYED;
-  
-  GST_DEBUG ("sinkconnect %s with %s", gst_caps_to_string(caps),
-             gst_caps_to_string(ximagesink->xcontext->caps));
-  
-  if (!gst_caps_get_int (caps, "width", &ximagesink->width))
-    return GST_PAD_LINK_REFUSED;
-  if (!gst_caps_get_int (caps, "height", &ximagesink->height))
-    return GST_PAD_LINK_REFUSED;
-  
-  if (gst_caps_has_fixed_property (caps, "pixel_width"))
-    gst_caps_get_int (caps, "pixel_width", &ximagesink->pixel_width);
-  else
-    ximagesink->pixel_width = 1;
+  ximagesink = GST_XIMAGESINK (element);
+  
+  ximagesink->clock = clock;
+}
 
-  if (gst_caps_has_fixed_property (caps, "pixel_height"))
-    gst_caps_get_int (caps, "pixel_height", &ximagesink->pixel_height);
-  else
-    ximagesink->pixel_height = 1;
+static GstBuffer*
+gst_ximagesink_buffer_new (GstBufferPool *pool,  
+                          gint64 location, guint size, gpointer user_data)
+{
+  GstXImageSink *ximagesink;
+  GstBuffer *buffer;
+  GstXImage *ximage = NULL;
+  gboolean not_found = TRUE;
   
-  /* Creating our window and our image */
-  if (!ximagesink->xwindow)
-    ximagesink->xwindow = gst_ximagesink_xwindow_new (ximagesink,
-                                                      ximagesink->width,
-                                                      ximagesink->height);
-  else
-    { /* We resize our window only if size has changed, preventing us from
-         infinite loops with XConfigure events.
-      if ( (ximagesink->width != ximagesink->xwindow->width) ||
-           (ximagesink->height != ximagesink->xwindow->height) )
-        gst_ximagesink_xwindow_resize (ximagesink, ximagesink->xwindow,
-                                       ximagesink->width, ximagesink->height);*/
-    }
+  ximagesink = GST_XIMAGESINK (user_data);
   
-  if ( (ximagesink->ximage) &&
-       ( (ximagesink->width != ximagesink->ximage->width) ||
-         (ximagesink->height != ximagesink->ximage->height) ) )
-    { /* We renew our ximage only if size changed */
-      gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
+  g_mutex_lock (ximagesink->pool_lock);
   
-      ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
-                                                      ximagesink->width,
-                                                      ximagesink->height);
+  /* Walking through the pool cleaning unsuable images and searching for a
+     suitable one */
+  while (not_found && ximagesink->image_pool)
+    {
+      ximage = ximagesink->image_pool->data;
+      
+      if (ximage)
+        {
+          /* Removing from the pool */
+          ximagesink->image_pool = g_slist_delete_link (ximagesink->image_pool,
+                                                        ximagesink->image_pool);
+          
+          if ( (ximage->width != ximagesink->width) ||
+               (ximage->height != ximagesink->height) )
+            { /* This image is unusable. Destroying... */
+              gst_ximagesink_ximage_destroy (ximagesink, ximage);
+              ximage = NULL;
+            }
+          else /* We found a suitable image */
+            break;
+        }
     }
-  else if (!ximagesink->ximage) /* If no ximage, creating one */
-    ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
-                                                    ximagesink->width,
-                                                    ximagesink->height);
+   
+  g_mutex_unlock (ximagesink->pool_lock);
   
-  return GST_PAD_LINK_OK;
+  if (!ximage) /* We didn't find a suitable image in the pool. Creating... */
+    ximage = gst_ximagesink_ximage_new (ximagesink,
+                                        ximagesink->width,
+                                        ximagesink->height);
+  
+  if (ximage)
+    {
+      buffer = gst_buffer_new ();
+      GST_BUFFER_POOL_PRIVATE (buffer) = ximage;
+      GST_BUFFER_DATA (buffer) = ximage->ximage->data;
+      GST_BUFFER_SIZE (buffer) = ximage->size;
+      return buffer;
+    }
+  else
+    return NULL;
 }
 
-static GstElementStateReturn
-gst_ximagesink_change_state (GstElement *element)
+static void
+gst_ximagesink_buffer_free (GstBufferPool *pool,
+                            GstBuffer *buffer, gpointer user_data)
 {
   GstXImageSink *ximagesink;
-
-  ximagesink = GST_XIMAGESINK (element);
-
-  switch (GST_STATE_TRANSITION (element)) {
-    case GST_STATE_NULL_TO_READY:
-      /* Initializing the XContext */
-      ximagesink->xcontext = gst_ximagesink_xcontext_get (ximagesink);
-      if (!ximagesink->xcontext)
-        return GST_STATE_FAILURE;
-      break;
-    case GST_STATE_READY_TO_PAUSED:
-      break;
-    case GST_STATE_PAUSED_TO_PLAYING:
-      break;
-    case GST_STATE_PLAYING_TO_PAUSED:
-      break;
-    case GST_STATE_PAUSED_TO_READY:
-      break;
-    case GST_STATE_READY_TO_NULL:
-      break;
+  GstXImage *ximage;
+  
+  ximagesink = GST_XIMAGESINK (user_data);
+  
+  ximage = GST_BUFFER_POOL_PRIVATE (buffer);
+  
+  /* If our geometry changed we can't reuse that image. */
+  if ( (ximage->width != ximagesink->width) ||
+       (ximage->height != ximagesink->height) )
+    {
+      gst_ximagesink_ximage_destroy (ximagesink, ximage);
+    }
+  else /* If it didn't we can reuse the image and add it to our image pool. */
+    {
+      g_mutex_lock (ximagesink->pool_lock);
   }
 
   if (parent_class->change_state)
@@ -794,161 +819,6 @@ gst_ximagesink_buffer_new (GstBufferPool *pool,
         }
     }
    
-  g_mutex_unlock (ximagesink->pool_lock);
-  
-  if (!ximage) /* We found no suitable image in the pool. Creating... */
-    ximage = gst_ximagesink_ximage_new (ximagesink,
-                                        ximagesink->width,
-                                        ximagesink->height);
-  
-  if (ximage)
-    {
-      buffer = gst_buffer_new ();
-      GST_BUFFER_POOL_PRIVATE (buffer) = ximage;
-      GST_BUFFER_DATA (buffer) = ximage->ximage->data;
-      GST_BUFFER_SIZE (buffer) = ximage->size;
-      return buffer;
-    }
-  else
-    return NULL;
-}
-
-static void
-gst_ximagesink_buffer_free (GstBufferPool *pool,
-                            GstBuffer *buffer, gpointer user_data)
-{
-  GstXImageSink *ximagesink;
-  GstXImage *ximage;
-  
-  ximagesink = GST_XIMAGESINK (user_data);
-  
-  ximage = GST_BUFFER_POOL_PRIVATE (buffer);
-  
-  /* If our geometry changed we can't reuse that image. */
-  if ( (ximage->width != ximagesink->width) ||
-       (ximage->height != ximagesink->height) )
-    gst_ximagesink_ximage_destroy (ximagesink, ximage);
-  else /* In that case we can reuse the image and add it to our image pool. */
-    {
-      g_mutex_lock (ximagesink->pool_lock);
-      ximagesink->image_pool = g_slist_prepend (ximagesink->image_pool, ximage);
-      g_mutex_unlock (ximagesink->pool_lock);
-    }
-    
-  GST_BUFFER_DATA (buffer) = NULL;
-
-  gst_buffer_default_free (buffer);
-}
-
-static void
-gst_ximagesink_imagepool_clear (GstXImageSink *ximagesink)
-{
-  g_mutex_lock(ximagesink->pool_lock);
-  
-  while (ximagesink->image_pool)
-    {
-      GstXImage *ximage = ximagesink->image_pool->data;
-      ximagesink->image_pool = g_slist_delete_link (ximagesink->image_pool,
-                                                    ximagesink->image_pool);
-      gst_ximagesink_ximage_destroy (ximagesink, ximage);
-    }
-  
-  g_mutex_unlock(ximagesink->pool_lock);
-}
-
-static GstBufferPool*
-gst_ximagesink_get_bufferpool (GstPad *pad)
-{
-  GstXImageSink *ximagesink;
-  
-  ximagesink = GST_XIMAGESINK (gst_pad_get_parent (pad));
-
-  if (!ximagesink->bufferpool) {
-    ximagesink->bufferpool = gst_buffer_pool_new (
-                NULL,          /* free */
-                NULL,          /* copy */
-                (GstBufferPoolBufferNewFunction) gst_ximagesink_buffer_new,
-                NULL,          /* buffer copy, the default is fine */
-                (GstBufferPoolBufferFreeFunction) gst_ximagesink_buffer_free,
-                ximagesink);
-
-    ximagesink->image_pool = NULL;
-  }
-
-  gst_buffer_pool_ref (ximagesink->bufferpool);
-
-  return ximagesink->bufferpool;
-}
-
-/* =========================================== */
-/*                                             */
-/*              Init & Class init              */
-/*                                             */
-/* =========================================== */
-
-static void
-gst_ximagesink_dispose (GObject *object)
-{
-  GstXImageSink *ximagesink;
-
-  ximagesink = GST_XIMAGESINK (object);
-
-  if (ximagesink->ximage)
-    {
-      gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
-      ximagesink->ximage = NULL;
-    }
-    
-  if (ximagesink->image_pool)
-    gst_ximagesink_imagepool_clear (ximagesink);
-  
-  if (ximagesink->xwindow)
-    {
-      gst_ximagesink_xwindow_destroy (ximagesink, ximagesink->xwindow);
-      ximagesink->xwindow = NULL;
-    }
-  
-  if (ximagesink->xcontext)
-    gst_ximagesink_xcontext_clear (ximagesink);
-    
-  g_mutex_free (ximagesink->x_lock);
-  g_mutex_free (ximagesink->pool_lock);
-
-  if (ximagesink->bufferpool) 
-    gst_buffer_pool_free (ximagesink->bufferpool);
-
-  G_OBJECT_CLASS (parent_class)->dispose (object);
-}
-
-static void
-gst_ximagesink_init (GstXImageSink *ximagesink)
-{
-  ximagesink->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (
-                                         gst_ximagesink_sink_template_factory),
-                                         "sink");
-  gst_element_add_pad (GST_ELEMENT (ximagesink), ximagesink->sinkpad);
-
-  gst_pad_set_chain_function (ximagesink->sinkpad, gst_ximagesink_chain);
-  gst_pad_set_link_function (ximagesink->sinkpad, gst_ximagesink_sinkconnect);
-  gst_pad_set_getcaps_function (ximagesink->sinkpad, gst_ximagesink_getcaps);
-  gst_pad_set_bufferpool_function (ximagesink->sinkpad,
-                                   gst_ximagesink_get_bufferpool);
-
-  ximagesink->xcontext = NULL;
-  ximagesink->xwindow = NULL;
-  ximagesink->ximage = NULL;
-  ximagesink->clock = NULL;
-  
-  ximagesink->width = ximagesink->height = 0;
-  
-  ximagesink->x_lock = g_mutex_new ();
-  
-  ximagesink->pixel_width = ximagesink->pixel_height = 1;
-  
-  ximagesink->image_pool = NULL;
-  ximagesink->pool_lock = g_mutex_new ();
-
-  GST_FLAG_SET(ximagesink, GST_ELEMENT_THREAD_SUGGESTED);
   GST_FLAG_SET(ximagesink, GST_ELEMENT_EVENT_AWARE);
 }
 
@@ -973,9 +843,13 @@ gst_ximagesink_class_init (GstXImageSinkClass *klass)
   gstelement_class = (GstElementClass *) klass;
 
   parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DISPLAY_NAME,
+    g_param_spec_string ("displayname", "displayname", "Name of display to use",
+            NULL, G_PARAM_READABLE));
+                                                                                
+  gobject_class->set_property = gst_ximagesink_set_property;
+  gobject_class->get_property = gst_ximagesink_get_property;
 
-  gobject_class->dispose = gst_ximagesink_dispose;
-  
   gstelement_class->change_state = gst_ximagesink_change_state;
   gstelement_class->set_clock    = gst_ximagesink_set_clock;
 }
@@ -1026,9 +900,10 @@ gst_ximagesink_get_type (void)
         NULL,
       };*/
       
-      ximagesink_type = g_type_register_static (GST_TYPE_ELEMENT,
-                                                "GstXImageSink",
-                                                &ximagesink_info, 0);
+      ximagesink_type = g_type_register_static(GST_TYPE_ELEMENT,
+                                               "GstXImageSink",
+                                               &ximagesink_info,
+                                               0);
       
       g_type_add_interface_static (ximagesink_type, GST_TYPE_INTERFACE,
         &iface_info);
@@ -1044,8 +919,7 @@ gst_ximagesink_get_type (void)
 static gboolean
 plugin_init (GstPlugin *plugin)
 {
-  if (!gst_element_register (plugin, "ximagesink",
-                             GST_RANK_SECONDARY, GST_TYPE_XIMAGESINK))
+  if (!gst_element_register (plugin, "ximagesink", GST_RANK_NONE, GST_TYPE_XIMAGESINK))
     return FALSE;
 
   return TRUE;
index 84ea0e0..edbd00e 100644 (file)
 
 #include <gst/gst.h>
 
-/* FIXME : We should have a configure test for shm support */
-#define HAVE_XSHM
-
-#ifdef HAVE_XSHM
+#ifdef HAVE_SHM
 #include <sys/ipc.h>
 #include <sys/shm.h>
-#endif /* HAVE_XSHM */
+#endif /* HAVE_SHM */
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 
-#ifdef HAVE_XSHM
+#ifdef HAVE_SHM
 #include <X11/extensions/XShm.h>
-#endif /* HAVE_XSHM */
+#endif /* HAVE_SHM */
 
 #include <string.h>
 #include <math.h>
@@ -93,9 +90,9 @@ struct _GstXWindow {
 struct _GstXImage {
   XImage *ximage;
   
-#ifdef HAVE_XSHM
+#ifdef HAVE_SHM
   XShmSegmentInfo SHMInfo;
-#endif /* HAVE_XSHM */
+#endif /* HAVE_SHM */
   
   char *data;
   gint width, height, size;
@@ -128,7 +125,7 @@ struct _GstXImageSinkClass {
   GstElementClass parent_class;
 };
 
-GType gst_ximagesink_get_type(void);
+GType gst_ximagesink_get_type (void);
 
 G_END_DECLS