From 147fa8b1f7221cb3917b545143abf84cce9d7f88 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Wed, 9 Nov 2011 11:05:59 +0100 Subject: [PATCH 1/3] Android: build audio controller example Add buildsystem hooks for building the audiocontroller example with the NDK. Signed-off-by: Reynaldo H. Verdejo Pinochet --- Android.mk | 2 ++ tests/examples/controller/Makefile.am | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Android.mk b/Android.mk index 6719d9ce7a..54788e1e5a 100644 --- a/Android.mk +++ b/Android.mk @@ -36,6 +36,7 @@ GST_BUILT_SOURCES := \ plugins/Android.mk \ plugins/elements/Android.mk \ plugins/indexers/Android.mk \ + tests/examples/controller/Android.mk \ tools/Android.mk GST_BUILT_SOURCES := $(patsubst %, $(abspath $(gstreamer_TOP))/%, $(GST_BUILT_SOURCES)) @@ -68,3 +69,4 @@ CONFIGURE_TARGETS += gst-configure -include $(gstreamer_TOP)/libs/Android.mk -include $(gstreamer_TOP)/plugins/Android.mk -include $(gstreamer_TOP)/tools/Android.mk +-include $(gstreamer_TOP)/tests/examples/controller/Android.mk diff --git a/tests/examples/controller/Makefile.am b/tests/examples/controller/Makefile.am index 0255ea7a2e..98c1b65c28 100644 --- a/tests/examples/controller/Makefile.am +++ b/tests/examples/controller/Makefile.am @@ -4,3 +4,15 @@ audio_example_CFLAGS = $(GST_OBJ_CFLAGS) -I$(top_builddir)/libs audio_example_LDADD = \ $(top_builddir)/libs/gst/controller/libgstcontroller-@GST_MAJORMINOR@.la \ $(GST_OBJ_LIBS) + +Android.mk: Makefile.am audio-example.c + androgenizer \ + -:PROJECT audio-example -:EXECUTABLE audio-example \ + -:TAGS eng debug \ + -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ + -:SOURCES audio-example.c \ + -:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(audio_example_CFLAGS) \ + -:LDFLAGS -lgstcontroller-@GST_MAJORMINOR@ \ + $(GST_OBJ_LIBS) -ldl \ + -:PASSTHROUGH LOCAL_ARM_MODE:=arm \ + > $@ From 4d6795dcd15f957ba9faf98056d9442be3a40eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 12 Nov 2011 14:55:07 +0000 Subject: [PATCH 2/3] gst, controller: replace g_list_prepend + reverse with GQueue --- gst/gstelementfactory.c | 6 ++-- gst/gstparse.c | 16 ++++----- gst/gstplugin.c | 36 +++++++------------ .../gstinterpolationcontrolsource.c | 8 ++--- 4 files changed, 27 insertions(+), 39 deletions(-) diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 0eca4576d7..a74183c569 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -888,7 +888,7 @@ GList * gst_element_factory_list_filter (GList * list, const GstCaps * caps, GstPadDirection direction, gboolean subsetonly) { - GList *result = NULL; + GQueue results = G_QUEUE_INIT; GST_DEBUG ("finding factories"); @@ -922,7 +922,7 @@ gst_element_factory_list_filter (GList * list, if ((subsetonly && gst_caps_is_subset (caps, tmpl_caps)) || (!subsetonly && gst_caps_can_intersect (caps, tmpl_caps))) { /* non empty intersection, we can use this element */ - result = g_list_prepend (result, gst_object_ref (factory)); + g_queue_push_tail (&results, gst_object_ref (factory)); gst_caps_unref (tmpl_caps); break; } @@ -930,5 +930,5 @@ gst_element_factory_list_filter (GList * list, } } } - return g_list_reverse (result); + return results.head; } diff --git a/gst/gstparse.c b/gst/gstparse.c index 910fc8f702..a2d3d3deaf 100644 --- a/gst/gstparse.c +++ b/gst/gstparse.c @@ -44,12 +44,6 @@ #include "parse/types.h" #endif -static void -_prepend_missing_element (gchar * element, GList ** list) -{ - *list = g_list_prepend (*list, g_strdup (element)); -} - static GstParseContext * gst_parse_context_copy (const GstParseContext * context) { @@ -58,9 +52,13 @@ gst_parse_context_copy (const GstParseContext * context) ret = gst_parse_context_new (); if (context) { - g_list_foreach (context->missing_elements, (GFunc) _prepend_missing_element, - &ret->missing_elements); - ret->missing_elements = g_list_reverse (ret->missing_elements); + GQueue missing_copy = G_QUEUE_INIT; + GList *l; + + for (l = context->missing_elements; l != NULL; l = l->next) + g_queue_push_tail (&missing_copy, g_strdup ((const gchar *) l->data)); + + ret->missing_elements = missing_copy.head; } #endif return ret; diff --git a/gst/gstplugin.c b/gst/gstplugin.c index 4db7612d13..02e5cc959e 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -1451,12 +1451,11 @@ _priv_plugin_deps_env_vars_changed (GstPlugin * plugin) return FALSE; } -static GList * +static void gst_plugin_ext_dep_extract_env_vars_paths (GstPlugin * plugin, - GstPluginDep * dep) + GstPluginDep * dep, GQueue * paths) { gchar **evars; - GList *paths = NULL; for (evars = dep->env_vars; evars != NULL && *evars != NULL; ++evars) { const gchar *e; @@ -1503,9 +1502,9 @@ gst_plugin_ext_dep_extract_env_vars_paths (GstPlugin * plugin, full_path = g_strdup (arr[i]); } - if (!g_list_find_custom (paths, full_path, (GCompareFunc) strcmp)) { + if (!g_queue_find_custom (paths, full_path, (GCompareFunc) strcmp)) { GST_LOG_OBJECT (plugin, "path: '%s'", full_path); - paths = g_list_prepend (paths, full_path); + g_queue_push_tail (paths, full_path); full_path = NULL; } else { GST_LOG_OBJECT (plugin, "path: '%s' (duplicate,ignoring)", full_path); @@ -1519,10 +1518,7 @@ gst_plugin_ext_dep_extract_env_vars_paths (GstPlugin * plugin, g_strfreev (components); } - GST_LOG_OBJECT (plugin, "Extracted %d paths from environment", - g_list_length (paths)); - - return paths; + GST_LOG_OBJECT (plugin, "Extracted %d paths from environment", paths->length); } static guint @@ -1668,43 +1664,37 @@ static guint gst_plugin_ext_dep_get_stat_hash (GstPlugin * plugin, GstPluginDep * dep) { gboolean paths_are_default_only; - GList *scan_paths; + GQueue scan_paths = G_QUEUE_INIT; guint scan_hash = 0; + gchar *path; GST_LOG_OBJECT (plugin, "start"); paths_are_default_only = dep->flags & GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY; - scan_paths = gst_plugin_ext_dep_extract_env_vars_paths (plugin, dep); + gst_plugin_ext_dep_extract_env_vars_paths (plugin, dep, &scan_paths); - if (scan_paths == NULL || !paths_are_default_only) { + if (g_queue_is_empty (&scan_paths) || !paths_are_default_only) { gchar **paths; for (paths = dep->paths; paths != NULL && *paths != NULL; ++paths) { const gchar *path = *paths; - if (!g_list_find_custom (scan_paths, path, (GCompareFunc) strcmp)) { + if (!g_queue_find_custom (&scan_paths, path, (GCompareFunc) strcmp)) { GST_LOG_OBJECT (plugin, "path: '%s'", path); - scan_paths = g_list_prepend (scan_paths, g_strdup (path)); + g_queue_push_tail (&scan_paths, g_strdup (path)); } else { GST_LOG_OBJECT (plugin, "path: '%s' (duplicate, ignoring)", path); } } } - /* not that the order really matters, but it makes debugging easier */ - scan_paths = g_list_reverse (scan_paths); - - while (scan_paths != NULL) { - const gchar *path = scan_paths->data; - + while ((path = g_queue_pop_head (&scan_paths))) { scan_hash += gst_plugin_ext_dep_scan_path_with_filenames (plugin, path, (const gchar **) dep->names, dep->flags); scan_hash = scan_hash << 1; - - g_free (scan_paths->data); - scan_paths = g_list_delete_link (scan_paths, scan_paths); + g_free (path); } GST_LOG_OBJECT (plugin, "done, scan_hash: %08x", scan_hash); diff --git a/libs/gst/controller/gstinterpolationcontrolsource.c b/libs/gst/controller/gstinterpolationcontrolsource.c index 8f7d1d86f6..f320d7d0fc 100644 --- a/libs/gst/controller/gstinterpolationcontrolsource.c +++ b/libs/gst/controller/gstinterpolationcontrolsource.c @@ -604,9 +604,9 @@ gst_interpolation_control_source_unset_all (GstInterpolationControlSource * } static void -_append_control_point (GstControlPoint * cp, GList ** l) +_append_control_point (GstControlPoint * cp, GQueue * res) { - *l = g_list_prepend (*l, cp); + g_queue_push_tail (res, cp); } /** @@ -621,7 +621,7 @@ _append_control_point (GstControlPoint * cp, GList ** l) GList * gst_interpolation_control_source_get_all (GstInterpolationControlSource * self) { - GList *res = NULL; + GQueue res = G_QUEUE_INIT; g_return_val_if_fail (GST_IS_INTERPOLATION_CONTROL_SOURCE (self), NULL); @@ -631,7 +631,7 @@ gst_interpolation_control_source_get_all (GstInterpolationControlSource * self) &res); g_mutex_unlock (self->lock); - return g_list_reverse (res); + return res.head; } /** From c0d5857cd997ee8d3e6674bf92f7ad76c2c2de8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 12 Nov 2011 16:42:14 +0000 Subject: [PATCH 3/3] gst-inspect: print current value as default value Instead of printing separate 'Current' and 'Default' values (the former obtained via g_object_get() and the latter from the property GParamSpec), simply print the Current value as the Default value. This is the right thing to do for almost all elements and avoids confusion if a subclass of a base class chooses a different default than the base class. --- tools/gst-inspect.c | 94 +++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 64 deletions(-) diff --git a/tools/gst-inspect.c b/tools/gst-inspect.c index c8f51e5dd4..e3306d1c81 100644 --- a/tools/gst-inspect.c +++ b/tools/gst-inspect.c @@ -358,6 +358,11 @@ print_element_properties_info (GstElement * element) readable = TRUE; g_print ("%s%s", (first_flag) ? "" : ", ", _("readable")); first_flag = FALSE; + } else { + /* if we can't read the property value, assume it's set to the default + * (which might not be entirely true for sub-classes, but that's an + * unlikely corner-case anyway) */ + g_param_value_set_default (param, &value); } if (param->flags & G_PARAM_WRITABLE) { g_print ("%s%s", (first_flag) ? "" : ", ", _("writable")); @@ -383,34 +388,23 @@ print_element_properties_info (GstElement * element) switch (G_VALUE_TYPE (&value)) { case G_TYPE_STRING: { - GParamSpecString *pstring = G_PARAM_SPEC_STRING (param); + const char *string_val = g_value_get_string (&value); n_print ("%-23.23s String. ", ""); - if (pstring->default_value == NULL) - g_print ("Default: null "); + if (string_val == NULL) + g_print ("Default: null"); else - g_print ("Default: \"%s\" ", pstring->default_value); - - if (readable) { - const char *string_val = g_value_get_string (&value); - - if (string_val == NULL) - g_print ("Current: null"); - else - g_print ("Current: \"%s\"", string_val); - } + g_print ("Default: \"%s\"", string_val); break; } case G_TYPE_BOOLEAN: { - GParamSpecBoolean *pboolean = G_PARAM_SPEC_BOOLEAN (param); + gboolean bool_val = g_value_get_boolean (&value); n_print ("%-23.23s Boolean. ", ""); - g_print ("Default: %s ", (pboolean->default_value ? "true" : "false")); - if (readable) - g_print ("Current: %s", - (g_value_get_boolean (&value) ? "true" : "false")); + + g_print ("Default: %s", bool_val ? "true" : "false"); break; } case G_TYPE_ULONG: @@ -419,9 +413,7 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Unsigned Long. ", ""); g_print ("Range: %lu - %lu Default: %lu ", - pulong->minimum, pulong->maximum, pulong->default_value); - if (readable) - g_print ("Current: %lu", g_value_get_ulong (&value)); + pulong->minimum, pulong->maximum, g_value_get_ulong (&value)); break; } case G_TYPE_LONG: @@ -430,9 +422,7 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Long. ", ""); g_print ("Range: %ld - %ld Default: %ld ", - plong->minimum, plong->maximum, plong->default_value); - if (readable) - g_print ("Current: %ld", g_value_get_long (&value)); + plong->minimum, plong->maximum, g_value_get_long (&value)); break; } case G_TYPE_UINT: @@ -441,9 +431,7 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Unsigned Integer. ", ""); g_print ("Range: %u - %u Default: %u ", - puint->minimum, puint->maximum, puint->default_value); - if (readable) - g_print ("Current: %u", g_value_get_uint (&value)); + puint->minimum, puint->maximum, g_value_get_uint (&value)); break; } case G_TYPE_INT: @@ -452,9 +440,7 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Integer. ", ""); g_print ("Range: %d - %d Default: %d ", - pint->minimum, pint->maximum, pint->default_value); - if (readable) - g_print ("Current: %d", g_value_get_int (&value)); + pint->minimum, pint->maximum, g_value_get_int (&value)); break; } case G_TYPE_UINT64: @@ -464,9 +450,7 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Unsigned Integer64. ", ""); g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT " Default: %" G_GUINT64_FORMAT " ", - puint64->minimum, puint64->maximum, puint64->default_value); - if (readable) - g_print ("Current: %" G_GUINT64_FORMAT, g_value_get_uint64 (&value)); + puint64->minimum, puint64->maximum, g_value_get_uint64 (&value)); break; } case G_TYPE_INT64: @@ -476,9 +460,7 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Integer64. ", ""); g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT " Default: %" G_GINT64_FORMAT " ", - pint64->minimum, pint64->maximum, pint64->default_value); - if (readable) - g_print ("Current: %" G_GINT64_FORMAT, g_value_get_int64 (&value)); + pint64->minimum, pint64->maximum, g_value_get_int64 (&value)); break; } case G_TYPE_FLOAT: @@ -487,9 +469,7 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Float. ", ""); g_print ("Range: %15.7g - %15.7g Default: %15.7g ", - pfloat->minimum, pfloat->maximum, pfloat->default_value); - if (readable) - g_print ("Current: %15.7g", g_value_get_float (&value)); + pfloat->minimum, pfloat->maximum, g_value_get_float (&value)); break; } case G_TYPE_DOUBLE: @@ -498,9 +478,7 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Double. ", ""); g_print ("Range: %15.7g - %15.7g Default: %15.7g ", - pdouble->minimum, pdouble->maximum, pdouble->default_value); - if (readable) - g_print ("Current: %15.7g", g_value_get_double (&value)); + pdouble->minimum, pdouble->maximum, g_value_get_double (&value)); break; } default: @@ -513,27 +491,22 @@ print_element_properties_info (GstElement * element) print_caps (caps, " "); } } else if (G_IS_PARAM_SPEC_ENUM (param)) { - GParamSpecEnum *penum = G_PARAM_SPEC_ENUM (param); GEnumValue *values; guint j = 0; gint enum_value; - const gchar *def_val_nick = "", *cur_val_nick = ""; + const gchar *value_nick = ""; values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values; enum_value = g_value_get_enum (&value); while (values[j].value_name) { if (values[j].value == enum_value) - cur_val_nick = values[j].value_nick; - if (values[j].value == penum->default_value) - def_val_nick = values[j].value_nick; + value_nick = values[j].value_nick; j++; } - n_print - ("%-23.23s Enum \"%s\" Default: %d, \"%s\" Current: %d, \"%s\"", - "", g_type_name (G_VALUE_TYPE (&value)), penum->default_value, - def_val_nick, enum_value, cur_val_nick); + n_print ("%-23.23s Enum \"%s\" Default: %d, \"%s\"", "", + g_type_name (G_VALUE_TYPE (&value)), enum_value, value_nick); j = 0; while (values[j].value_name) { @@ -548,17 +521,15 @@ print_element_properties_info (GstElement * element) } else if (G_IS_PARAM_SPEC_FLAGS (param)) { GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param); GFlagsValue *vals; - gchar *cur, *def; + gchar *cur; vals = pflags->flags_class->values; cur = flags_to_string (vals, g_value_get_flags (&value)); - def = flags_to_string (vals, pflags->default_value); - n_print - ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\" Current: 0x%08x, \"%s\"", - "", g_type_name (G_VALUE_TYPE (&value)), pflags->default_value, - def, g_value_get_flags (&value), cur); + n_print ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\"", "", + g_type_name (G_VALUE_TYPE (&value)), + g_value_get_flags (&value), cur); while (vals[0].value_name) { g_print ("\n"); @@ -570,7 +541,6 @@ print_element_properties_info (GstElement * element) } g_free (cur); - g_free (def); } else if (G_IS_PARAM_SPEC_OBJECT (param)) { n_print ("%-23.23s Object of type \"%s\"", "", g_type_name (param->value_type)); @@ -601,12 +571,8 @@ print_element_properties_info (GstElement * element) g_print ("Range: %d/%d - %d/%d Default: %d/%d ", pfraction->min_num, pfraction->min_den, pfraction->max_num, pfraction->max_den, - pfraction->def_num, pfraction->def_den); - if (readable) - g_print ("Current: %d/%d", - gst_value_get_fraction_numerator (&value), - gst_value_get_fraction_denominator (&value)); - + gst_value_get_fraction_numerator (&value), + gst_value_get_fraction_denominator (&value)); } else if (GST_IS_PARAM_SPEC_MINI_OBJECT (param)) { n_print ("%-23.23s MiniObject of type \"%s\"", "", g_type_name (param->value_type));