Commit 532bb2e6 authored by Julien Moutte's avatar Julien Moutte
Browse files

sys/ximage/ximagesink.c: Fixed a tricky race.

Original commit message from CVS:
2005-11-27  Julien MOUTTE  <julien@moutte.net>

* 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:
parent 56c6518c
2005-11-27 Julien MOUTTE <julien@moutte.net>
* 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 <edward@fluendo.com>
 
* gst/playback/gstdecodebin.c: (gst_decode_bin_class_init),
......
/* GStreamer
* Copyright (C) <2003> Julien Moutte <julien@moutte.net>
* Copyright (C) <2005> Julien Moutte <julien@moutte.net>
*
* 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
......
/* GStreamer
* Copyright (C) <2003> Julien Moutte <julien@moutte.net>
* Copyright (C) <2005> Julien Moutte <julien@moutte.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......
/* GStreamer
* Copyright (C) <2003> Julien Moutte <julien@moutte.net>
* Copyright (C) <2005> Julien Moutte <julien@moutte.net>
*
* 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
......
/* GStreamer
* Copyright (C) <2003> Julien Moutte <julien@moutte.net>
* Copyright (C) <2005> Julien Moutte <julien@moutte.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment