playbin2: Fix stream-changed message list iteration

When iterating the list and removing the current element, first
get the next element and then remove the current one and not
the other way around.
This commit is contained in:
Sebastian Dröge 2009-12-08 13:40:18 +01:00
parent 1ad0e4342e
commit 7bf631e448

View file

@ -2130,21 +2130,25 @@ gst_play_bin_handle_message (GstBin * bin, GstMessage * msg)
/* Drop all stream-changed messages except the last one */
if (strcmp ("playbin2-stream-changed", gst_structure_get_name (s)) == 0) {
guint32 seqnum = gst_message_get_seqnum (msg);
GList *l;
GList *l, *l_prev;
group = playbin->curr_group;
g_mutex_lock (group->stream_changed_pending_lock);
for (l = group->stream_changed_pending; l; l = l->next) {
for (l = group->stream_changed_pending; l;) {
guint32 l_seqnum = GPOINTER_TO_UINT (l->data);
if (l_seqnum == seqnum) {
l_prev = l;
l = l->next;
group->stream_changed_pending =
g_list_delete_link (group->stream_changed_pending, l);
g_list_delete_link (group->stream_changed_pending, l_prev);
if (group->stream_changed_pending) {
gst_message_unref (msg);
msg = NULL;
break;
}
} else {
l = l->next;
}
}
g_mutex_unlock (group->stream_changed_pending_lock);