discoverer: Use switch/case instead of lots of ifs for the event handling

This commit is contained in:
Sebastian Dröge 2012-11-20 14:37:51 +01:00
parent 1990c45b60
commit e223e313b6

View file

@ -465,7 +465,8 @@ _event_probe (GstPad * pad, GstPadProbeInfo * info, PrivateStream * ps)
{
GstEvent *event = GST_PAD_PROBE_INFO_EVENT (info);
if (GST_EVENT_TYPE (event) == GST_EVENT_TAG) {
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_TAG:{
GstTagList *tl = NULL, *tmp;
gst_event_parse_tag (event, &tl);
@ -474,20 +475,20 @@ _event_probe (GstPad * pad, GstPadProbeInfo * info, PrivateStream * ps)
/* If preroll is complete, drop these tags - the collected information is
* possibly already being processed and adding more tags would be racy */
if (G_LIKELY (ps->dc->priv->processing)) {
GST_DEBUG_OBJECT (pad, "private stream %p old tags %" GST_PTR_FORMAT, ps,
ps->tags);
GST_DEBUG_OBJECT (pad, "private stream %p old tags %" GST_PTR_FORMAT,
ps, ps->tags);
tmp = gst_tag_list_merge (ps->tags, tl, GST_TAG_MERGE_APPEND);
if (ps->tags)
gst_tag_list_unref (ps->tags);
ps->tags = tmp;
GST_DEBUG_OBJECT (pad, "private stream %p new tags %" GST_PTR_FORMAT, ps,
tmp);
GST_DEBUG_OBJECT (pad, "private stream %p new tags %" GST_PTR_FORMAT,
ps, tmp);
} else
GST_DEBUG_OBJECT (pad, "Dropping tags since preroll is done");
DISCO_UNLOCK (ps->dc);
break;
}
if (GST_EVENT_TYPE (event) == GST_EVENT_TOC) {
case GST_EVENT_TOC:{
GstToc *tmp;
gst_event_parse_toc (event, &tmp, NULL);
@ -495,10 +496,15 @@ _event_probe (GstPad * pad, GstPadProbeInfo * info, PrivateStream * ps)
DISCO_LOCK (ps->dc);
ps->toc = tmp;
if (G_LIKELY (ps->dc->priv->processing)) {
GST_DEBUG_OBJECT (pad, "private stream %p toc %" GST_PTR_FORMAT, ps, tmp);
GST_DEBUG_OBJECT (pad, "private stream %p toc %" GST_PTR_FORMAT, ps,
tmp);
} else
GST_DEBUG_OBJECT (pad, "Dropping toc since preroll is done");
DISCO_UNLOCK (ps->dc);
break;
}
default:
break;
}
return GST_PAD_PROBE_OK;