--- gstqueue.c.orig	2005-12-05 16:16:50.000000000 +0200
+++ gstqueue.c	2006-01-13 19:06:11.000000000 +0200
@@ -754,7 +754,8 @@
   GstQueue *queue;
   GstMiniObject *data;
   gboolean restart = TRUE;
-
+  gboolean push_ok = FALSE;
+  
   queue = GST_QUEUE (GST_PAD_PARENT (pad));
 
   /* have to lock for thread-safety */
@@ -791,25 +792,39 @@
   }
 
   /* There's something in the list now, whatever it is */
-  data = g_queue_pop_head (queue->queue);
+  data = g_queue_peek_head (queue->queue);
+
   GST_CAT_LOG_OBJECT (queue_dataflow, queue,
       "retrieved data %p from queue", data);
 
   if (GST_IS_BUFFER (data)) {
     GstFlowReturn result;
 
-    /* Update statistics */
-    queue->cur_level.buffers--;
-    queue->cur_level.bytes -= GST_BUFFER_SIZE (data);
-    if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
-      queue->cur_level.time -= GST_BUFFER_DURATION (data);
-
+    /* Copy the buffer */
+    GstMiniObject * buf = gst_mini_object_copy(data);
+    
     GST_QUEUE_MUTEX_UNLOCK (queue);
-    result = gst_pad_push (pad, GST_BUFFER (data));
+    result = gst_pad_push (pad, GST_BUFFER (buf));
     /* need to check for srcresult here as well */
     GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing);
+    if ( result == GST_FLOW_OK ) {
+      /* Remove the buffer from list */      
+      data = g_queue_pop_head (queue->queue);
+      /* Update statistics */
+      queue->cur_level.buffers--;
+      queue->cur_level.bytes -= GST_BUFFER_SIZE (data);
+      if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
+        queue->cur_level.time -= GST_BUFFER_DURATION (data);
+
+      gst_mini_object_unref(data);
+      push_ok = TRUE;
+    }
+    /* Did next element want buffer again? */
+    else if ( result == GST_FLOW_RESEND ) {
+      /* Do nothing */
+    }
     /* else result of push indicates what happens */
-    if (result != GST_FLOW_OK) {
+    else  {
       const gchar *flowname;
 
       flowname = gst_flow_get_name (result);
@@ -825,6 +840,7 @@
       gst_pad_pause_task (queue->srcpad);
     }
   } else if (GST_IS_EVENT (data)) {
+    data = g_queue_pop_head (queue->queue);  
     if (GST_EVENT_TYPE (data) == GST_EVENT_EOS) {
       queue->cur_level.buffers = 0;
       queue->cur_level.bytes = 0;
@@ -839,6 +855,7 @@
     GST_QUEUE_MUTEX_UNLOCK (queue);
     gst_pad_push_event (queue->srcpad, GST_EVENT (data));
     GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing);
+    push_ok = TRUE;
     if (restart == TRUE)
       goto restart;
   } else {
@@ -848,8 +865,10 @@
 
   STATUS (queue, "after _get()");
 
-  GST_CAT_LOG_OBJECT (queue_dataflow, queue, "signalling item_del");
-  g_cond_signal (queue->item_del);
+  if ( push_ok ) {
+    GST_CAT_LOG_OBJECT (queue_dataflow, queue, "signalling item_del");  
+    g_cond_signal (queue->item_del);
+  }
   GST_QUEUE_MUTEX_UNLOCK (queue);
 
   return;
