gst/elements/gsttypefindelement.c: Allow event caching while typefinding so we don't lose events.

Original commit message from CVS:
* gst/elements/gsttypefindelement.c: (gst_type_find_element_init),
(push_buffer_store), (gst_type_find_element_handle_event),
(gst_type_find_element_change_state):
Allow event caching while typefinding so we don't lose events.
* gst/elements/gsttypefindelement.h:
Allow event caching while typefinding so we don't lose events.
* gst/gsttag.c: (_gst_tag_initialize):
* gst/gsttag.h:
Add language-code tag.
* gst/registries/gstlibxmlregistry.c: (load_pad_template),
(load_feature), (load_paths):
Fix memleaks (#300736), based on patch from Kjartan Maraas
<kmaraas@gnome.org>.
This commit is contained in:
Ronald S. Bultje 2005-04-17 20:43:55 +00:00
parent 4088590f88
commit 30f318eb3e
10 changed files with 90 additions and 16 deletions

View file

@ -1,3 +1,19 @@
2005-04-17 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* gst/elements/gsttypefindelement.c: (gst_type_find_element_init),
(push_buffer_store), (gst_type_find_element_handle_event),
(gst_type_find_element_change_state):
Allow event caching while typefinding so we don't lose events.
* gst/elements/gsttypefindelement.h:
Allow event caching while typefinding so we don't lose events.
* gst/gsttag.c: (_gst_tag_initialize):
* gst/gsttag.h:
Add language-code tag.
* gst/registries/gstlibxmlregistry.c: (load_pad_template),
(load_feature), (load_paths):
Fix memleaks (#300736), based on patch from Kjartan Maraas
<kmaraas@gnome.org>.
2005-04-14 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* docs/faq/using.xml:

View file

@ -197,6 +197,7 @@ gst_type_find_element_init (GstTypeFindElement * typefind)
gst_element_add_pad (GST_ELEMENT (typefind), typefind->src);
typefind->caps = NULL;
typefind->pending_events = NULL;
typefind->min_probability = 1;
typefind->max_probability = GST_TYPE_FIND_MAXIMUM;
@ -412,7 +413,18 @@ push_buffer_store (GstTypeFindElement * typefind)
{
guint size = gst_buffer_store_get_size (typefind->store, 0);
GstBuffer *buffer;
const GList *item;
/* handle pending events */
for (item = typefind->pending_events; item; item = item->next) {
GstEvent *e = item->data;
gst_pad_push (typefind->src, GST_DATA (e));
}
g_list_free (typefind->pending_events);
typefind->pending_events = NULL;
/* data */
gst_pad_push (typefind->src, GST_DATA (gst_event_new_discontinuous (TRUE,
GST_FORMAT_DEFAULT, (guint64) 0, GST_FORMAT_BYTES, (guint64) 0,
GST_FORMAT_UNDEFINED)));
@ -494,7 +506,8 @@ gst_type_find_element_handle_event (GstPad * pad, GstEvent * event)
}
break;
default:
gst_data_unref (GST_DATA (event));
typefind->pending_events = g_list_append (typefind->pending_events,
event);
break;
}
break;
@ -816,6 +829,9 @@ gst_type_find_element_change_state (GstElement * element)
case GST_STATE_PAUSED_TO_READY:
stop_typefinding (typefind);
gst_caps_replace (&typefind->caps, NULL);
g_list_foreach (typefind->pending_events, (GFunc) gst_data_unref, NULL);
g_list_free (typefind->pending_events);
typefind->pending_events = NULL;
break;
default:
break;

View file

@ -51,6 +51,7 @@ struct _GstTypeFindElement {
guint min_probability;
guint max_probability;
GstCaps * caps;
GList * pending_events;
guint mode;
guint64 waiting_for_discont_offset;

View file

@ -188,6 +188,9 @@ _gst_tag_initialize (void)
G_TYPE_DOUBLE, _("replaygain album gain"), _("album gain in db"), NULL);
gst_tag_register (GST_TAG_ALBUM_PEAK, GST_TAG_FLAG_META,
G_TYPE_DOUBLE, _("replaygain album peak"), _("peak of the album"), NULL);
gst_tag_register (GST_TAG_LANGUAGE_CODE, GST_TAG_FLAG_META, G_TYPE_STRING,
_("language code"),
_("language code for this stream, conforming to ISO-639-1"), NULL);
}
/**

View file

@ -430,6 +430,12 @@ GstTagList * gst_event_tag_get_list (GstEvent * tag_event);
* peak of the album
*/
#define GST_TAG_ALBUM_PEAK "replaygain-album-peak"
/**
* GST_TAG_LANGUAGE_CODE:
*
* Language code (ISO-639-1)
*/
#define GST_TAG_LANGUAGE_CODE "language-code"
G_END_DECLS

View file

@ -188,6 +188,9 @@ _gst_tag_initialize (void)
G_TYPE_DOUBLE, _("replaygain album gain"), _("album gain in db"), NULL);
gst_tag_register (GST_TAG_ALBUM_PEAK, GST_TAG_FLAG_META,
G_TYPE_DOUBLE, _("replaygain album peak"), _("peak of the album"), NULL);
gst_tag_register (GST_TAG_LANGUAGE_CODE, GST_TAG_FLAG_META, G_TYPE_STRING,
_("language code"),
_("language code for this stream, conforming to ISO-639-1"), NULL);
}
/**

View file

@ -430,6 +430,12 @@ GstTagList * gst_event_tag_get_list (GstEvent * tag_event);
* peak of the album
*/
#define GST_TAG_ALBUM_PEAK "replaygain-album-peak"
/**
* GST_TAG_LANGUAGE_CODE:
*
* Language code (ISO-639-1)
*/
#define GST_TAG_LANGUAGE_CODE "language-code"
G_END_DECLS

View file

@ -680,11 +680,12 @@ load_pad_template (xmlTextReaderPtr reader)
} else if (g_str_equal (tag, "presence")) {
read_enum (reader, GST_TYPE_PAD_PRESENCE, &presence);
} else if (!strncmp (tag, "caps", 4)) {
char *s = NULL;
gchar *s = NULL;
if (!caps && read_string (reader, &s))
if (!caps && read_string (reader, &s)) {
caps = gst_caps_from_string (s);
g_free (s);
g_free (s);
}
}
}
}
@ -699,14 +700,15 @@ load_feature (xmlTextReaderPtr reader)
{
int ret;
int depth = xmlTextReaderDepth (reader);
const gchar *feature_name =
(const gchar *) xmlTextReaderGetAttribute (reader, BAD_CAST "typename");
guchar *feature_name =
xmlTextReaderGetAttribute (reader, BAD_CAST "typename");
GstPluginFeature *feature;
GType type;
if (!feature_name)
return NULL;
type = g_type_from_name (feature_name);
type = g_type_from_name ((gchar *) feature_name);
xmlFree (feature_name);
if (!type)
return NULL;
feature = g_object_new (type, NULL);
@ -744,9 +746,10 @@ load_feature (xmlTextReaderPtr reader)
if (read_string (reader, &s)) {
if (g_ascii_strncasecmp (s, "sink", 4) == 0) {
factory->uri_type = GST_URI_SINK;
} else if (g_ascii_strncasecmp (s, "source", 5) == 0) {
} else if (g_ascii_strncasecmp (s, "source", 6) == 0) {
factory->uri_type = GST_URI_SRC;
}
g_free (s);
}
} else if (g_str_equal (tag, "uri_protocol")) {
gchar *s = NULL;
@ -756,8 +759,10 @@ load_feature (xmlTextReaderPtr reader)
} else if (g_str_equal (tag, "interface")) {
gchar *s = NULL;
if (read_string (reader, &s))
if (read_string (reader, &s)) {
__gst_element_factory_add_interface (factory, s);
g_free (s);
}
} else if (g_str_equal (tag, "padtemplate")) {
GstPadTemplate *template = load_pad_template (reader);
@ -779,7 +784,7 @@ load_feature (xmlTextReaderPtr reader)
} else if (g_str_equal (tag, "caps")) {
gchar *s = NULL;
if (read_string (reader, &s)) {
if (!factory->caps && read_string (reader, &s)) {
factory->caps = gst_caps_from_string (s);
g_free (s);
}
@ -865,11 +870,12 @@ load_paths (xmlTextReaderPtr reader, GstXMLRegistry * registry)
if (g_str_equal (tag, "path")) {
gchar *s = NULL;
if (read_string (reader, &s) &&
!g_list_find_custom (GST_REGISTRY (registry)->paths, s,
(GCompareFunc) strcmp))
gst_registry_add_path (GST_REGISTRY (registry), s);
g_free (s);
if (read_string (reader, &s)) {
if (!g_list_find_custom (GST_REGISTRY (registry)->paths, s,
(GCompareFunc) strcmp))
gst_registry_add_path (GST_REGISTRY (registry), s);
g_free (s);
}
}
}
}

View file

@ -197,6 +197,7 @@ gst_type_find_element_init (GstTypeFindElement * typefind)
gst_element_add_pad (GST_ELEMENT (typefind), typefind->src);
typefind->caps = NULL;
typefind->pending_events = NULL;
typefind->min_probability = 1;
typefind->max_probability = GST_TYPE_FIND_MAXIMUM;
@ -412,7 +413,18 @@ push_buffer_store (GstTypeFindElement * typefind)
{
guint size = gst_buffer_store_get_size (typefind->store, 0);
GstBuffer *buffer;
const GList *item;
/* handle pending events */
for (item = typefind->pending_events; item; item = item->next) {
GstEvent *e = item->data;
gst_pad_push (typefind->src, GST_DATA (e));
}
g_list_free (typefind->pending_events);
typefind->pending_events = NULL;
/* data */
gst_pad_push (typefind->src, GST_DATA (gst_event_new_discontinuous (TRUE,
GST_FORMAT_DEFAULT, (guint64) 0, GST_FORMAT_BYTES, (guint64) 0,
GST_FORMAT_UNDEFINED)));
@ -494,7 +506,8 @@ gst_type_find_element_handle_event (GstPad * pad, GstEvent * event)
}
break;
default:
gst_data_unref (GST_DATA (event));
typefind->pending_events = g_list_append (typefind->pending_events,
event);
break;
}
break;
@ -816,6 +829,9 @@ gst_type_find_element_change_state (GstElement * element)
case GST_STATE_PAUSED_TO_READY:
stop_typefinding (typefind);
gst_caps_replace (&typefind->caps, NULL);
g_list_foreach (typefind->pending_events, (GFunc) gst_data_unref, NULL);
g_list_free (typefind->pending_events);
typefind->pending_events = NULL;
break;
default:
break;

View file

@ -51,6 +51,7 @@ struct _GstTypeFindElement {
guint min_probability;
guint max_probability;
GstCaps * caps;
GList * pending_events;
guint mode;
guint64 waiting_for_discont_offset;