hlsdemux: avoid using g_list_append for creating segments list

Use g_list_prepend and reverse it at the end to skip traversing the
same list for every new segment
This commit is contained in:
Thiago Santos 2015-01-07 09:21:33 -03:00
parent cd6069f5af
commit c79e8a78ac

View file

@ -487,8 +487,7 @@ gst_m3u8_update (GstM3U8Client * client, GstM3U8 * self, gchar * data,
if (offset != -1) {
file->offset = offset;
} else {
GstM3U8MediaFile *prev =
self->files ? g_list_last (self->files)->data : NULL;
GstM3U8MediaFile *prev = self->files ? self->files->data : NULL;
if (!prev) {
offset = 0;
@ -508,7 +507,7 @@ gst_m3u8_update (GstM3U8Client * client, GstM3U8 * self, gchar * data,
title = NULL;
discontinuity = FALSE;
size = offset = -1;
self->files = g_list_append (self->files, file);
self->files = g_list_prepend (self->files, file);
}
} else if (g_str_has_prefix (data, "#EXT-X-ENDLIST")) {
@ -696,6 +695,8 @@ gst_m3u8_update (GstM3U8Client * client, GstM3U8 * self, gchar * data,
g_free (current_key);
current_key = NULL;
self->files = g_list_reverse (self->files);
/* reorder playlists by bitrate */
if (self->lists) {
gchar *top_variant_uri = NULL;
@ -1116,7 +1117,7 @@ gst_m3u8_client_get_current_uri (GstM3U8Client * client)
}
gboolean
gst_m3u8_client_has_main(GstM3U8Client * client)
gst_m3u8_client_has_main (GstM3U8Client * client)
{
gboolean ret;