+static gboolean
+gst_lame_sink_event (GstPad * pad, GstEvent * event)
+{
+ GstLame *lame;
+
+ lame = GST_LAME (gst_pad_get_parent (pad));
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_EOS:
+ GST_DEBUG_OBJECT (lame, "handling EOS event");
+ /* FIXME, push last data packet */
+
+ gst_pad_push_event (lame->srcpad, event);
+ break;
+ case GST_EVENT_FLUSH_START:
+ GST_DEBUG_OBJECT (lame, "handling FLUSH start event");
+ /* forward event */
+ gst_pad_push_event (lame->srcpad, event);
+
+ /* make streaming stop */
+ GST_STREAM_LOCK (pad);
+ GST_STREAM_UNLOCK (pad);
+ break;
+ case GST_EVENT_FLUSH_STOP:
+ {
+ guchar *mp3_data = NULL;
+ gint mp3_buffer_size, mp3_size = 0;
+
+ GST_DEBUG_OBJECT (lame, "handling FLUSH stop event");
+
+ /* clear buffers */
+ GST_STREAM_LOCK (pad);
+ mp3_buffer_size = 7200;
+ mp3_data = g_malloc (mp3_buffer_size);
+ mp3_size = lame_encode_flush (lame->lgf, mp3_data, mp3_buffer_size);
+
+ gst_pad_push_event (lame->srcpad, event);
+ GST_STREAM_UNLOCK (pad);
+ break;
+ }
+ case GST_EVENT_TAG:
+ GST_DEBUG_OBJECT (lame, "handling TAG event");
+ if (lame->tags) {
+ GstTagList *taglist;
+
+ gst_event_parse_tag (event, &taglist),
+ gst_tag_list_insert (lame->tags, taglist,
+ gst_tag_setter_get_merge_mode (GST_TAG_SETTER (lame)));
+ } else {
+ g_assert_not_reached ();
+ }
+ gst_pad_push_event (lame->srcpad, event);
+ break;
+ default:
+ gst_pad_push_event (lame->srcpad, event);
+ break;
+ }
+ return TRUE;
+}
+
+static GstFlowReturn
+gst_lame_chain (GstPad * pad, GstBuffer * buf)