+2006-07-07 Tim-Philipp Müller <tim at centricular dot net>
+
+ * gst/gstbin.c: (compare_interface), (gst_bin_get_by_interface),
+ (gst_bin_iterate_all_by_interface):
+ Can't use GPOINTER_TO_INT and GINT_TO_POINTER with GTypes.
+ GTypes are gulongs and thus the top 4 bytes might be cut
+ off on some platforms when doing GPOINTER_TO_INT, leading
+ to invalid GTypes and bad things happening.
+ Also add a check to make sure the type passed in is really
+ an interface type.
+
2006-07-07 Tim-Philipp Müller <tim at centricular dot net>
* .cvsignore:
static gint
compare_interface (GstElement * element, gpointer interface)
{
+ GType interface_type = (GType) interface;
gint ret;
- if (G_TYPE_CHECK_INSTANCE_TYPE (element, GPOINTER_TO_INT (interface))) {
+ if (G_TYPE_CHECK_INSTANCE_TYPE (element, interface_type)) {
ret = 0;
} else {
/* we did not find the element, need to release the ref
gst_bin_get_by_interface (GstBin * bin, GType interface)
{
GstIterator *children;
- GstIterator *result;
+ gpointer result;
g_return_val_if_fail (GST_IS_BIN (bin), NULL);
+ g_return_val_if_fail (G_TYPE_IS_INTERFACE (interface), NULL);
children = gst_bin_iterate_recurse (bin);
result = gst_iterator_find_custom (children, (GCompareFunc) compare_interface,
- GINT_TO_POINTER (interface));
+ (gpointer) interface);
gst_iterator_free (children);
return GST_ELEMENT_CAST (result);
GstIterator *result;
g_return_val_if_fail (GST_IS_BIN (bin), NULL);
+ g_return_val_if_fail (G_TYPE_IS_INTERFACE (interface), NULL);
children = gst_bin_iterate_recurse (bin);
result = gst_iterator_filter (children, (GCompareFunc) compare_interface,
- GINT_TO_POINTER (interface));
+ (gpointer) interface);
return result;
}