gst-indent

Original commit message from CVS:
gst-indent
parent 1e83b097
2004-03-14 Thomas Vander Stichele <thomas at apestaart dot org>
* *.c, *.h: run gst-indent
2004-03-14 Benjamin Otte <otte@gnome.org>
* gst/modplug/gstmodplug.cc:
......
......@@ -6,7 +6,7 @@
* connection would use the I420 format (assuming Xv is enabled) */
static void
new_pad_func (GstElement *element, GstPad *newpad, gpointer data)
new_pad_func (GstElement * element, GstPad * newpad, gpointer data)
{
GstElement *pipeline = (GstElement *) data;
GstElement *queue = gst_bin_get_by_name (GST_BIN (pipeline), "queue");
......@@ -19,7 +19,7 @@ new_pad_func (GstElement *element, GstPad *newpad, gpointer data)
}
gint
main (gint argc, gchar *argv[])
main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *filesrc;
......@@ -44,7 +44,8 @@ main (gint argc, gchar *argv[])
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
demux = gst_element_factory_make ("mpegdemux", "demux");
g_return_val_if_fail (demux, -1);
g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func), pipeline);
g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func),
pipeline);
thread = gst_thread_new ("thread");
queue = gst_element_factory_make ("queue", "queue");
......@@ -70,10 +71,8 @@ main (gint argc, gchar *argv[])
gst_element_link (mpeg2dec, "src", colorspace, "sink");
/* force RGB data passing between colorspace and xvideosink */
res = gst_element_link_filtered (colorspace, "src", xvideosink, "sink",
GST_CAPS_NEW (
"filtercaps",
"video/raw",
"format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB "))
GST_CAPS_NEW ("filtercaps",
"video/raw", "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB "))
));
if (!res) {
g_print ("could not connect colorspace and xvideosink\n");
......
This diff is collapsed.
......@@ -23,7 +23,7 @@ static GMainLoop *loop = NULL;
static gint64 length = 0;
static void
print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
{
gint i, count;
......@@ -35,8 +35,8 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
if (gst_tag_get_type (tag) == G_TYPE_STRING) {
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
} else {
str = g_strdup_value_contents (
gst_tag_list_get_value_index (list, tag, i));
str =
g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
}
if (i == 0) {
......@@ -50,46 +50,46 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
}
static void
got_found_tag (GstPlay *play,GstElement *source, GstTagList *tag_list)
got_found_tag (GstPlay * play, GstElement * source, GstTagList * tag_list)
{
gst_tag_list_foreach (tag_list, print_tag, NULL);
}
static void
got_time_tick (GstPlay *play, gint64 time_nanos)
got_time_tick (GstPlay * play, gint64 time_nanos)
{
g_print ("time tick %f\n", time_nanos / (float) GST_SECOND);
}
static void
got_stream_length (GstPlay *play, gint64 length_nanos)
got_stream_length (GstPlay * play, gint64 length_nanos)
{
g_print ("got length %llu\n", length_nanos);
length = length_nanos;
}
static void
got_video_size (GstPlay *play, gint width, gint height)
got_video_size (GstPlay * play, gint width, gint height)
{
g_print ("got video size %d, %d\n", width, height);
}
static void
got_eos (GstPlay *play)
got_eos (GstPlay * play)
{
g_print ("End Of Stream\n");
g_main_loop_quit (loop);
}
static gboolean
seek_timer (GstPlay *play)
seek_timer (GstPlay * play)
{
gst_play_seek_to_time (play, length / 2);
return FALSE;
}
static gboolean
idle_iterate (GstPlay *play)
idle_iterate (GstPlay * play)
{
gst_bin_iterate (GST_BIN (play));
return (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING);
......@@ -114,8 +114,7 @@ main (int argc, char *argv[])
/* Creating the GstPlay object */
play = gst_play_new (&error);
if (error)
{
if (error) {
g_print ("Error: could not create play object:\n%s\n", error->message);
g_error_free (error);
return 1;
......@@ -149,8 +148,7 @@ main (int argc, char *argv[])
G_CALLBACK (got_found_tag), NULL);
g_signal_connect (G_OBJECT (play), "error",
G_CALLBACK (gst_element_default_error), NULL);
g_signal_connect (G_OBJECT (play), "eos",
G_CALLBACK (got_eos), NULL);
g_signal_connect (G_OBJECT (play), "eos", G_CALLBACK (got_eos), NULL);
/* Change state to PLAYING */
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);
......
......@@ -24,7 +24,7 @@ static gboolean verbose = FALSE;
static gboolean quiet = FALSE;
static void
entry_added (GstIndex *index, GstIndexEntry *entry)
entry_added (GstIndex * index, GstIndexEntry * entry)
{
switch (entry->type) {
case GST_INDEX_ENTRY_ID:
......@@ -33,14 +33,14 @@ entry_added (GstIndex *index, GstIndexEntry *entry)
break;
case GST_INDEX_ENTRY_FORMAT:
g_print ("%d: registered format %d for %s\n", entry->id,
GST_INDEX_FORMAT_FORMAT (entry),
GST_INDEX_FORMAT_KEY (entry));
GST_INDEX_FORMAT_FORMAT (entry), GST_INDEX_FORMAT_KEY (entry));
break;
case GST_INDEX_ENTRY_ASSOCIATION:
{
gint i;
g_print ("%p, %d: %08x ", entry, entry->id, GST_INDEX_ASSOC_FLAGS (entry));
g_print ("%p, %d: %08x ", entry, entry->id,
GST_INDEX_ASSOC_FLAGS (entry));
for (i = 0; i < GST_INDEX_NASSOCS (entry); i++) {
g_print ("%d %lld ", GST_INDEX_ASSOC_FORMAT (entry, i),
GST_INDEX_ASSOC_VALUE (entry, i));
......@@ -63,7 +63,7 @@ typedef struct
} dyn_link;
static void
dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data)
dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data)
{
dyn_link *link = (dyn_link *) data;
......@@ -77,12 +77,9 @@ dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data)
}
static void
setup_dynamic_linking (GstElement *pipeline,
GstElement *element,
const gchar *padname,
GstPad *target,
GstElement *bin,
GstIndex *index)
setup_dynamic_linking (GstElement * pipeline,
GstElement * element,
const gchar * padname, GstPad * target, GstElement * bin, GstIndex * index)
{
dyn_link *link;
......@@ -93,11 +90,12 @@ setup_dynamic_linking (GstElement *pipeline,
link->pipeline = pipeline;
link->index = index;
g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), link);
g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link),
link);
}
static GstElement*
make_mpeg_systems_pipeline (const gchar *path, GstIndex *index)
static GstElement *
make_mpeg_systems_pipeline (const gchar * path, GstIndex * index)
{
GstElement *pipeline;
GstElement *src, *demux;
......@@ -121,8 +119,8 @@ make_mpeg_systems_pipeline (const gchar *path, GstIndex *index)
return pipeline;
}
static GstElement*
make_mpeg_decoder_pipeline (const gchar *path, GstIndex *index)
static GstElement *
make_mpeg_decoder_pipeline (const gchar * path, GstIndex * index)
{
GstElement *pipeline;
GstElement *src, *demux;
......@@ -147,15 +145,13 @@ make_mpeg_decoder_pipeline (const gchar *path, GstIndex *index)
gst_bin_add (GST_BIN (video_bin), video_decoder);
setup_dynamic_linking (pipeline, demux, "video_00",
gst_element_get_pad (video_decoder, "sink"),
video_bin, index);
gst_element_get_pad (video_decoder, "sink"), video_bin, index);
audio_bin = gst_bin_new ("audio_bin");
audio_decoder = gst_element_factory_make ("mad", "audio_decoder");
setup_dynamic_linking (pipeline, demux, "audio_00",
gst_element_get_pad (audio_decoder, "sink"),
audio_bin, index);
gst_element_get_pad (audio_decoder, "sink"), audio_bin, index);
gst_bin_add (GST_BIN (audio_bin), audio_decoder);
......@@ -167,7 +163,7 @@ make_mpeg_decoder_pipeline (const gchar *path, GstIndex *index)
}
static void
print_progress (GstPad *pad)
print_progress (GstPad * pad)
{
gint i = 0;
gchar status[53];
......@@ -185,10 +181,10 @@ print_progress (GstPad *pad)
}
for (i = 0; i < percent; i++) {
status[i+1] = '=';
status[i + 1] = '=';
}
for (i = percent; i < 50; i++) {
status[i+1] = ' ';
status[i + 1] = ' ';
}
status[51] = '|';
status[52] = 0;
......@@ -197,7 +193,7 @@ print_progress (GstPad *pad)
}
gint
main (gint argc, gchar *argv[])
main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *src;
......@@ -208,9 +204,9 @@ main (gint argc, gchar *argv[])
gboolean res;
GstElement *sink;
struct poptOption options[] = {
{ "verbose", 'v', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &verbose, 0,
{"verbose", 'v', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &verbose, 0,
"Print index entries", NULL},
{ "quiet", 'q', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &quiet, 0,
{"quiet", 'q', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &quiet, 0,
"don't print progress bar", NULL},
POPT_TABLEEND
};
......@@ -220,7 +216,7 @@ main (gint argc, gchar *argv[])
" type can be: 0 mpeg_systems\n"
" 1 mpeg_decoder\n"
" -v : report added index entries\n"
" -q : don't print progress\n" , argv[0]);
" -q : don't print progress\n", argv[0]);
return -1;
}
......@@ -228,7 +224,8 @@ main (gint argc, gchar *argv[])
index = gst_index_factory_make ("memindex");
if (index) {
if (verbose)
g_signal_connect (G_OBJECT (index), "entry_added", G_CALLBACK (entry_added), NULL);
g_signal_connect (G_OBJECT (index), "entry_added",
G_CALLBACK (entry_added), NULL);
g_object_set (G_OBJECT (index), "resolver", 1, NULL);
}
......@@ -259,7 +256,7 @@ main (gint argc, gchar *argv[])
/* prepare for iteration */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("indexing %s...\n", argv [2]);
g_print ("indexing %s...\n", argv[2]);
/* run through the complete stream to let it generate an index */
while (gst_bin_iterate (GST_BIN (pipeline))) {
if (!quiet && (count % 1000 == 0)) {
......@@ -299,10 +296,9 @@ main (gint argc, gchar *argv[])
gst_element_link_pads (src, "src", sink, "sink");
gst_bin_add (GST_BIN (pipeline), sink);
g_print ("seeking %s...\n", argv [2]);
g_print ("seeking %s...\n", argv[2]);
event = gst_event_new_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, 5 * GST_SECOND);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 5 * GST_SECOND);
res = gst_pad_send_event (pad, event);
if (!res) {
......@@ -322,4 +318,3 @@ main (gint argc, gchar *argv[])
return 1;
}
......@@ -3,7 +3,7 @@
#include <string.h>
static void
get_position_info (GstElement *cdparanoia)
get_position_info (GstElement * cdparanoia)
{
GstFormat track_format;
const GstFormat *formats;
......@@ -24,14 +24,13 @@ get_position_info (GstElement *cdparanoia)
definition = gst_format_get_details (*formats);
format = *formats;
res = gst_pad_query (pad, GST_QUERY_POSITION,
&format, &position);
res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &position);
if (format == GST_FORMAT_TIME) {
position /= GST_SECOND;
g_print ("%s: %lld:%02lld", definition->nick, position/60, position%60);
}
else {
g_print ("%s: %lld:%02lld", definition->nick, position / 60,
position % 60);
} else {
g_print ("%s: %lld", definition->nick, position);
}
......@@ -44,7 +43,7 @@ get_position_info (GstElement *cdparanoia)
}
static void
get_track_info (GstElement *cdparanoia)
get_track_info (GstElement * cdparanoia)
{
GstFormat track_format;
gint64 total_tracks = 0, total_time = 0;
......@@ -70,22 +69,20 @@ get_track_info (GstElement *cdparanoia)
definition = gst_format_get_details (*formats);
format = *formats;
res = gst_pad_query (pad, GST_QUERY_TOTAL,
&format, &total);
res = gst_pad_query (pad, GST_QUERY_TOTAL, &format, &total);
if (res) {
if (format == GST_FORMAT_TIME) {
total /= GST_SECOND;
g_print ("%s total: %lld:%02lld\n", definition->nick, total/60, total%60);
}
else
g_print ("%s total: %lld:%02lld\n", definition->nick, total / 60,
total % 60);
} else
g_print ("%s total: %lld\n", definition->nick, total);
if (format == track_format)
total_tracks = total;
else if (format == GST_FORMAT_TIME)
total_time = total;
}
else
} else
g_print ("failed to get %s total\n", definition->nick);
formats++;
......@@ -102,11 +99,9 @@ get_track_info (GstElement *cdparanoia)
GstFormat format;
format = GST_FORMAT_TIME;
res = gst_pad_convert (pad, track_format, i,
&format, &time);
res = gst_pad_convert (pad, track_format, i, &format, &time);
time /= GST_SECOND;
}
else {
} else {
time = total_time;
res = TRUE;
}
......@@ -118,13 +113,11 @@ get_track_info (GstElement *cdparanoia)
gint64 length = time - time_count;
g_print ("track %d: %lld:%02lld -> %lld:%02lld, length: %lld:%02lld\n",
i-1,
i - 1,
time_count / 60, time_count % 60,
time / 60, time % 60,
length / 60, length % 60);
}
time / 60, time % 60, length / 60, length % 60);
}
else {
} else {
g_print ("could not get time for track %d\n", i);
}
......@@ -177,9 +170,7 @@ main (int argc, char **argv)
g_print ("playing from track 3\n");
/* seek to track3 */
event = gst_event_new_seek (track_format |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH,
3);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 3);
res = gst_pad_send_event (pad, event);
if (!res)
......@@ -199,8 +190,7 @@ main (int argc, char **argv)
/* seek to some seconds */
event = gst_event_new_segment_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH,
25 * GST_SECOND, 29 * GST_SECOND);
GST_SEEK_FLAG_FLUSH, 25 * GST_SECOND, 29 * GST_SECOND);
res = gst_pad_send_event (pad, event);
if (!res)
g_warning ("seek failed");
......
......@@ -15,7 +15,7 @@ static guint update_id;
#define UPDATE_INTERVAL 500
static GstElement*
static GstElement *
make_cdaudio_pipeline (void)
{
GstElement *cdaudio;
......@@ -28,9 +28,8 @@ make_cdaudio_pipeline (void)
return cdaudio;
}
static gchar*
format_value (GtkScale *scale,
gdouble value)
static gchar *
format_value (GtkScale * scale, gdouble value)
{
gint64 real;
gint64 seconds;
......@@ -41,9 +40,7 @@ format_value (GtkScale *scale,
subseconds = (gint64) real / (GST_SECOND / 100);
return g_strdup_printf ("%02lld:%02lld:%02lld",
seconds/60,
seconds%60,
subseconds%100);
seconds / 60, seconds % 60, subseconds % 100);
}
typedef struct
......@@ -52,13 +49,12 @@ typedef struct
const GstFormat format;
} seek_format;
static seek_format seek_formats[] =
{
{ "tim", GST_FORMAT_TIME },
{ "byt", GST_FORMAT_BYTES },
{ "buf", GST_FORMAT_BUFFERS },
{ "def", GST_FORMAT_DEFAULT },
{ NULL, 0 },
static seek_format seek_formats[] = {
{"tim", GST_FORMAT_TIME},
{"byt", GST_FORMAT_BYTES},
{"buf", GST_FORMAT_BUFFERS},
{"def", GST_FORMAT_DEFAULT},
{NULL, 0},
};
......@@ -81,8 +77,7 @@ query_durations ()
res = gst_element_query (element, GST_QUERY_TOTAL, &format, &value);
if (res) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
......@@ -111,8 +106,7 @@ query_positions ()
res = gst_element_query (element, GST_QUERY_POSITION, &format, &value);
if (res) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
......@@ -134,6 +128,7 @@ update_scale (gpointer data)
if (seekable_elements) {
GstElement *element = GST_ELEMENT (seekable_elements->data);
gst_element_query (element, GST_QUERY_TOTAL, &format, &duration);
}
if (clock)
......@@ -141,7 +136,8 @@ update_scale (gpointer data)
if (stats) {
if (clock)
g_print ("clock: %13llu (%s)\n", position, gst_object_get_name (GST_OBJECT (clock)));
g_print ("clock: %13llu (%s)\n", position,
gst_object_get_name (GST_OBJECT (clock)));
query_durations ();
query_positions ();
}
......@@ -167,7 +163,7 @@ iterate (gpointer data)
}
static gboolean
start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
start_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gtk_timeout_remove (update_id);
......@@ -176,7 +172,7 @@ start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
}
static gboolean
stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
gint64 real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100;
gboolean res;
......@@ -188,8 +184,7 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
g_print ("seek to %lld on element %s\n", real, GST_ELEMENT_NAME (seekable));
s_event = gst_event_new_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, real);
res = gst_element_send_event (seekable, s_event);
......@@ -199,7 +194,8 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE))
gtk_idle_add ((GtkFunction) iterate, pipeline);
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
return FALSE;
}
......@@ -211,7 +207,8 @@ play_cb (GtkButton * button, gpointer data)
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE))
gtk_idle_add ((GtkFunction) iterate, pipeline);
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
}
}
......@@ -237,10 +234,9 @@ int
main (int argc, char **argv)
{
GtkWidget *window, *hbox, *vbox,
*play_button, *pause_button, *stop_button,
*hscale;
*play_button, *pause_button, *stop_button, *hscale;
struct poptOption options[] = {
{"stats", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &stats, 0,
{"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0,
"Show element stats", NULL},
POPT_TABLEEND
};
......@@ -250,8 +246,10 @@ main (int argc, char **argv)
pipeline = make_cdaudio_pipeline ();
g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL);
g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL);
g_signal_connect (pipeline, "deep_notify",
G_CALLBACK (gst_element_default_deep_notify), NULL);
g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error),
NULL);
/* initialize gui elements ... */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
......@@ -261,16 +259,17 @@ main (int argc, char **argv)
pause_button = gtk_button_new_with_label ("pause");
stop_button = gtk_button_new_with_label ("stop");
adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
adjustment =
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
hscale = gtk_hscale_new (adjustment);
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
gtk_signal_connect(GTK_OBJECT(hscale),
gtk_signal_connect (GTK_OBJECT (hscale),
"button_press_event", G_CALLBACK (start_seek), pipeline);
gtk_signal_connect(GTK_OBJECT(hscale),
gtk_signal_connect (GTK_OBJECT (hscale),
"button_release_event", G_CALLBACK (stop_seek), pipeline);
gtk_signal_connect(GTK_OBJECT(hscale),
gtk_signal_connect (GTK_OBJECT (hscale),
"format_value", G_CALLBACK (format_value), pipeline);
/* do the packing stuff ... */
......@@ -283,9 +282,12 @@ main (int argc, char **argv)
gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
/* connect things ... */
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), pipeline);
g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), pipeline);
g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), pipeline);
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb),