From 7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sun, 14 Mar 2004 22:34:33 +0000 Subject: gst-indent Original commit message from CVS: gst-indent --- examples/dynparams/filter.c | 294 +++++++++++++++++++++----------------------- 1 file changed, 141 insertions(+), 153 deletions(-) (limited to 'examples/dynparams') diff --git a/examples/dynparams/filter.c b/examples/dynparams/filter.c index ed0dd5aa..982a4c7a 100644 --- a/examples/dynparams/filter.c +++ b/examples/dynparams/filter.c @@ -18,13 +18,13 @@ struct _filter_ui GtkWidget *window; /* top-level interface window */ GtkWidget *buttons; /* all of the control buttons */ - GtkWidget *parse, *play, *stop; /* control buttons */ - + GtkWidget *parse, *play, *stop; /* control buttons */ + GtkWidget *feedback; /* here's where we'll tell you stuff */ GtkTextBuffer *fb_buffer; /* feedback buffer */ GtkWidget *selection; /* the place to input element stuff */ - GtkWidget *input, *filter, *output; /* the selection widgets */ - + GtkWidget *input, *filter, *output; /* the selection widgets */ + GtkWidget *control; /* the dynamically generated control UI */ }; @@ -33,13 +33,13 @@ typedef struct _filter_ui _filter_ui_t; /* back-end data */ struct _filter_data { - _filter_ui_t *ui; /* the UI data */ + _filter_ui_t *ui; /* the UI data */ gchar *input_pipe, *output_pipe, *filter_element; gchar *pipe_string; GList *filter_choices; gboolean playing; - GstElement *input, *output; /* these are in and out bins */ + GstElement *input, *output; /* these are in and out bins */ GstElement *pipeline; GstElement *filter; }; @@ -47,17 +47,18 @@ struct _filter_data typedef struct _filter_data _filter_data_t; /* internal prototypes when they can't be avoided */ -void cb_remove_and_destroy (GtkWidget *widget, gpointer user_data); -//void cb_dynparm_value_changed (GtkWidget *widget, gpointer user_data); -void cb_dynparm_value_changed (GtkRange *range, GstDParam *dparam); +void cb_remove_and_destroy (GtkWidget * widget, gpointer user_data); + +//void cb_dynparm_value_changed (GtkWidget *widget, gpointer user_data); +void cb_dynparm_value_changed (GtkRange * range, GstDParam * dparam); /* GStreamer helper functions go here */ - + /* go through a bin, finding the one pad that is unconnected in the given * direction, and return a ghost pad */ GstPad * -gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction, - gchar *name) +gst_bin_find_unconnected_pad (GstBin * bin, GstPadDirection direction, + gchar * name) { GstPad *pad = NULL; GList *elements = NULL; @@ -67,39 +68,36 @@ gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction, g_print ("DEBUG: find_unconnected start\n"); elements = (GList *) gst_bin_get_list (bin); /* traverse all elements looking for unconnected pads */ - while (elements && pad == NULL) - { + while (elements && pad == NULL) { element = GST_ELEMENT (elements->data); g_print ("DEBUG: looking in element %s\n", gst_element_get_name (element)); pads = gst_element_get_pad_list (element); - while (pads) - { + while (pads) { /* check if the direction matches */ - if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction) - { - if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL) - { + if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction) { + if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL) { /* found it ! */ g_print ("DEBUG: found an unconnected pad !\n"); pad = GST_PAD (pads->data); } } - if (pad) break; /* found one already */ + if (pad) + break; /* found one already */ pads = g_list_next (pads); } elements = g_list_next (elements); } g_print ("DEBUG: find_unconnected stop\n"); - if (pad == NULL) /* we didn't find it at all */ + if (pad == NULL) /* we didn't find it at all */ return NULL; - + pad = gst_ghost_pad_new (name, pad); return pad; } void -ui_feedback_add_text (_filter_ui_t *ui, const gchar *text) +ui_feedback_add_text (_filter_ui_t * ui, const gchar * text) { GtkTextIter iter; @@ -108,7 +106,7 @@ ui_feedback_add_text (_filter_ui_t *ui, const gchar *text) } void -ui_feedback_add (_filter_ui_t *ui, const gchar *format, ...) +ui_feedback_add (_filter_ui_t * ui, const gchar * format, ...) { va_list args; gchar *buffer = NULL; @@ -121,7 +119,7 @@ ui_feedback_add (_filter_ui_t *ui, const gchar *format, ...) } void -ui_feedback_clear (_filter_ui_t *ui) +ui_feedback_clear (_filter_ui_t * ui) { gtk_text_buffer_set_text (ui->fb_buffer, "", 0); } @@ -129,7 +127,7 @@ ui_feedback_clear (_filter_ui_t *ui) /* create the control widget using the element's dynparams * control is a vbox which we need to empty first */ void -ui_control_create (GstElement *element, GtkWidget *control, _filter_ui_t *ui) +ui_control_create (GstElement * element, GtkWidget * control, _filter_ui_t * ui) { GtkWidget *hbox = NULL; GtkWidget *widget = NULL; @@ -137,70 +135,63 @@ ui_control_create (GstElement *element, GtkWidget *control, _filter_ui_t *ui) GstDParam *dparam = NULL; GParamSpec **specs = NULL; int i = 0; - + g_assert (GTK_IS_VBOX (control)); /* empty control vbox */ g_print ("DEBUG: emptying control widget\n"); - gtk_container_foreach (GTK_CONTAINER (control), cb_remove_and_destroy, - (gpointer) control); + gtk_container_foreach (GTK_CONTAINER (control), cb_remove_and_destroy, + (gpointer) control); g_print ("DEBUG: adding label to control widget\n"); widget = gtk_label_new ("Dynamic Parameters"); gtk_container_add (GTK_CONTAINER (control), widget); gtk_widget_show (widget); - - if ((dpman = gst_dpman_get_manager (element))) - { + + if ((dpman = gst_dpman_get_manager (element))) { ui_feedback_add (ui, "Found Dynamic Parameters on filter element.\n"); specs = gst_dpman_list_dparam_specs (dpman); - for (i = 0; specs[i] != NULL; ++i) - { + for (i = 0; specs[i] != NULL; ++i) { hbox = gtk_hbox_new (FALSE, 0); widget = gtk_label_new (g_param_spec_get_name (specs[i])); gtk_container_add (GTK_CONTAINER (hbox), widget); gtk_widget_show (widget); - switch (G_PARAM_SPEC_VALUE_TYPE (specs[i])) - { - case G_TYPE_INT64: + switch (G_PARAM_SPEC_VALUE_TYPE (specs[i])) { + case G_TYPE_INT64: widget = gtk_hscale_new_with_range ( - (gdouble) (((GParamSpecInt64*)specs[i])->minimum), - (gdouble) (((GParamSpecInt64*)specs[i])->maximum), - 1.0); + (gdouble) (((GParamSpecInt64 *) specs[i])->minimum), + (gdouble) (((GParamSpecInt64 *) specs[i])->maximum), 1.0); gtk_range_set_value (GTK_RANGE (widget), - (gdouble) ((GParamSpecInt64*)specs[i])->default_value); - break; + (gdouble) ((GParamSpecInt64 *) specs[i])->default_value); + break; case G_TYPE_INT: widget = gtk_hscale_new_with_range ( - (gdouble) (((GParamSpecInt*)specs[i])->minimum), - (gdouble) (((GParamSpecInt*)specs[i])->maximum), - 1.0); + (gdouble) (((GParamSpecInt *) specs[i])->minimum), + (gdouble) (((GParamSpecInt *) specs[i])->maximum), 1.0); gtk_range_set_value (GTK_RANGE (widget), - (gdouble) ((GParamSpecInt*)specs[i])->default_value); - break; - case G_TYPE_FLOAT: + (gdouble) ((GParamSpecInt *) specs[i])->default_value); + break; + case G_TYPE_FLOAT: widget = gtk_hscale_new_with_range ( - (gdouble) (((GParamSpecFloat*)specs[i])->minimum), - (gdouble) (((GParamSpecFloat*)specs[i])->maximum), - 0.00001); + (gdouble) (((GParamSpecFloat *) specs[i])->minimum), + (gdouble) (((GParamSpecFloat *) specs[i])->maximum), 0.00001); gtk_range_set_value (GTK_RANGE (widget), - (gdouble) ((GParamSpecFloat*)specs[i])->default_value); + (gdouble) ((GParamSpecFloat *) specs[i])->default_value); break; } /* create the dparam object */ dparam = gst_dpsmooth_new (G_PARAM_SPEC_VALUE_TYPE (specs[i])); g_object_set (G_OBJECT (dparam), "update_period", 2000000LL, NULL); - g_assert (gst_dpman_attach_dparam (dpman, - (gchar *) g_param_spec_get_name (specs[i]), - dparam)); - gst_dpman_set_mode(dpman, "asynchronous"); + g_assert (gst_dpman_attach_dparam (dpman, + (gchar *) g_param_spec_get_name (specs[i]), dparam)); + gst_dpman_set_mode (dpman, "asynchronous"); g_signal_connect (widget, "value-changed", - G_CALLBACK (cb_dynparm_value_changed), dparam); + G_CALLBACK (cb_dynparm_value_changed), dparam); cb_dynparm_value_changed (GTK_RANGE (widget), dparam); - + gtk_container_add (GTK_CONTAINER (hbox), widget); - gtk_widget_show (widget); + gtk_widget_show (widget); } gtk_container_add (GTK_CONTAINER (control), hbox); gtk_widget_show (hbox); @@ -209,7 +200,7 @@ ui_control_create (GstElement *element, GtkWidget *control, _filter_ui_t *ui) /* all the pretty callbacks gather here please */ void -cb_remove_and_destroy (GtkWidget *widget, gpointer user_data) +cb_remove_and_destroy (GtkWidget * widget, gpointer user_data) { GtkContainer *container = GTK_CONTAINER (user_data); @@ -220,55 +211,51 @@ cb_remove_and_destroy (GtkWidget *widget, gpointer user_data) /* when the scale associated with a dparam changes, respond */ void -cb_dynparm_value_changed (GtkRange *range, GstDParam *dparam) +cb_dynparm_value_changed (GtkRange * range, GstDParam * dparam) { /* - GstDParam *dparam = GST_DPARAM (user_data); - GtkHScale *adj = GTK_HSCALE (widget); - */ + GstDParam *dparam = GST_DPARAM (user_data); + GtkHScale *adj = GTK_HSCALE (widget); + */ gdouble value = 0.0; + g_assert (GST_IS_DPARAM (dparam)); g_assert (GTK_IS_RANGE (range)); value = gtk_range_get_value (range); - g_print ("DEBUG: setting value to %f\n", value); + g_print ("DEBUG: setting value to %f\n", value); - switch (G_PARAM_SPEC_VALUE_TYPE (GST_DPARAM_PARAM_SPEC (dparam))) - { + switch (G_PARAM_SPEC_VALUE_TYPE (GST_DPARAM_PARAM_SPEC (dparam))) { case G_TYPE_INT64: - g_object_set (G_OBJECT (dparam), "value_int64", - (gint64) value, NULL); + g_object_set (G_OBJECT (dparam), "value_int64", (gint64) value, NULL); break; case G_TYPE_INT: - g_object_set (G_OBJECT (dparam), "value_int", - (gint) value, NULL); + g_object_set (G_OBJECT (dparam), "value_int", (gint) value, NULL); break; case G_TYPE_FLOAT: - g_object_set (G_OBJECT (dparam), "value_float", - (gfloat) value, NULL); + g_object_set (G_OBJECT (dparam), "value_float", (gfloat) value, NULL); break; } } - + void -cb_entry_activate (GtkEntry *entry, gpointer user_data) +cb_entry_activate (GtkEntry * entry, gpointer user_data) { g_print ("DEBUG: oi ! you activated an entry !\n"); g_print ("DEBUG: pipeline: %s\n", gtk_entry_get_text (entry)); } void -cb_play_clicked (GtkButton *button, gpointer *user_data) +cb_play_clicked (GtkButton * button, gpointer * user_data) { _filter_data_t *fd = (_filter_data_t *) user_data; g_return_if_fail (GST_IS_PIPELINE (fd->pipeline)); - if (GST_STATE (fd->pipeline) == GST_STATE_PLAYING) - { + if (GST_STATE (fd->pipeline) == GST_STATE_PLAYING) { ui_feedback_add (fd->ui, "Pipeline is already playing !\n"); return; } @@ -276,12 +263,11 @@ cb_play_clicked (GtkButton *button, gpointer *user_data) } void -cb_stop_clicked (GtkButton *button, gpointer *user_data) +cb_stop_clicked (GtkButton * button, gpointer * user_data) { _filter_data_t *fd = (_filter_data_t *) user_data; - if (GST_STATE (fd->pipeline) != GST_STATE_PLAYING) - { + if (GST_STATE (fd->pipeline) != GST_STATE_PLAYING) { ui_feedback_add (fd->ui, "Pipeline is not playing !\n"); return; } @@ -289,67 +275,72 @@ cb_stop_clicked (GtkButton *button, gpointer *user_data) } void -cb_parse_clicked (GtkButton *button, gpointer *user_data) +cb_parse_clicked (GtkButton * button, gpointer * user_data) { _filter_data_t *fd = (_filter_data_t *) user_data; GtkCombo *filter = GTK_COMBO (fd->ui->filter); GError *error = NULL; GstPad *src_pad, *sink_pad; - + g_print ("DEBUG: you pressed parse.\n"); ui_feedback_clear (fd->ui); ui_feedback_add (fd->ui, "Parsing pipeline ...\n"); - if (fd->input_pipe) g_free (fd->input_pipe); - if (fd->output_pipe) g_free (fd->output_pipe); - if (fd->filter_element) g_free (fd->filter_element); + if (fd->input_pipe) + g_free (fd->input_pipe); + if (fd->output_pipe) + g_free (fd->output_pipe); + if (fd->filter_element) + g_free (fd->filter_element); fd->input_pipe = g_strdup_printf ("bin.( %s )", - gtk_entry_get_text (GTK_ENTRY (fd->ui->input))); + gtk_entry_get_text (GTK_ENTRY (fd->ui->input))); fd->output_pipe = g_strdup_printf ("bin.( %s )", - gtk_entry_get_text (GTK_ENTRY (fd->ui->output))); + gtk_entry_get_text (GTK_ENTRY (fd->ui->output))); /* gtkcombo.h says I can access the entry field directly */ - fd->filter_element = g_strdup (gtk_entry_get_text (GTK_ENTRY (filter->entry))); - g_print ("Input pipeline :\t%s (%d)\n", fd->input_pipe, (int)strlen (fd->input_pipe)); - g_print ("Filter element :\t%s (%d)\n", fd->filter_element, (int)strlen (fd->filter_element)); - g_print ("Output pipeline :\t%s (%d)\n", fd->output_pipe, (int)strlen (fd->output_pipe)); + fd->filter_element = + g_strdup (gtk_entry_get_text (GTK_ENTRY (filter->entry))); + g_print ("Input pipeline :\t%s (%d)\n", fd->input_pipe, + (int) strlen (fd->input_pipe)); + g_print ("Filter element :\t%s (%d)\n", fd->filter_element, + (int) strlen (fd->filter_element)); + g_print ("Output pipeline :\t%s (%d)\n", fd->output_pipe, + (int) strlen (fd->output_pipe)); /* try to create in and out bins */ - if (strlen (fd->input_pipe) == 0) - { + if (strlen (fd->input_pipe) == 0) { ui_feedback_add (fd->ui, "Error : try setting an input pipe.\n"); return; } - if (fd->input) gst_object_unref (GST_OBJECT (fd->input)); + if (fd->input) + gst_object_unref (GST_OBJECT (fd->input)); fd->input = GST_ELEMENT (gst_parse_launch (fd->input_pipe, &error)); - if (error) - { - ui_feedback_add (fd->ui, "Error : parsing input pipeline : %s\n", - error->message); + if (error) { + ui_feedback_add (fd->ui, "Error : parsing input pipeline : %s\n", + error->message); g_error_free (error); return; } - - if (strlen (fd->output_pipe) == 0) - { + + if (strlen (fd->output_pipe) == 0) { ui_feedback_add (fd->ui, "Error : try setting an output pipe.\n"); return; } - if (fd->output) gst_object_unref (GST_OBJECT (fd->output)); + if (fd->output) + gst_object_unref (GST_OBJECT (fd->output)); fd->output = GST_ELEMENT (gst_parse_launch (fd->output_pipe, &error)); - if (error) - { - ui_feedback_add (fd->ui, "Error : parsing output pipeline : %s\n", - error->message); + if (error) { + ui_feedback_add (fd->ui, "Error : parsing output pipeline : %s\n", + error->message); g_error_free (error); return; } /* try to create filter */ - if (fd->filter) gst_object_unref (GST_OBJECT (fd->filter)); + if (fd->filter) + gst_object_unref (GST_OBJECT (fd->filter)); fd->filter = gst_element_factory_make (fd->filter_element, "filter"); - if (fd->filter == NULL) - { + if (fd->filter == NULL) { ui_feedback_add (fd->ui, "Error : could not create element %s\n", - fd->filter_element); + fd->filter_element); return; } @@ -360,35 +351,33 @@ cb_parse_clicked (GtkButton *button, gpointer *user_data) fd->pipeline = gst_thread_new ("toplevel"); /* add the players to it */ - gst_bin_add_many (GST_BIN (fd->pipeline), - fd->input, fd->filter, - fd->output, NULL); + gst_bin_add_many (GST_BIN (fd->pipeline), + fd->input, fd->filter, fd->output, NULL); /* connect filter to input and output bin */ - src_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->input), GST_PAD_SRC, - "source"); - if (src_pad == NULL) - { - ui_feedback_add (fd->ui, - "Error : could not find an unconnected source pad !\n"); + src_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->input), GST_PAD_SRC, + "source"); + if (src_pad == NULL) { + ui_feedback_add (fd->ui, + "Error : could not find an unconnected source pad !\n"); return; } - sink_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->output), GST_PAD_SINK, - "sink"); - if (sink_pad == NULL) - { - ui_feedback_add (fd->ui, - "Error : could not find an unconnected sink pad !\n"); + sink_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->output), GST_PAD_SINK, + "sink"); + if (sink_pad == NULL) { + ui_feedback_add (fd->ui, + "Error : could not find an unconnected sink pad !\n"); return; } gst_element_add_pad (fd->input, src_pad); gst_element_add_pad (fd->output, sink_pad); gst_element_link_many (fd->input, fd->filter, fd->output, NULL); - - if (fd->pipe_string) g_free (fd->pipe_string); + + if (fd->pipe_string) + g_free (fd->pipe_string); fd->pipe_string = g_strdup_printf ("%s ! %s ! %s", fd->input_pipe, - fd->filter_element, fd->output_pipe); + fd->filter_element, fd->output_pipe); g_print ("Pipeline : %s\n", fd->pipe_string); ui_feedback_add (fd->ui, "Complete parsed pipeline: %s\n", fd->pipe_string); @@ -404,12 +393,12 @@ get_filter_choices (void) choices = g_list_append (choices, "volume"); choices = g_list_append (choices, "ladspa_lpf"); choices = g_list_append (choices, "ladspa_hpf"); - + return choices; } void -init_data (_filter_data_t *fd) +init_data (_filter_data_t * fd) { fd->input_pipe = NULL; fd->output_pipe = NULL; @@ -426,11 +415,11 @@ init_data (_filter_data_t *fd) } void -create_ui (_filter_ui_t *fui, _filter_data_t *fd) +create_ui (_filter_ui_t * fui, _filter_data_t * fd) { GtkWidget *widget; /* temporary widget */ GtkWidget *vbox; /* temporary vbox */ - + g_print ("DEBUG: creating top-level window\n"); fui->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); widget = gtk_vbox_new (FALSE, 0); @@ -452,22 +441,22 @@ create_ui (_filter_ui_t *fui, _filter_data_t *fd) fui->parse = gtk_button_new_with_label ("Parse"); gtk_container_add (GTK_CONTAINER (fui->buttons), fui->parse); g_signal_connect (G_OBJECT (fui->parse), "clicked", - G_CALLBACK (cb_parse_clicked), fd); + G_CALLBACK (cb_parse_clicked), fd); fui->play = gtk_button_new_with_label ("Play"); gtk_container_add (GTK_CONTAINER (fui->buttons), fui->play); g_signal_connect (G_OBJECT (fui->play), "clicked", - G_CALLBACK (cb_play_clicked), fd); + G_CALLBACK (cb_play_clicked), fd); fui->stop = gtk_button_new_with_label ("Stop"); gtk_container_add (GTK_CONTAINER (fui->buttons), fui->stop); g_signal_connect (G_OBJECT (fui->stop), "clicked", - G_CALLBACK (cb_stop_clicked), fd); + G_CALLBACK (cb_stop_clicked), fd); /* feedback widget */ fui->fb_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (fui->feedback)); - gtk_text_buffer_set_text (fui->fb_buffer, - "Hello, and welcome to the GStreamer filter demo app !\n"\ + gtk_text_buffer_set_text (fui->fb_buffer, + "Hello, and welcome to the GStreamer filter demo app !\n" "I'll be your feedback window for today.\n", -1); - + /* selection widget */ vbox = gtk_vbox_new (FALSE, 0); widget = gtk_label_new ("Input Pipe"); @@ -476,8 +465,8 @@ create_ui (_filter_ui_t *fui, _filter_data_t *fd) gtk_entry_set_text (GTK_ENTRY (fui->input), "sinesrc"); gtk_container_add (GTK_CONTAINER (vbox), fui->input); gtk_container_add (GTK_CONTAINER (fui->selection), vbox); - g_signal_connect (G_OBJECT (fui->input), "activate", - G_CALLBACK (cb_entry_activate), NULL); + g_signal_connect (G_OBJECT (fui->input), "activate", + G_CALLBACK (cb_entry_activate), NULL); vbox = gtk_vbox_new (FALSE, 0); widget = gtk_label_new ("Filter"); @@ -491,18 +480,18 @@ create_ui (_filter_ui_t *fui, _filter_data_t *fd) widget = gtk_label_new ("Output Pipe"); gtk_container_add (GTK_CONTAINER (vbox), widget); fui->output = gtk_entry_new (); - gtk_entry_set_text (GTK_ENTRY (fui->output), "osssink fragment=1572872"); /* fixme: gconf default ? */ + gtk_entry_set_text (GTK_ENTRY (fui->output), "osssink fragment=1572872"); /* fixme: gconf default ? */ gtk_container_add (GTK_CONTAINER (vbox), fui->output); gtk_container_add (GTK_CONTAINER (fui->selection), vbox); - g_signal_connect (G_OBJECT (fui->output), "activate", - G_CALLBACK (cb_entry_activate), NULL); + g_signal_connect (G_OBJECT (fui->output), "activate", + G_CALLBACK (cb_entry_activate), NULL); /* control widget is dynamically generated */ /* - g_print ("DEBUG: labeling control area.\n"); - widget = gtk_label_new ("This is the big control area."); - gtk_container_add (GTK_CONTAINER (fui->control), widget); - */ + g_print ("DEBUG: labeling control area.\n"); + widget = gtk_label_new ("This is the big control area."); + gtk_container_add (GTK_CONTAINER (fui->control), widget); + */ } @@ -511,8 +500,8 @@ main (int argc, char *argv[]) { _filter_data_t filter_data; _filter_ui_t filter_ui; - - + + gtk_init (&argc, &argv); gst_init (&argc, &argv); gst_control_init (&argc, &argv); @@ -524,7 +513,6 @@ main (int argc, char *argv[]) gtk_widget_show_all (filter_ui.window); gtk_main (); - + return 0; } - -- cgit v1.2.1