basevideodecoder: fix weird event list handling
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Tue, 22 Nov 2011 19:57:07 +0000 (19:57 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Tue, 22 Nov 2011 20:04:13 +0000 (20:04 +0000)
Get rid of weird code that copies a list manually, taking
ownership of the elements and then frees the old list. Instead,
just take over the old list entirely. (If the intent was to
reverse the list, one could use g_list_reverse() instead).

Then, push events in the list out from last to first (since they
were prepended as they came in) instead of just pushing out the
last in the list and leaking the others.

gst-libs/gst/video/gstbasevideodecoder.c

index 1b01ed701cd2c0423ea959a44e44bf72251ce93e..34f9ef429c5e938a0ec6f1362cc87b9e101a21c7 100644 (file)
@@ -1405,11 +1405,7 @@ gst_base_video_decoder_finish_frame (GstBaseVideoDecoder * base_video_decoder,
     GstVideoFrame *tmp = l->data;
 
     if (tmp->events) {
-      GList *k;
-
-      for (k = g_list_last (tmp->events); k; k = k->prev)
-        events = g_list_prepend (events, k->data);
-      g_list_free (tmp->events);
+      events = tmp->events;
       tmp->events = NULL;
     }
 
@@ -1417,7 +1413,7 @@ gst_base_video_decoder_finish_frame (GstBaseVideoDecoder * base_video_decoder,
       break;
   }
 
-  for (l = g_list_last (events); l; l = l->next)
+  for (l = g_list_last (events); l; l = l->prev)
     gst_pad_push_event (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder),
         l->data);
   g_list_free (events);