queuearray: Only clear dropped item if it is not returned

This commit is contained in:
Sebastian Dröge 2018-10-15 18:47:16 +03:00
parent 2481e542c7
commit fc3602aec8

View file

@ -607,7 +607,8 @@ gst_queue_array_drop_struct (GstQueueArray * array, guint idx,
/* simple case actual_idx == first item */ /* simple case actual_idx == first item */
if (actual_idx == first_item_index) { if (actual_idx == first_item_index) {
/* clear current head position if needed */ /* clear current head position if needed */
gst_queue_array_clear_idx (array, idx); if (p_struct == NULL)
gst_queue_array_clear_idx (array, idx);
/* move the head plus one */ /* move the head plus one */
array->head++; array->head++;
@ -619,7 +620,8 @@ gst_queue_array_drop_struct (GstQueueArray * array, guint idx,
/* simple case idx == last item */ /* simple case idx == last item */
if (actual_idx == last_item_index) { if (actual_idx == last_item_index) {
/* clear current tail position if needed */ /* clear current tail position if needed */
gst_queue_array_clear_idx (array, idx); if (p_struct == NULL)
gst_queue_array_clear_idx (array, idx);
/* move tail minus one, potentially wrapping */ /* move tail minus one, potentially wrapping */
array->tail = (array->tail - 1 + array->size) % array->size; array->tail = (array->tail - 1 + array->size) % array->size;
@ -630,7 +632,8 @@ gst_queue_array_drop_struct (GstQueueArray * array, guint idx,
/* non-wrapped case */ /* non-wrapped case */
if (first_item_index < last_item_index) { if (first_item_index < last_item_index) {
/* clear idx if needed */ /* clear idx if needed */
gst_queue_array_clear_idx (array, idx); if (p_struct == NULL)
gst_queue_array_clear_idx (array, idx);
g_assert (first_item_index < actual_idx && actual_idx < last_item_index); g_assert (first_item_index < actual_idx && actual_idx < last_item_index);
/* move everything beyond actual_idx one step towards zero in array */ /* move everything beyond actual_idx one step towards zero in array */
@ -648,7 +651,8 @@ gst_queue_array_drop_struct (GstQueueArray * array, guint idx,
if (actual_idx < last_item_index) { if (actual_idx < last_item_index) {
/* clear idx if needed */ /* clear idx if needed */
gst_queue_array_clear_idx (array, idx); if (p_struct == NULL)
gst_queue_array_clear_idx (array, idx);
/* actual_idx is before last_item_index, move data towards zero */ /* actual_idx is before last_item_index, move data towards zero */
memmove (array->array + elt_size * actual_idx, memmove (array->array + elt_size * actual_idx,
@ -663,7 +667,8 @@ gst_queue_array_drop_struct (GstQueueArray * array, guint idx,
if (actual_idx > first_item_index) { if (actual_idx > first_item_index) {
/* clear idx if needed */ /* clear idx if needed */
gst_queue_array_clear_idx (array, idx); if (p_struct == NULL)
gst_queue_array_clear_idx (array, idx);
/* actual_idx is after first_item_index, move data to higher indices */ /* actual_idx is after first_item_index, move data to higher indices */
memmove (array->array + elt_size * (first_item_index + 1), memmove (array->array + elt_size * (first_item_index + 1),