[MOVED FROM BAD 04/57] gst/flv/gstflvdemux.c: Fix locking and refcounting on the...
authorWim Taymans <wim.taymans@gmail.com>
Tue, 14 Aug 2007 14:56:20 +0000 (14:56 +0000)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 12 May 2009 19:20:50 +0000 (21:20 +0200)
Original commit message from CVS:
* gst/flv/gstflvdemux.c: (gst_flv_demux_set_index),
(gst_flv_demux_get_index):
Fix locking and refcounting on the index.

gst/flv/gstflvdemux.c

index 339fc0d..3f727f1 100644 (file)
@@ -911,7 +911,11 @@ gst_flv_demux_set_index (GstElement * element, GstIndex * index)
 {
   GstFLVDemux *demux = GST_FLV_DEMUX (element);
 
+  GST_OBJECT_LOCK (demux);
+  if (demux->index)
+    gst_object_unref (demux->index);
   demux->index = gst_object_ref (index);
+  GST_OBJECT_UNLOCK (demux);
 
   gst_index_get_writer_id (index, GST_OBJECT (element), &demux->index_id);
 }
@@ -919,9 +923,16 @@ gst_flv_demux_set_index (GstElement * element, GstIndex * index)
 static GstIndex *
 gst_flv_demux_get_index (GstElement * element)
 {
+  GstIndex *result = NULL;
+
   GstFLVDemux *demux = GST_FLV_DEMUX (element);
 
-  return demux->index;
+  GST_OBJECT_LOCK (demux);
+  if (demux->index)
+    result = gst_object_ref (demux->index);
+  GST_OBJECT_UNLOCK (demux);
+
+  return result;
 }
 
 static void