Cache all events except EOS if we still have to send a NEWSEGMENT event. This will let TAG events be forwarded until ...

Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_dispose), (gst_mad_sink_event),
(gst_mad_chain):
* ext/mad/gstmad.h:
* gst/mpegaudioparse/gstmpegaudioparse.c: (gst_mp3parse_dispose),
(gst_mp3parse_sink_event), (gst_mp3parse_emit_frame):
* gst/mpegaudioparse/gstmpegaudioparse.h:
Cache all events except EOS if we still have to send a NEWSEGMENT
event. This will let TAG events be forwarded until after decodebin
to an encoder for example as decodebin only links the pads
after NEWSEGMENT. Fixes bug #518933.
This commit is contained in:
Sebastian Dröge 2008-02-27 13:18:57 +00:00
parent 98577768ee
commit b6529e9d60
5 changed files with 76 additions and 5 deletions

View file

@ -1,3 +1,16 @@
2008-02-27 Sebastian Dröge <slomo@circular-chaos.org>
* ext/mad/gstmad.c: (gst_mad_dispose), (gst_mad_sink_event),
(gst_mad_chain):
* ext/mad/gstmad.h:
* gst/mpegaudioparse/gstmpegaudioparse.c: (gst_mp3parse_dispose),
(gst_mp3parse_sink_event), (gst_mp3parse_emit_frame):
* gst/mpegaudioparse/gstmpegaudioparse.h:
Cache all events except EOS if we still have to send a NEWSEGMENT
event. This will let TAG events be forwarded until after decodebin
to an encoder for example as decodebin only links the pads
after NEWSEGMENT. Fixes bug #518933.
2008-02-27 Sebastian Dröge <slomo@circular-chaos.org>
* gst/mpegaudioparse/gstxingmux.c: (get_xing_offset):

View file

@ -284,6 +284,10 @@ gst_mad_dispose (GObject * object)
g_free (mad->tempbuffer);
mad->tempbuffer = NULL;
g_list_foreach (mad->pending_events, (GFunc) gst_mini_object_unref, NULL);
g_list_free (mad->pending_events);
mad->pending_events = NULL;
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@ -988,7 +992,14 @@ gst_mad_sink_event (GstPad * pad, GstEvent * event)
break;
default:
result = gst_pad_event_default (pad, event);
if (mad->restart) {
/* Cache all events except EOS if we still have to send a NEWSEGMENT */
if (GST_EVENT_TYPE (event) != GST_EVENT_EOS)
mad->pending_events = g_list_append (mad->pending_events, event);
result = TRUE;
} else {
result = gst_pad_event_default (pad, event);
}
break;
}
return result;
@ -1409,7 +1420,12 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
} else {
mad->tags = gst_tag_list_copy (list);
}
gst_pad_push_event (mad->srcpad, gst_event_new_tag (list));
if (mad->need_newsegment)
mad->pending_events =
g_list_append (mad->pending_events,
gst_event_new_tag (list));
else
gst_pad_push_event (mad->srcpad, gst_event_new_tag (list));
}
}
}
@ -1449,7 +1465,12 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
GST_TAG_BITRATE, bitrate, NULL);
gst_element_post_message (GST_ELEMENT (mad),
gst_message_new_tag (GST_OBJECT (mad), gst_tag_list_copy (list)));
gst_pad_push_event (mad->srcpad, gst_event_new_tag (list));
if (mad->need_newsegment)
mad->pending_events =
g_list_append (mad->pending_events, gst_event_new_tag (list));
else
gst_pad_push_event (mad->srcpad, gst_event_new_tag (list));
goto next_no_samples;
}
@ -1542,6 +1563,16 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
mad->need_newsegment = FALSE;
}
if (mad->pending_events) {
GList *l;
for (l = mad->pending_events; l != NULL; l = l->next) {
gst_pad_push_event (mad->srcpad, GST_EVENT (l->data));
}
g_list_free (mad->pending_events);
mad->pending_events = NULL;
}
/* will attach the caps to the buffer */
result =
gst_pad_alloc_buffer_and_set_caps (mad->srcpad, 0,

View file

@ -92,6 +92,8 @@ struct _GstMad
gboolean xing_found;
gboolean framed; /* whether there is a demuxer in front of us */
GList *pending_events;
};
struct _GstMadClass

View file

@ -401,13 +401,18 @@ gst_mp3parse_dispose (GObject * object)
g_mutex_free (mp3parse->pending_accurate_seeks_lock);
mp3parse->pending_accurate_seeks_lock = NULL;
g_list_foreach (mp3parse->pending_events, (GFunc) gst_mini_object_unref,
NULL);
g_list_free (mp3parse->pending_events);
mp3parse->pending_events = NULL;
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static gboolean
gst_mp3parse_sink_event (GstPad * pad, GstEvent * event)
{
gboolean res;
gboolean res = TRUE;
GstMPEGAudioParse *mp3parse;
GstEvent **eventp;
@ -535,7 +540,16 @@ gst_mp3parse_sink_event (GstPad * pad, GstEvent * event)
res = gst_pad_push_event (mp3parse->srcpad, event);
break;
default:
res = gst_pad_push_event (mp3parse->srcpad, event);
GST_PAD_STREAM_LOCK (pad);
if (mp3parse->pending_segment) {
/* Cache all events except EOS if we have a pending segment */
if (GST_EVENT_TYPE (event) != GST_EVENT_EOS)
mp3parse->pending_events =
g_list_append (mp3parse->pending_events, event);
} else {
res = gst_pad_push_event (mp3parse->srcpad, event);
}
GST_PAD_STREAM_UNLOCK (pad);
break;
}
@ -765,6 +779,15 @@ gst_mp3parse_emit_frame (GstMPEGAudioParse * mp3parse, guint size,
gst_pad_push_event (mp3parse->srcpad, mp3parse->pending_segment);
mp3parse->pending_segment = NULL;
}
if (mp3parse->pending_events) {
GList *l;
for (l = mp3parse->pending_events; l != NULL; l = l->next) {
gst_pad_push_event (mp3parse->srcpad, GST_EVENT (l->data));
}
g_list_free (mp3parse->pending_events);
mp3parse->pending_events = NULL;
}
ret = gst_pad_push (mp3parse->srcpad, outbuf);
}

View file

@ -121,6 +121,8 @@ struct _GstMPEGAudioParse {
/* pending segment */
GstEvent *pending_segment;
/* pending events */
GList *pending_events;
};
struct _GstMPEGAudioParseClass {