diff options
author | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
---|---|---|
committer | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
commit | 7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2 (patch) | |
tree | f863b467dea9559a6ec9c48affbfae11f8104164 /ext/smoothwave | |
parent | a19db4bbdc4a15ea0d8f4d28e9a1302c9c3d1657 (diff) |
gst-indent
Original commit message from CVS:
gst-indent
Diffstat (limited to 'ext/smoothwave')
-rw-r--r-- | ext/smoothwave/demo-osssrc.c | 57 | ||||
-rw-r--r-- | ext/smoothwave/gstsmoothwave.c | 202 | ||||
-rw-r--r-- | ext/smoothwave/gstsmoothwave.h | 39 |
3 files changed, 150 insertions, 148 deletions
diff --git a/ext/smoothwave/demo-osssrc.c b/ext/smoothwave/demo-osssrc.c index 457900d7c..c39bc72c7 100644 --- a/ext/smoothwave/demo-osssrc.c +++ b/ext/smoothwave/demo-osssrc.c @@ -3,11 +3,13 @@ extern gboolean _gst_plugin_spew; -gboolean idle_func(gpointer data); +gboolean idle_func (gpointer data); GtkWidget *drawingarea; -int main(int argc,char *argv[]) { +int +main (int argc, char *argv[]) +{ GstElement *bin; GstElementFactory *srcfactory; GstElement *src; @@ -16,46 +18,47 @@ int main(int argc,char *argv[]) { GtkWidget *wave_widget; GtkWidget *appwindow; - gst_init(&argc,&argv); - gst_plugin_load("libsmoothwave.so"); - gtk_init(&argc,&argv); + gst_init (&argc, &argv); + gst_plugin_load ("libsmoothwave.so"); + gtk_init (&argc, &argv); - bin = gst_pipeline_new("bin"); + bin = gst_pipeline_new ("bin"); - srcfactory = gst_element_factory_find("sinesrc"); - g_return_val_if_fail(srcfactory != NULL, -1); - wavefactory = gst_element_factory_find("smoothwave"); - g_return_val_if_fail(wavefactory != NULL, -1); + srcfactory = gst_element_factory_find ("sinesrc"); + g_return_val_if_fail (srcfactory != NULL, -1); + wavefactory = gst_element_factory_find ("smoothwave"); + g_return_val_if_fail (wavefactory != NULL, -1); - src = gst_element_factory_create(srcfactory,"src"); + src = gst_element_factory_create (srcfactory, "src"); //g_object_set(G_OBJECT(src),"bytes_per_read",(gulong)2048,NULL); - wave = gst_element_factory_create(wavefactory,"wave"); - g_object_set(G_OBJECT(wave),"width",256,"height",100,NULL); + wave = gst_element_factory_create (wavefactory, "wave"); + g_object_set (G_OBJECT (wave), "width", 256, "height", 100, NULL); - gst_bin_add(GST_BIN(bin),GST_ELEMENT(src)); - gst_bin_add(GST_BIN(bin),GST_ELEMENT(wave)); + gst_bin_add (GST_BIN (bin), GST_ELEMENT (src)); + gst_bin_add (GST_BIN (bin), GST_ELEMENT (wave)); - gst_pad_link(gst_element_get_pad(src,"src"), - gst_element_get_pad(wave,"sink")); + gst_pad_link (gst_element_get_pad (src, "src"), + gst_element_get_pad (wave, "sink")); - appwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); - g_object_get(G_OBJECT(wave),"widget",&wave_widget,NULL); - gtk_container_add(GTK_CONTAINER(appwindow), wave_widget); - gtk_widget_show_all(appwindow); + appwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); + g_object_get (G_OBJECT (wave), "widget", &wave_widget, NULL); + gtk_container_add (GTK_CONTAINER (appwindow), wave_widget); + gtk_widget_show_all (appwindow); - gst_element_set_state(GST_ELEMENT(bin),GST_STATE_READY); - gst_element_set_state(GST_ELEMENT(bin),GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); - g_idle_add(idle_func,bin); + g_idle_add (idle_func, bin); - gtk_main(); + gtk_main (); return 0; } -gboolean idle_func(gpointer data) +gboolean +idle_func (gpointer data) { - gst_bin_iterate(GST_BIN(data)); + gst_bin_iterate (GST_BIN (data)); return TRUE; } diff --git a/ext/smoothwave/gstsmoothwave.c b/ext/smoothwave/gstsmoothwave.c index 57c267e51..2abbdec2f 100644 --- a/ext/smoothwave/gstsmoothwave.c +++ b/ext/smoothwave/gstsmoothwave.c @@ -25,37 +25,41 @@ #include "gstsmoothwave.h" -static GstElementDetails gst_smoothwave_details = GST_ELEMENT_DETAILS ( - "Smooth waveform", - "Visualization", - "Fading grayscale waveform display", - "Erik Walthinsen <omega@cse.ogi.edu>" -); +static GstElementDetails gst_smoothwave_details = +GST_ELEMENT_DETAILS ("Smooth waveform", + "Visualization", + "Fading grayscale waveform display", + "Erik Walthinsen <omega@cse.ogi.edu>"); /* SmoothWave signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_WIDTH, ARG_HEIGHT, ARG_WIDGET, }; -static void gst_smoothwave_base_init (gpointer g_class); -static void gst_smoothwave_class_init (GstSmoothWaveClass *klass); -static void gst_smoothwave_init (GstSmoothWave *smoothwave); +static void gst_smoothwave_base_init (gpointer g_class); +static void gst_smoothwave_class_init (GstSmoothWaveClass * klass); +static void gst_smoothwave_init (GstSmoothWave * smoothwave); -static void gst_smoothwave_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_smoothwave_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gst_smoothwave_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_smoothwave_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_smoothwave_chain (GstPad *pad, GstData *_data); +static void gst_smoothwave_chain (GstPad * pad, GstData * _data); static GstElementClass *parent_class = NULL; + /*static guint gst_smoothwave_signals[LAST_SIGNAL] = { 0 }; */ @@ -66,17 +70,19 @@ gst_smoothwave_get_type (void) if (!smoothwave_type) { static const GTypeInfo smoothwave_info = { - sizeof(GstSmoothWaveClass), + sizeof (GstSmoothWaveClass), gst_smoothwave_base_init, NULL, - (GClassInitFunc)gst_smoothwave_class_init, + (GClassInitFunc) gst_smoothwave_class_init, NULL, NULL, - sizeof(GstSmoothWave), + sizeof (GstSmoothWave), 0, - (GInstanceInitFunc)gst_smoothwave_init, + (GInstanceInitFunc) gst_smoothwave_init, }; - smoothwave_type = g_type_register_static(GST_TYPE_ELEMENT, "GstSmoothWave", &smoothwave_info, 0); + smoothwave_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstSmoothWave", + &smoothwave_info, 0); } return smoothwave_type; } @@ -90,83 +96,77 @@ gst_smoothwave_base_init (gpointer g_class) } static void -gst_smoothwave_class_init (GstSmoothWaveClass *klass) +gst_smoothwave_class_init (GstSmoothWaveClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_ELEMENT); + parent_class = g_type_class_ref (GST_TYPE_ELEMENT); - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_WIDTH, - g_param_spec_int("width","width","width", - G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */ - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_HEIGHT, - g_param_spec_int("height","height","height", - G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */ - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_WIDGET, - g_param_spec_object("widget","widget","widget", - GTK_TYPE_WIDGET,G_PARAM_READABLE)); /* CHECKME! */ + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDTH, g_param_spec_int ("width", "width", "width", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HEIGHT, g_param_spec_int ("height", "height", "height", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDGET, g_param_spec_object ("widget", "widget", "widget", GTK_TYPE_WIDGET, G_PARAM_READABLE)); /* CHECKME! */ gobject_class->set_property = gst_smoothwave_set_property; gobject_class->get_property = gst_smoothwave_get_property; } static void -gst_smoothwave_init (GstSmoothWave *smoothwave) +gst_smoothwave_init (GstSmoothWave * smoothwave) { int i; guint32 palette[256]; - smoothwave->sinkpad = gst_pad_new("sink",GST_PAD_SINK); - gst_element_add_pad(GST_ELEMENT(smoothwave),smoothwave->sinkpad); - gst_pad_set_chain_function(smoothwave->sinkpad,gst_smoothwave_chain); - smoothwave->srcpad = gst_pad_new("src",GST_PAD_SRC); - gst_element_add_pad(GST_ELEMENT(smoothwave),smoothwave->srcpad); + smoothwave->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); + gst_element_add_pad (GST_ELEMENT (smoothwave), smoothwave->sinkpad); + gst_pad_set_chain_function (smoothwave->sinkpad, gst_smoothwave_chain); + smoothwave->srcpad = gst_pad_new ("src", GST_PAD_SRC); + gst_element_add_pad (GST_ELEMENT (smoothwave), smoothwave->srcpad); /* smoothwave->meta = NULL; */ smoothwave->width = 512; smoothwave->height = 256; - gdk_rgb_init(); + gdk_rgb_init (); /* gtk_widget_set_default_colormap (gdk_rgb_get_cmap()); */ /* gtk_widget_set_default_visual (gdk_rgb_get_visual()); */ /* GST_DEBUG ("creating palette"); */ - for (i=0;i<256;i++) + for (i = 0; i < 256; i++) palette[i] = (i << 16) || (i << 8); /* GST_DEBUG ("creating cmap"); */ - smoothwave->cmap = gdk_rgb_cmap_new(palette,256); + smoothwave->cmap = gdk_rgb_cmap_new (palette, 256); /* GST_DEBUG ("created cmap"); */ /* gtk_widget_set_default_colormap (smoothwave->cmap); */ - smoothwave->image = gtk_drawing_area_new(); - gtk_drawing_area_size(GTK_DRAWING_AREA(smoothwave->image), - smoothwave->width,smoothwave->height); - gtk_widget_show(smoothwave->image); + smoothwave->image = gtk_drawing_area_new (); + gtk_drawing_area_size (GTK_DRAWING_AREA (smoothwave->image), + smoothwave->width, smoothwave->height); + gtk_widget_show (smoothwave->image); - smoothwave->imagebuffer = g_malloc(smoothwave->width*smoothwave->height); - memset(smoothwave->imagebuffer,0,smoothwave->width*smoothwave->height); + smoothwave->imagebuffer = g_malloc (smoothwave->width * smoothwave->height); + memset (smoothwave->imagebuffer, 0, smoothwave->width * smoothwave->height); } static void -gst_smoothwave_chain (GstPad *pad, GstData *_data) +gst_smoothwave_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstSmoothWave *smoothwave; gint16 *samples; - gint samplecount,i; + gint samplecount, i; register guint32 *ptr; gint qheight; - g_return_if_fail(pad != NULL); - g_return_if_fail(GST_IS_PAD(pad)); - g_return_if_fail(buf != NULL); + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); + g_return_if_fail (buf != NULL); /* g_return_if_fail(GST_IS_BUFFER(buf)); */ - smoothwave = GST_SMOOTHWAVE(GST_OBJECT_PARENT (pad)); + smoothwave = GST_SMOOTHWAVE (GST_OBJECT_PARENT (pad)); /* first deal with audio metadata */ #if 0 @@ -175,36 +175,35 @@ gst_smoothwave_chain (GstPad *pad, GstData *_data) /* FIXME: need to unref the old metadata so it goes away */ } /* we just make a copy of the pointer */ - smoothwave->meta = (MetaAudioRaw *)(buf->meta); + smoothwave->meta = (MetaAudioRaw *) (buf->meta); /* FIXME: now we have to ref the metadata so it doesn't go away */ } #endif /* g_return_if_fail(smoothwave->meta != NULL); */ - samples = (gint16 *)GST_BUFFER_DATA(buf); + samples = (gint16 *) GST_BUFFER_DATA (buf); /* samplecount = buf->datasize / (smoothwave->meta->channels * sizeof(gint16)); */ - samplecount = GST_BUFFER_SIZE(buf) / (2 * sizeof(gint16)); + samplecount = GST_BUFFER_SIZE (buf) / (2 * sizeof (gint16)); - qheight = smoothwave->height/4; + qheight = smoothwave->height / 4; /* GST_DEBUG ("traversing %d",smoothwave->width); */ - for (i=0;i<MAX(smoothwave->width,samplecount);i++) { - gint16 y1 = (gint32)(samples[i*2] * qheight) / 32768 + - qheight; - gint16 y2 = (gint32)(samples[(i*2)+1] * qheight) / 32768 + - (qheight*3); - smoothwave->imagebuffer[y1*smoothwave->width + i] = 0xff; - smoothwave->imagebuffer[y2*smoothwave->width + i] = 0xff; + for (i = 0; i < MAX (smoothwave->width, samplecount); i++) { + gint16 y1 = (gint32) (samples[i * 2] * qheight) / 32768 + qheight; + gint16 y2 = (gint32) (samples[(i * 2) + 1] * qheight) / 32768 + + (qheight * 3); + smoothwave->imagebuffer[y1 * smoothwave->width + i] = 0xff; + smoothwave->imagebuffer[y2 * smoothwave->width + i] = 0xff; /* smoothwave->imagebuffer[i+(smoothwave->width*5)] = i; */ } - ptr = (guint32 *)smoothwave->imagebuffer; - for (i=0;i<(smoothwave->width*smoothwave->height)/4;i++) { - if (*ptr){ + ptr = (guint32 *) smoothwave->imagebuffer; + for (i = 0; i < (smoothwave->width * smoothwave->height) / 4; i++) { + if (*ptr) { *ptr -= ((*ptr & 0xf0f0f0f0ul) >> 4) + ((*ptr & 0xe0e0e0e0ul) >> 5); ptr++; - }else{ + } else { ptr++; } } @@ -223,40 +222,40 @@ gst_smoothwave_chain (GstPad *pad, GstData *_data) GDK_RGB_DITHER_NONE, smoothwave->imagebuffer,smoothwave->width, smoothwave->cmap);*/ - gdk_draw_gray_image(smoothwave->image->window, - smoothwave->image->style->fg_gc[GTK_STATE_NORMAL], - 0,0,smoothwave->width,smoothwave->height, - GDK_RGB_DITHER_NORMAL, - smoothwave->imagebuffer,smoothwave->width); + gdk_draw_gray_image (smoothwave->image->window, + smoothwave->image->style->fg_gc[GTK_STATE_NORMAL], + 0, 0, smoothwave->width, smoothwave->height, + GDK_RGB_DITHER_NORMAL, smoothwave->imagebuffer, smoothwave->width); /* gst_trace_add_entry(NULL,0,buf,"smoothwave: calculated smoothwave"); */ - gst_buffer_unref(buf); + gst_buffer_unref (buf); } static void -gst_smoothwave_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_smoothwave_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstSmoothWave *smoothwave; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_SMOOTHWAVE(object)); - smoothwave = GST_SMOOTHWAVE(object); + g_return_if_fail (GST_IS_SMOOTHWAVE (object)); + smoothwave = GST_SMOOTHWAVE (object); switch (prop_id) { case ARG_WIDTH: smoothwave->width = g_value_get_int (value); - gtk_drawing_area_size(GTK_DRAWING_AREA(smoothwave->image), - smoothwave->width,smoothwave->height); - gtk_widget_set_usize(GTK_WIDGET(smoothwave->image), - smoothwave->width,smoothwave->height); + gtk_drawing_area_size (GTK_DRAWING_AREA (smoothwave->image), + smoothwave->width, smoothwave->height); + gtk_widget_set_usize (GTK_WIDGET (smoothwave->image), + smoothwave->width, smoothwave->height); break; case ARG_HEIGHT: smoothwave->height = g_value_get_int (value); - gtk_drawing_area_size(GTK_DRAWING_AREA(smoothwave->image), - smoothwave->width,smoothwave->height); - gtk_widget_set_usize(GTK_WIDGET(smoothwave->image), - smoothwave->width,smoothwave->height); + gtk_drawing_area_size (GTK_DRAWING_AREA (smoothwave->image), + smoothwave->width, smoothwave->height); + gtk_widget_set_usize (GTK_WIDGET (smoothwave->image), + smoothwave->width, smoothwave->height); break; default: break; @@ -264,27 +263,28 @@ gst_smoothwave_set_property (GObject *object, guint prop_id, const GValue *value } static void -gst_smoothwave_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_smoothwave_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstSmoothWave *smoothwave; /* it's not null if we got it, but it might not be ours */ - smoothwave = GST_SMOOTHWAVE(object); + smoothwave = GST_SMOOTHWAVE (object); switch (prop_id) { - case ARG_WIDTH: { + case ARG_WIDTH:{ g_value_set_int (value, smoothwave->width); break; } - case ARG_HEIGHT: { + case ARG_HEIGHT:{ g_value_set_int (value, smoothwave->height); break; } - case ARG_WIDGET: { + case ARG_WIDGET:{ g_value_set_object (value, smoothwave->image); break; } - default: { + default:{ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } @@ -294,21 +294,17 @@ gst_smoothwave_get_property (GObject *object, guint prop_id, GValue *value, GPar static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { - if (!gst_element_register (plugin, "smoothwave", GST_RANK_NONE, GST_TYPE_SMOOTHWAVE)) + if (!gst_element_register (plugin, "smoothwave", GST_RANK_NONE, + GST_TYPE_SMOOTHWAVE)) return FALSE; return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "smoothwave", - "Fading greyscale waveform display", - plugin_init, - VERSION, - "LGPL", - GST_PACKAGE, - GST_ORIGIN) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "smoothwave", + "Fading greyscale waveform display", + plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN) diff --git a/ext/smoothwave/gstsmoothwave.h b/ext/smoothwave/gstsmoothwave.h index 871651310..df4d87634 100644 --- a/ext/smoothwave/gstsmoothwave.h +++ b/ext/smoothwave/gstsmoothwave.h @@ -26,8 +26,9 @@ #include <gtk/gtk.h> #ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +extern "C" +{ +#endif /* __cplusplus */ #define GST_TYPE_SMOOTHWAVE \ @@ -41,31 +42,33 @@ extern "C" { #define GST_IS_SMOOTHWAVE_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SMOOTHWAVE)) -typedef struct _GstSmoothWave GstSmoothWave; -typedef struct _GstSmoothWaveClass GstSmoothWaveClass; + typedef struct _GstSmoothWave GstSmoothWave; + typedef struct _GstSmoothWaveClass GstSmoothWaveClass; -struct _GstSmoothWave { - GstElement element; + struct _GstSmoothWave + { + GstElement element; - GstPad *sinkpad,*srcpad; + GstPad *sinkpad, *srcpad; - gint width,height; + gint width, height; - GdkRgbCmap *cmap; - GtkWidget *image; - guchar *imagebuffer; -}; + GdkRgbCmap *cmap; + GtkWidget *image; + guchar *imagebuffer; + }; -struct _GstSmoothWaveClass { - GstElementClass parent_class; -}; + struct _GstSmoothWaveClass + { + GstElementClass parent_class; + }; -GType gst_smoothwave_get_type(void); + GType gst_smoothwave_get_type (void); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ -#endif /* __GST_SMOOTHWAVE_H__ */ +#endif /* __GST_SMOOTHWAVE_H__ */ |