diff --git a/ChangeLog b/ChangeLog index f042b7e8cd..522569c37d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-11-27 Julien MOUTTE + + * sys/ximage/ximagesink.c: (gst_ximage_buffer_free), + (gst_ximagesink_ximage_new), (gst_ximagesink_ximage_put), + (gst_ximagesink_bufferpool_clear), (gst_ximagesink_buffer_alloc), + (gst_ximagesink_expose): Fixed a tricky race. + * sys/ximage/ximagesink.h: + * sys/xvimage/xvimagesink.c: (gst_xvimagesink_xvimage_put), + (gst_xvimagesink_expose): Fixed a tricky race. + * sys/xvimage/xvimagesink.h: + 2005-11-27 Edward Hervey * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init), diff --git a/sys/ximage/ximagesink.c b/sys/ximage/ximagesink.c index e867f7726a..91a7200b16 100644 --- a/sys/ximage/ximagesink.c +++ b/sys/ximage/ximagesink.c @@ -1,5 +1,5 @@ /* GStreamer - * Copyright (C) <2003> Julien Moutte + * Copyright (C) <2005> Julien Moutte * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -228,6 +228,15 @@ beach: return; } +static void +gst_ximage_buffer_free (GstXImageBuffer * ximage) +{ + /* make sure it is not recycled */ + ximage->width = -1; + ximage->height = -1; + gst_buffer_unref (GST_BUFFER (ximage)); +} + static void gst_ximage_buffer_init (GstXImageBuffer * ximage_buffer, gpointer g_class) { @@ -456,7 +465,7 @@ beach: g_mutex_unlock (ximagesink->x_lock); if (!succeeded) { - gst_buffer_unref (GST_BUFFER (ximage)); + gst_ximage_buffer_free (ximage); ximage = NULL; } @@ -555,16 +564,12 @@ gst_ximagesink_ximage_put (GstXImageSink * ximagesink, GstXImageBuffer * ximage) g_return_if_fail (GST_IS_XIMAGESINK (ximagesink)); - if (!ximage) { - return; - } - /* 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 (ximagesink->flow_lock); /* Store a reference to the last image we put, loose the previous one */ - if (ximagesink->cur_image != ximage) { + if (ximage && ximagesink->cur_image != ximage) { if (ximagesink->cur_image) { GST_DEBUG_OBJECT (ximagesink, "unreffing %p", ximagesink->cur_image); gst_buffer_unref (ximagesink->cur_image); @@ -572,6 +577,16 @@ gst_ximagesink_ximage_put (GstXImageSink * ximagesink, GstXImageBuffer * ximage) ximagesink->cur_image = GST_XIMAGE_BUFFER (gst_buffer_ref (ximage)); } + /* Expose sends a NULL image, we take the latest frame */ + if (!ximage) { + if (ximagesink->cur_image) { + ximage = ximagesink->cur_image; + } else { + g_mutex_unlock (ximagesink->flow_lock); + return; + } + } + gst_ximagesink_xwindow_update_geometry (ximagesink, ximagesink->xwindow); src.w = ximage->width; @@ -1117,7 +1132,7 @@ gst_ximagesink_bufferpool_clear (GstXImageSink * ximagesink) ximagesink->buffer_pool = g_slist_delete_link (ximagesink->buffer_pool, ximagesink->buffer_pool); - gst_ximagesink_ximage_destroy (ximagesink, ximage); + gst_ximage_buffer_free (ximage); } g_mutex_unlock (ximagesink->pool_lock); @@ -1508,7 +1523,7 @@ alloc: /* If the ximage is invalid for our need, destroy */ if ((ximage->width != width) || (ximage->height != height)) { - gst_ximagesink_ximage_destroy (ximagesink, ximage); + gst_ximage_buffer_free (ximage); ximage = NULL; } else { /* We found a suitable ximage */ @@ -1687,7 +1702,7 @@ gst_ximagesink_expose (GstXOverlay * overlay) if (!ximagesink->xwindow) return; - gst_ximagesink_ximage_put (ximagesink, ximagesink->cur_image); + gst_ximagesink_ximage_put (ximagesink, NULL); } static void diff --git a/sys/ximage/ximagesink.h b/sys/ximage/ximagesink.h index d940194132..1383f7732a 100644 --- a/sys/ximage/ximagesink.h +++ b/sys/ximage/ximagesink.h @@ -1,5 +1,5 @@ /* GStreamer - * Copyright (C) <2003> Julien Moutte + * Copyright (C) <2005> Julien Moutte * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index 987ddb261d..ebda4511b3 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -1,5 +1,5 @@ /* GStreamer - * Copyright (C) <2003> Julien Moutte + * Copyright (C) <2005> Julien Moutte * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -587,16 +587,12 @@ gst_xvimagesink_xvimage_put (GstXvImageSink * xvimagesink, g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink)); g_return_if_fail (xvimagesink->xwindow != NULL); - if (!xvimage) { - return; - } - /* 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); /* Store a reference to the last image we put, loose the previous one */ - if (xvimagesink->cur_image != xvimage) { + if (xvimage && xvimagesink->cur_image != xvimage) { if (xvimagesink->cur_image) { GST_DEBUG_OBJECT (xvimagesink, "unreffing %p", xvimagesink->cur_image); gst_buffer_unref (xvimagesink->cur_image); @@ -604,6 +600,16 @@ gst_xvimagesink_xvimage_put (GstXvImageSink * xvimagesink, xvimagesink->cur_image = GST_XVIMAGE_BUFFER (gst_buffer_ref (xvimage)); } + /* Expose sends a NULL image, we take the latest frame */ + if (!xvimage) { + if (xvimagesink->cur_image) { + xvimage = xvimagesink->cur_image; + } else { + g_mutex_unlock (xvimagesink->flow_lock); + return; + } + } + gst_xvimagesink_xwindow_update_geometry (xvimagesink, xvimagesink->xwindow); src.w = xvimage->width; @@ -2002,7 +2008,7 @@ gst_xvimagesink_expose (GstXOverlay * overlay) if (!xvimagesink->xwindow) return; - gst_xvimagesink_xvimage_put (xvimagesink, xvimagesink->cur_image); + gst_xvimagesink_xvimage_put (xvimagesink, NULL); } static void diff --git a/sys/xvimage/xvimagesink.h b/sys/xvimage/xvimagesink.h index fa88aa8c4b..80bb1f5f5b 100644 --- a/sys/xvimage/xvimagesink.h +++ b/sys/xvimage/xvimagesink.h @@ -1,5 +1,5 @@ /* GStreamer - * Copyright (C) <2003> Julien Moutte + * Copyright (C) <2005> Julien Moutte * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public