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 | 5d25c00e4b613b9cdf2c04fa3a68dffa03834a68 (patch) | |
tree | 74a5b1eaf3a324b520e64e87404fd0b3018a7829 /ext/esd | |
parent | 1e83b097f7b732ae49e294a5a398bdc3e88854a8 (diff) |
gst-indent
Original commit message from CVS:
gst-indent
Diffstat (limited to 'ext/esd')
-rw-r--r-- | ext/esd/esdmon.c | 228 | ||||
-rw-r--r-- | ext/esd/esdmon.h | 23 | ||||
-rw-r--r-- | ext/esd/esdsink.c | 240 | ||||
-rw-r--r-- | ext/esd/esdsink.h | 47 | ||||
-rw-r--r-- | ext/esd/gstesd.c | 31 |
5 files changed, 284 insertions, 285 deletions
diff --git a/ext/esd/esdmon.c b/ext/esd/esdmon.c index 25e9df81..4a7f4ca1 100644 --- a/ext/esd/esdmon.c +++ b/ext/esd/esdmon.c @@ -37,12 +37,14 @@ static GstElementDetails esdmon_details = { }; /* Signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_DEPTH, ARG_BYTESPERREAD, @@ -52,43 +54,37 @@ enum { ARG_HOST, }; -static GstStaticPadTemplate src_factory = -GST_STATIC_PAD_TEMPLATE ( - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ( - "audio/x-raw-int, " - "endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", " - "signed = (boolean) TRUE, " - "width = (int) 16, " - "depth = (int) 16, " - "rate = [ 8000, 96000 ], " - "channels = [ 1, 2 ]; " - "audio/x-raw-int, " - "signed = (boolean) FALSE, " - "width = (int) 8, " - "depth = (int) 8, " - "rate = [ 8000, 96000 ], " - "channels = [ 1, 2 ]" - ) -); - -static void gst_esdmon_base_init (gpointer g_class); -static void gst_esdmon_class_init (gpointer g_class, gpointer class_data); -static void gst_esdmon_init (GTypeInstance *instance, gpointer g_class); - -static gboolean gst_esdmon_open_audio (GstEsdmon *src); -static void gst_esdmon_close_audio (GstEsdmon *src); -static GstElementStateReturn gst_esdmon_change_state (GstElement *element); -static gboolean gst_esdmon_sync_parms (GstEsdmon *esdmon); - -static GstData * gst_esdmon_get (GstPad *pad); - -static void gst_esdmon_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_esdmon_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw-int, " + "endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", " + "signed = (boolean) TRUE, " + "width = (int) 16, " + "depth = (int) 16, " + "rate = [ 8000, 96000 ], " + "channels = [ 1, 2 ]; " + "audio/x-raw-int, " + "signed = (boolean) FALSE, " + "width = (int) 8, " + "depth = (int) 8, " "rate = [ 8000, 96000 ], " "channels = [ 1, 2 ]") + ); + +static void gst_esdmon_base_init (gpointer g_class); +static void gst_esdmon_class_init (gpointer g_class, gpointer class_data); +static void gst_esdmon_init (GTypeInstance * instance, gpointer g_class); + +static gboolean gst_esdmon_open_audio (GstEsdmon * src); +static void gst_esdmon_close_audio (GstEsdmon * src); +static GstElementStateReturn gst_esdmon_change_state (GstElement * element); +static gboolean gst_esdmon_sync_parms (GstEsdmon * esdmon); + +static GstData *gst_esdmon_get (GstPad * pad); + +static void gst_esdmon_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_esdmon_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); #define GST_TYPE_ESDMON_DEPTHS (gst_esdmon_depths_get_type()) static GType @@ -101,7 +97,8 @@ gst_esdmon_depths_get_type (void) {0, NULL, NULL}, }; if (!esdmon_depths_type) { - esdmon_depths_type = g_enum_register_static("GstEsdmonDepths", esdmon_depths); + esdmon_depths_type = + g_enum_register_static ("GstEsdmonDepths", esdmon_depths); } return esdmon_depths_type; } @@ -117,13 +114,15 @@ gst_esdmon_channels_get_type (void) {0, NULL, NULL}, }; if (!esdmon_channels_type) { - esdmon_channels_type = g_enum_register_static("GstEsdmonChannels", esdmon_channels); + esdmon_channels_type = + g_enum_register_static ("GstEsdmonChannels", esdmon_channels); } return esdmon_channels_type; } static GstElementClass *parent_class = NULL; + /*static guint gst_esdmon_signals[LAST_SIGNAL] = { 0 }; */ GType @@ -133,17 +132,18 @@ gst_esdmon_get_type (void) if (!esdmon_type) { static const GTypeInfo esdmon_info = { - sizeof(GstEsdmonClass), + sizeof (GstEsdmonClass), gst_esdmon_base_init, NULL, gst_esdmon_class_init, NULL, NULL, - sizeof(GstEsdmon), + sizeof (GstEsdmon), 0, gst_esdmon_init, }; - esdmon_type = g_type_register_static(GST_TYPE_ELEMENT, "GstEsdmon", &esdmon_info, 0); + esdmon_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstEsdmon", &esdmon_info, 0); } return esdmon_type; } @@ -153,7 +153,7 @@ gst_esdmon_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - gst_element_class_add_pad_template (element_class, + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&src_factory)); gst_element_class_set_details (element_class, &esdmon_details); } @@ -166,24 +166,12 @@ gst_esdmon_class_init (gpointer g_class, gpointer class_data) parent_class = g_type_class_peek_parent (g_class); - g_object_class_install_property(gobject_class, ARG_BYTESPERREAD, - g_param_spec_ulong("bytes_per_read","bytes_per_read","bytes_per_read", - 0,G_MAXULONG,0,G_PARAM_READWRITE)); /* CHECKME */ - g_object_class_install_property(gobject_class, ARG_CUROFFSET, - g_param_spec_ulong("curoffset","curoffset","curoffset", - 0,G_MAXULONG,0,G_PARAM_READABLE)); /* CHECKME */ - g_object_class_install_property(gobject_class, ARG_DEPTH, - g_param_spec_enum("depth","depth","depth", - GST_TYPE_ESDMON_DEPTHS,16,G_PARAM_READWRITE)); /* CHECKME! */ - g_object_class_install_property(gobject_class, ARG_CHANNELS, - g_param_spec_enum("channels","channels","channels", - GST_TYPE_ESDMON_CHANNELS,2,G_PARAM_READWRITE)); /* CHECKME! */ - g_object_class_install_property(gobject_class, ARG_RATE, - g_param_spec_int("frequency","frequency","frequency", - G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */ - g_object_class_install_property(gobject_class, ARG_HOST, - g_param_spec_string("host","host","host", - NULL, G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (gobject_class, ARG_BYTESPERREAD, g_param_spec_ulong ("bytes_per_read", "bytes_per_read", "bytes_per_read", 0, G_MAXULONG, 0, G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (gobject_class, ARG_CUROFFSET, g_param_spec_ulong ("curoffset", "curoffset", "curoffset", 0, G_MAXULONG, 0, G_PARAM_READABLE)); /* CHECKME */ + g_object_class_install_property (gobject_class, ARG_DEPTH, g_param_spec_enum ("depth", "depth", "depth", GST_TYPE_ESDMON_DEPTHS, 16, G_PARAM_READWRITE)); /* CHECKME! */ + g_object_class_install_property (gobject_class, ARG_CHANNELS, g_param_spec_enum ("channels", "channels", "channels", GST_TYPE_ESDMON_CHANNELS, 2, G_PARAM_READWRITE)); /* CHECKME! */ + g_object_class_install_property (gobject_class, ARG_RATE, g_param_spec_int ("frequency", "frequency", "frequency", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (gobject_class, ARG_HOST, g_param_spec_string ("host", "host", "host", NULL, G_PARAM_READWRITE)); /* CHECKME */ gobject_class->set_property = gst_esdmon_set_property; gobject_class->get_property = gst_esdmon_get_property; @@ -192,16 +180,16 @@ gst_esdmon_class_init (gpointer g_class, gpointer class_data) } static void -gst_esdmon_init(GTypeInstance *instance, gpointer g_class) +gst_esdmon_init (GTypeInstance * instance, gpointer g_class) { GstEsdmon *esdmon = GST_ESDMON (instance); - esdmon->srcpad = gst_pad_new_from_template ( - gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (esdmon), "src"), - "src"); - gst_pad_set_get_function(esdmon->srcpad, gst_esdmon_get); + esdmon->srcpad = + gst_pad_new_from_template (gst_element_class_get_pad_template + (GST_ELEMENT_GET_CLASS (esdmon), "src"), "src"); + gst_pad_set_get_function (esdmon->srcpad, gst_esdmon_get); gst_pad_use_explicit_caps (esdmon->srcpad); - gst_element_add_pad(GST_ELEMENT(esdmon), esdmon->srcpad); + gst_element_add_pad (GST_ELEMENT (esdmon), esdmon->srcpad); esdmon->fd = -1; /* FIXME: get default from somewhere better than just putting them inline. */ @@ -216,12 +204,13 @@ gst_esdmon_init(GTypeInstance *instance, gpointer g_class) } static gboolean -gst_esdmon_sync_parms (GstEsdmon *esdmon) +gst_esdmon_sync_parms (GstEsdmon * esdmon) { g_return_val_if_fail (esdmon != NULL, FALSE); g_return_val_if_fail (GST_IS_ESDMON (esdmon), FALSE); - if (esdmon->fd == -1) return TRUE; + if (esdmon->fd == -1) + return TRUE; /* Need to set fd to use new parameters: only way to do this is to reopen. */ gst_esdmon_close_audio (esdmon); @@ -229,7 +218,7 @@ gst_esdmon_sync_parms (GstEsdmon *esdmon) } static GstData * -gst_esdmon_get (GstPad *pad) +gst_esdmon_get (GstPad * pad) { GstEsdmon *esdmon; GstBuffer *buf; @@ -237,36 +226,33 @@ gst_esdmon_get (GstPad *pad) glong readsamples; g_return_val_if_fail (pad != NULL, NULL); - esdmon = GST_ESDMON(gst_pad_get_parent (pad)); + esdmon = GST_ESDMON (gst_pad_get_parent (pad)); GST_DEBUG ("attempting to read something from esdmon"); buf = gst_buffer_new (); g_return_val_if_fail (buf, NULL); - GST_BUFFER_DATA (buf) = (gpointer)g_malloc (esdmon->bytes_per_read); + GST_BUFFER_DATA (buf) = (gpointer) g_malloc (esdmon->bytes_per_read); - readbytes = read (esdmon->fd, - GST_BUFFER_DATA (buf), - esdmon->bytes_per_read); + readbytes = read (esdmon->fd, GST_BUFFER_DATA (buf), esdmon->bytes_per_read); if (readbytes == 0) { - gst_element_set_eos (GST_ELEMENT (esdmon)); - return NULL; + gst_element_set_eos (GST_ELEMENT (esdmon)); + return NULL; } if (!GST_PAD_CAPS (pad)) { gint sign = (esdmon->depth == 8 ? FALSE : TRUE); + /* set caps on src pad */ if (gst_pad_set_explicit_caps (esdmon->srcpad, - gst_caps_new_simple ("audio/x-raw-int", - "endianness", G_TYPE_INT, G_BYTE_ORDER, - "signed", G_TYPE_BOOLEAN, sign, - "width", G_TYPE_INT, esdmon->depth, - "depth", G_TYPE_INT, esdmon->depth, - "rate", G_TYPE_INT, esdmon->frequency, - "channels", G_TYPE_INT, esdmon->channels - )) <= 0) - { + gst_caps_new_simple ("audio/x-raw-int", + "endianness", G_TYPE_INT, G_BYTE_ORDER, + "signed", G_TYPE_BOOLEAN, sign, + "width", G_TYPE_INT, esdmon->depth, + "depth", G_TYPE_INT, esdmon->depth, + "rate", G_TYPE_INT, esdmon->frequency, + "channels", G_TYPE_INT, esdmon->channels)) <= 0) { GST_ELEMENT_ERROR (esdmon, CORE, NEGOTIATION, (NULL), (NULL)); return NULL; } @@ -275,25 +261,28 @@ gst_esdmon_get (GstPad *pad) GST_BUFFER_SIZE (buf) = readbytes; GST_BUFFER_OFFSET (buf) = esdmon->curoffset; GST_BUFFER_TIMESTAMP (buf) = esdmon->basetime + - esdmon->samples_since_basetime * GST_SECOND / esdmon->frequency; + esdmon->samples_since_basetime * GST_SECOND / esdmon->frequency; esdmon->curoffset += readbytes; readsamples = readbytes / esdmon->channels; - if (esdmon->depth == 16) readsamples /= 2; + if (esdmon->depth == 16) + readsamples /= 2; esdmon->samples_since_basetime += readsamples; - GST_DEBUG ("pushed buffer from esdmon of %ld bytes, timestamp %" G_GINT64_FORMAT, readbytes, GST_BUFFER_TIMESTAMP (buf)); + GST_DEBUG ("pushed buffer from esdmon of %ld bytes, timestamp %" + G_GINT64_FORMAT, readbytes, GST_BUFFER_TIMESTAMP (buf)); return GST_DATA (buf); } static void -gst_esdmon_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_esdmon_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstEsdmon *esdmon; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_ESDMON(object)); - esdmon = GST_ESDMON(object); + g_return_if_fail (GST_IS_ESDMON (object)); + esdmon = GST_ESDMON (object); switch (prop_id) { case ARG_BYTESPERREAD: @@ -310,7 +299,8 @@ gst_esdmon_set_property (GObject *object, guint prop_id, const GValue *value, GP break; case ARG_RATE: /* Preserve the timestamps */ - esdmon->basetime = esdmon->samples_since_basetime * GST_SECOND / esdmon->frequency; + esdmon->basetime = + esdmon->samples_since_basetime * GST_SECOND / esdmon->frequency; esdmon->samples_since_basetime = 0; /* Set the new frequency */ @@ -318,11 +308,12 @@ gst_esdmon_set_property (GObject *object, guint prop_id, const GValue *value, GP gst_esdmon_sync_parms (esdmon); break; case ARG_HOST: - if (esdmon->host != NULL) g_free(esdmon->host); + if (esdmon->host != NULL) + g_free (esdmon->host); if (g_value_get_string (value) == NULL) - esdmon->host = NULL; + esdmon->host = NULL; else - esdmon->host = g_strdup (g_value_get_string (value)); + esdmon->host = g_strdup (g_value_get_string (value)); break; default: break; @@ -330,13 +321,14 @@ gst_esdmon_set_property (GObject *object, guint prop_id, const GValue *value, GP } static void -gst_esdmon_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_esdmon_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstEsdmon *esdmon; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_ESDMON(object)); - esdmon = GST_ESDMON(object); + g_return_if_fail (GST_IS_ESDMON (object)); + esdmon = GST_ESDMON (object); switch (prop_id) { case ARG_BYTESPERREAD: @@ -364,42 +356,46 @@ gst_esdmon_get_property (GObject *object, guint prop_id, GValue *value, GParamSp } gboolean -gst_esdmon_factory_init (GstPlugin *plugin) +gst_esdmon_factory_init (GstPlugin * plugin) { if (!gst_element_register (plugin, "esdmon", GST_RANK_NONE, GST_TYPE_ESDMON)) return FALSE; - + return TRUE; } static gboolean -gst_esdmon_open_audio (GstEsdmon *src) +gst_esdmon_open_audio (GstEsdmon * src) { /* Name used by esound for this connection. */ - const char * connname = "GStreamer"; + const char *connname = "GStreamer"; /* Bitmap describing audio format. */ esd_format_t esdformat = ESD_STREAM | ESD_PLAY; g_return_val_if_fail (src->fd == -1, FALSE); - if (src->depth == 16) esdformat |= ESD_BITS16; - else if (src->depth == 8) esdformat |= ESD_BITS8; + if (src->depth == 16) + esdformat |= ESD_BITS16; + else if (src->depth == 8) + esdformat |= ESD_BITS8; else { GST_DEBUG ("esdmon: invalid bit depth (%d)", src->depth); return FALSE; } - if (src->channels == 2) esdformat |= ESD_STEREO; - else if (src->channels == 1) esdformat |= ESD_MONO; + if (src->channels == 2) + esdformat |= ESD_STEREO; + else if (src->channels == 1) + esdformat |= ESD_MONO; else { GST_DEBUG ("esdmon: invalid number of channels (%d)", src->channels); return FALSE; } GST_DEBUG ("esdmon: attempting to open connection to esound server"); - src->fd = esd_monitor_stream(esdformat, src->frequency, src->host, connname); - if ( src->fd < 0 ) { + src->fd = esd_monitor_stream (esdformat, src->frequency, src->host, connname); + if (src->fd < 0) { GST_DEBUG ("esdmon: can't open connection to esound server"); return FALSE; } @@ -410,11 +406,12 @@ gst_esdmon_open_audio (GstEsdmon *src) } static void -gst_esdmon_close_audio (GstEsdmon *src) +gst_esdmon_close_audio (GstEsdmon * src) { - if (src->fd < 0) return; + if (src->fd < 0) + return; - close(src->fd); + close (src->fd); src->fd = -1; GST_FLAG_UNSET (src, GST_ESDMON_OPEN); @@ -423,7 +420,7 @@ gst_esdmon_close_audio (GstEsdmon *src) } static GstElementStateReturn -gst_esdmon_change_state (GstElement *element) +gst_esdmon_change_state (GstElement * element) { g_return_val_if_fail (GST_IS_ESDMON (element), FALSE); @@ -443,4 +440,3 @@ gst_esdmon_change_state (GstElement *element) return GST_ELEMENT_CLASS (parent_class)->change_state (element); return GST_STATE_SUCCESS; } - diff --git a/ext/esd/esdmon.h b/ext/esd/esdmon.h index f50e6544..5b8c7e49 100644 --- a/ext/esd/esdmon.h +++ b/ext/esd/esdmon.h @@ -26,7 +26,6 @@ #include <gst/gst.h> G_BEGIN_DECLS - #define GST_TYPE_ESDMON \ (gst_esdmon_get_type()) #define GST_ESDMON(obj) \ @@ -37,21 +36,22 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ESDMON)) #define GST_IS_ESDMON_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ESDMON)) - -typedef enum { - GST_ESDMON_OPEN = GST_ELEMENT_FLAG_LAST, - GST_ESDMON_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2, + typedef enum +{ + GST_ESDMON_OPEN = GST_ELEMENT_FLAG_LAST, + GST_ESDMON_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2, } GstEsdSrcFlags; typedef struct _GstEsdmon GstEsdmon; typedef struct _GstEsdmonClass GstEsdmonClass; -struct _GstEsdmon { +struct _GstEsdmon +{ GstElement element; GstPad *srcpad; - gchar* host; + gchar *host; int fd; @@ -65,14 +65,13 @@ struct _GstEsdmon { guint64 bytes_per_read; }; -struct _GstEsdmonClass { +struct _GstEsdmonClass +{ GstElementClass parent_class; }; -GType gst_esdmon_get_type(void); -gboolean gst_esdmon_factory_init(GstPlugin *plugin); +GType gst_esdmon_get_type (void); +gboolean gst_esdmon_factory_init (GstPlugin * plugin); G_END_DECLS - #endif /* __GST_ESDMON_H__ */ - diff --git a/ext/esd/esdsink.c b/ext/esd/esdsink.c index 4672ab79..ce7045e7 100644 --- a/ext/esd/esdsink.c +++ b/ext/esd/esdsink.c @@ -40,12 +40,14 @@ static GstElementDetails esdsink_details = { }; /* Signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_MUTE, ARG_HOST, @@ -53,41 +55,36 @@ enum { ARG_FALLBACK, }; -static GstStaticPadTemplate sink_factory = -GST_STATIC_PAD_TEMPLATE ( - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ( - "audio/x-raw-int, " - "endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", " - "signed = (boolean) TRUE, " - "width = (int) 16, " - "depth = (int) 16, " - "rate = 44100, " - "channels = 2" - ) -); - -static void gst_esdsink_base_init (gpointer g_class); -static void gst_esdsink_class_init (gpointer g_class, gpointer class_data); -static void gst_esdsink_init (GTypeInstance *instance, gpointer g_class); - -static gboolean gst_esdsink_open_audio (GstEsdsink *sink); -static void gst_esdsink_close_audio (GstEsdsink *sink); -static GstElementStateReturn gst_esdsink_change_state (GstElement *element); - -static GstClockTime gst_esdsink_get_time (GstClock *clock, gpointer data); -static GstClock * gst_esdsink_get_clock (GstElement *element); -static void gst_esdsink_set_clock (GstElement *element, GstClock *clock); -static void gst_esdsink_chain (GstPad *pad, GstData *_data); - -static void gst_esdsink_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_esdsink_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw-int, " + "endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", " + "signed = (boolean) TRUE, " + "width = (int) 16, " + "depth = (int) 16, " "rate = 44100, " "channels = 2") + ); + +static void gst_esdsink_base_init (gpointer g_class); +static void gst_esdsink_class_init (gpointer g_class, gpointer class_data); +static void gst_esdsink_init (GTypeInstance * instance, gpointer g_class); + +static gboolean gst_esdsink_open_audio (GstEsdsink * sink); +static void gst_esdsink_close_audio (GstEsdsink * sink); +static GstElementStateReturn gst_esdsink_change_state (GstElement * element); + +static GstClockTime gst_esdsink_get_time (GstClock * clock, gpointer data); +static GstClock *gst_esdsink_get_clock (GstElement * element); +static void gst_esdsink_set_clock (GstElement * element, GstClock * clock); +static void gst_esdsink_chain (GstPad * pad, GstData * _data); + +static void gst_esdsink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_esdsink_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); static GstElementClass *parent_class = NULL; + /*static guint gst_esdsink_signals[LAST_SIGNAL] = { 0 }; */ GType @@ -97,17 +94,19 @@ gst_esdsink_get_type (void) if (!esdsink_type) { static const GTypeInfo esdsink_info = { - sizeof(GstEsdsinkClass), + sizeof (GstEsdsinkClass), gst_esdsink_base_init, NULL, gst_esdsink_class_init, NULL, NULL, - sizeof(GstEsdsink), + sizeof (GstEsdsink), 0, gst_esdsink_init, }; - esdsink_type = g_type_register_static(GST_TYPE_ELEMENT, "GstEsdsink", &esdsink_info, 0); + esdsink_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstEsdsink", &esdsink_info, + 0); } return esdsink_type; } @@ -117,7 +116,7 @@ gst_esdsink_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - gst_element_class_add_pad_template (element_class, + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sink_factory)); gst_element_class_set_details (element_class, &esdsink_details); } @@ -130,64 +129,64 @@ gst_esdsink_class_init (gpointer g_class, gpointer class_data) parent_class = g_type_class_peek_parent (g_class); - g_object_class_install_property(gobject_class, ARG_MUTE, - g_param_spec_boolean("mute","mute","mute", - TRUE,G_PARAM_READWRITE)); /* CHECKME */ - g_object_class_install_property(gobject_class, ARG_HOST, - g_param_spec_string("host","host","host", - NULL, G_PARAM_READWRITE)); /* CHECKME */ - g_object_class_install_property(gobject_class, ARG_SYNC, - g_param_spec_boolean("sync","sync","Synchronize output to clock", - TRUE,G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, ARG_MUTE, g_param_spec_boolean ("mute", "mute", "mute", TRUE, G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (gobject_class, ARG_HOST, g_param_spec_string ("host", "host", "host", NULL, G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (gobject_class, ARG_SYNC, + g_param_spec_boolean ("sync", "sync", "Synchronize output to clock", + TRUE, G_PARAM_READWRITE)); #if 0 /* This option is disabled because it is dumb in GStreamer's architecture. */ - g_object_class_install_property(gobject_class, ARG_FALLBACK, - g_param_spec_boolean("fallback","fallback","Fall back to using OSS if Esound daemon is not present", - FALSE,G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, ARG_FALLBACK, + g_param_spec_boolean ("fallback", "fallback", + "Fall back to using OSS if Esound daemon is not present", FALSE, + G_PARAM_READWRITE)); #endif gobject_class->set_property = gst_esdsink_set_property; gobject_class->get_property = gst_esdsink_get_property; gstelement_class->change_state = gst_esdsink_change_state; - gstelement_class->set_clock = gst_esdsink_set_clock; - gstelement_class->get_clock = gst_esdsink_get_clock; + gstelement_class->set_clock = gst_esdsink_set_clock; + gstelement_class->get_clock = gst_esdsink_get_clock; } static void -gst_esdsink_init(GTypeInstance *instance, gpointer g_class) +gst_esdsink_init (GTypeInstance * instance, gpointer g_class) { GstEsdsink *esdsink = GST_ESDSINK (instance); - - esdsink->sinkpad = gst_pad_new_from_template ( - gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (instance), "sink"), - "sink"); - gst_element_add_pad(GST_ELEMENT(esdsink), esdsink->sinkpad); - gst_pad_set_chain_function(esdsink->sinkpad, GST_DEBUG_FUNCPTR(gst_esdsink_chain)); + + esdsink->sinkpad = + gst_pad_new_from_template (gst_element_class_get_pad_template + (GST_ELEMENT_GET_CLASS (instance), "sink"), "sink"); + gst_element_add_pad (GST_ELEMENT (esdsink), esdsink->sinkpad); + gst_pad_set_chain_function (esdsink->sinkpad, + GST_DEBUG_FUNCPTR (gst_esdsink_chain)); GST_FLAG_SET (esdsink, GST_ELEMENT_EVENT_AWARE); esdsink->mute = FALSE; esdsink->fd = -1; /* FIXME: get default from somewhere better than just putting them inline. */ - /*esdsink->negotiated = FALSE;*/ + /*esdsink->negotiated = FALSE; */ /* we have static caps on our template, so it always is negotiated */ esdsink->negotiated = TRUE; esdsink->format = 16; esdsink->depth = 16; esdsink->channels = 2; esdsink->frequency = 44100; - esdsink->bytes_per_sample = esdsink->channels * (esdsink->depth/8); + esdsink->bytes_per_sample = esdsink->channels * (esdsink->depth / 8); esdsink->host = getenv ("ESPEAKER"); - esdsink->provided_clock = gst_audio_clock_new("esdclock", gst_esdsink_get_time, esdsink); - gst_object_set_parent(GST_OBJECT(esdsink->provided_clock), GST_OBJECT(esdsink)); + esdsink->provided_clock = + gst_audio_clock_new ("esdclock", gst_esdsink_get_time, esdsink); + gst_object_set_parent (GST_OBJECT (esdsink->provided_clock), + GST_OBJECT (esdsink)); esdsink->sync = TRUE; esdsink->fallback = FALSE; } #ifdef unused static GstPadLinkReturn -gst_esdsink_link (GstPad *pad, const GstCaps *caps) +gst_esdsink_link (GstPad * pad, const GstCaps * caps) { GstEsdsink *esdsink; GstStructure *structure; @@ -199,7 +198,7 @@ gst_esdsink_link (GstPad *pad, const GstCaps *caps) gst_structure_get_int (structure, "channels", &esdsink->channels); gst_structure_get_int (structure, "rate", &esdsink->frequency); - esdsink->bytes_per_sample = esdsink->channels * (esdsink->depth/8); + esdsink->bytes_per_sample = esdsink->channels * (esdsink->depth / 8); gst_esdsink_close_audio (esdsink); if (gst_esdsink_open_audio (esdsink)) { @@ -215,29 +214,29 @@ gst_esdsink_link (GstPad *pad, const GstCaps *caps) #endif static GstClockTime -gst_esdsink_get_time (GstClock *clock, gpointer data) +gst_esdsink_get_time (GstClock * clock, gpointer data) { - GstEsdsink *esdsink = GST_ESDSINK(data); + GstEsdsink *esdsink = GST_ESDSINK (data); GstClockTime res; res = (esdsink->handled * GST_SECOND) / esdsink->frequency; - //- GST_SECOND * 2; + //- GST_SECOND * 2; return res; } static GstClock * -gst_esdsink_get_clock (GstElement *element) +gst_esdsink_get_clock (GstElement * element) { GstEsdsink *esdsink; esdsink = GST_ESDSINK (element); - return GST_CLOCK(esdsink->provided_clock); + return GST_CLOCK (esdsink->provided_clock); } static void -gst_esdsink_set_clock (GstElement *element, GstClock *clock) +gst_esdsink_set_clock (GstElement * element, GstClock * clock) { GstEsdsink *esdsink; @@ -247,7 +246,7 @@ gst_esdsink_set_clock (GstElement *element, GstClock *clock) } static void -gst_esdsink_chain (GstPad *pad, GstData *_data) +gst_esdsink_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstEsdsink *esdsink; @@ -256,24 +255,24 @@ gst_esdsink_chain (GstPad *pad, GstData *_data) if (!esdsink->negotiated) { GST_ELEMENT_ERROR (esdsink, CORE, NEGOTIATION, (NULL), - ("element wasn't negotiated before chain function")); + ("element wasn't negotiated before chain function")); goto done; } - if (GST_IS_EVENT(buf)){ - GstEvent *event = GST_EVENT(buf); + if (GST_IS_EVENT (buf)) { + GstEvent *event = GST_EVENT (buf); - switch(GST_EVENT_TYPE(event)){ + switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: gst_audio_clock_set_active (GST_AUDIO_CLOCK (esdsink->provided_clock), FALSE); gst_pad_event_default (pad, event); return; default: - gst_pad_event_default(pad, event); + gst_pad_event_default (pad, event); return; } - gst_event_unref(event); + gst_event_unref (event); return; } @@ -286,17 +285,17 @@ gst_esdsink_chain (GstPad *pad, GstData *_data) to_write = size; GST_LOG ("fd=%d data=%p size=%d", - esdsink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); - while (to_write > 0){ + esdsink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); + while (to_write > 0) { int done; - done = write (esdsink->fd, data, to_write); + done = write (esdsink->fd, data, to_write); - if(done < 0){ - if(errno==EINTR){ + if (done < 0) { + if (errno == EINTR) { goto done; } - g_assert_not_reached(); + g_assert_not_reached (); } to_write -= done; @@ -307,7 +306,7 @@ gst_esdsink_chain (GstPad *pad, GstData *_data) } } - gst_audio_clock_update_time ((GstAudioClock *)esdsink->provided_clock, + gst_audio_clock_update_time ((GstAudioClock *) esdsink->provided_clock, gst_esdsink_get_time (esdsink->provided_clock, esdsink)); done: @@ -315,24 +314,25 @@ done: } static void -gst_esdsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_esdsink_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstEsdsink *esdsink; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_ESDSINK(object)); - esdsink = GST_ESDSINK(object); + g_return_if_fail (GST_IS_ESDSINK (object)); + esdsink = GST_ESDSINK (object); switch (prop_id) { case ARG_MUTE: esdsink->mute = g_value_get_boolean (value); break; case ARG_HOST: - g_free(esdsink->host); + g_free (esdsink->host); if (g_value_get_string (value) == NULL) - esdsink->host = NULL; + esdsink->host = NULL; else - esdsink->host = g_strdup (g_value_get_string (value)); + esdsink->host = g_strdup (g_value_get_string (value)); break; case ARG_SYNC: esdsink->sync = g_value_get_boolean (value); @@ -346,11 +346,12 @@ gst_esdsink_set_property (GObject *object, guint prop_id, const GValue *value, G } static void -gst_esdsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_esdsink_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstEsdsink *esdsink; - esdsink = GST_ESDSINK(object); + esdsink = GST_ESDSINK (object); switch (prop_id) { case ARG_MUTE: @@ -372,50 +373,58 @@ gst_esdsink_get_property (GObject *object, guint prop_id, GValue *value, GParamS } gboolean -gst_esdsink_factory_init (GstPlugin *plugin) +gst_esdsink_factory_init (GstPlugin * plugin) { - if (!gst_element_register (plugin, "esdsink", GST_RANK_NONE, GST_TYPE_ESDSINK)) + if (!gst_element_register (plugin, "esdsink", GST_RANK_NONE, + GST_TYPE_ESDSINK)) return FALSE; return TRUE; } static gboolean -gst_esdsink_open_audio (GstEsdsink *sink) +gst_esdsink_open_audio (GstEsdsink * sink) { /* Name used by esound for this connection. */ - const char * connname = "GStreamer"; + const char *connname = "GStreamer"; /* Bitmap describing audio format. */ esd_format_t esdformat = ESD_STREAM | ESD_PLAY; g_return_val_if_fail (sink->fd == -1, FALSE); - if (sink->depth == 16) esdformat |= ESD_BITS16; - else if (sink->depth == 8) esdformat |= ESD_BITS8; + if (sink->depth == 16) + esdformat |= ESD_BITS16; + else if (sink->depth == 8) + esdformat |= ESD_BITS8; else { GST_ELEMENT_ERROR (sink, STREAM, FORMAT, (NULL), - ("invalid bit depth (%d)", sink->depth)); + ("invalid bit depth (%d)", sink->depth)); return FALSE; } - if (sink->channels == 2) esdformat |= ESD_STEREO; - else if (sink->channels == 1) esdformat |= ESD_MONO; + if (sink->channels == 2) + esdformat |= ESD_STEREO; + else if (sink->channels == 1) + esdformat |= ESD_MONO; else { GST_ELEMENT_ERROR (sink, STREAM, FORMAT, (NULL), - ("invalid number of channels (%d)", sink->channels)); + ("invalid number of channels (%d)", sink->channels)); return FALSE; } GST_INFO ("attempting to open connection to esound server"); - if(sink->fallback){ - sink->fd = esd_play_stream_fallback(esdformat, sink->frequency, sink->host, connname); - }else{ - sink->fd = esd_play_stream(esdformat, sink->frequency, sink->host, connname); + if (sink->fallback) { + sink->fd = + esd_play_stream_fallback (esdformat, sink->frequency, sink->host, + connname); + } else { + sink->fd = + esd_play_stream (esdformat, sink->frequency, sink->host, connname); } - if ( sink->fd < 0 ) { + if (sink->fd < 0) { GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL), - ("can't open connection to esound server")); + ("can't open connection to esound server")); return FALSE; } GST_INFO ("successfully opened connection to esound server"); @@ -424,19 +433,19 @@ gst_esdsink_open_audio (GstEsdsink *sink) } static void -gst_esdsink_close_audio (GstEsdsink *sink) +gst_esdsink_close_audio (GstEsdsink * sink) { - if (sink->fd < 0) + if (sink->fd < 0) return; - close(sink->fd); + close (sink->fd); sink->fd = -1; GST_INFO ("esdsink: closed sound device"); } static GstElementStateReturn -gst_esdsink_change_state (GstElement *element) +gst_esdsink_change_state (GstElement * element) { GstEsdsink *esdsink; @@ -445,7 +454,7 @@ gst_esdsink_change_state (GstElement *element) switch (GST_STATE_TRANSITION (element)) { case GST_STATE_NULL_TO_READY: if (!gst_esdsink_open_audio (GST_ESDSINK (element))) { - return GST_STATE_FAILURE; + return GST_STATE_FAILURE; } break; case GST_STATE_READY_TO_PAUSED: @@ -473,4 +482,3 @@ gst_esdsink_change_state (GstElement *element) return GST_STATE_SUCCESS; } - diff --git a/ext/esd/esdsink.h b/ext/esd/esdsink.h index 9bf81641..f88f29b1 100644 --- a/ext/esd/esdsink.h +++ b/ext/esd/esdsink.h @@ -25,7 +25,6 @@ #include <gst/audio/audioclock.h> G_BEGIN_DECLS - #define GST_TYPE_ESDSINK \ (gst_esdsink_get_type()) #define GST_ESDSINK(obj) \ @@ -36,41 +35,41 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ESDSINK)) #define GST_IS_ESDSINK_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ESDSINK)) - typedef struct _GstEsdsink GstEsdsink; typedef struct _GstEsdsinkClass GstEsdsinkClass; -struct _GstEsdsink { - GstElement element; +struct _GstEsdsink +{ + GstElement element; - GstPad *sinkpad; + GstPad *sinkpad; - GstClock *provided_clock; - GstClock *clock; + GstClock *provided_clock; + GstClock *clock; - gboolean mute; - int fd; - gint format; - gint depth; - gint channels; - gint frequency; - gboolean negotiated; - gchar *host; - int handled; - int bytes_per_sample; - gboolean sync; - gboolean resync; - gboolean fallback; + gboolean mute; + int fd; + gint format; + gint depth; + gint channels; + gint frequency; + gboolean negotiated; + gchar *host; + int handled; + int bytes_per_sample; + gboolean sync; + gboolean resync; + gboolean fallback; }; -struct _GstEsdsinkClass { +struct _GstEsdsinkClass +{ GstElementClass parent_class; }; -GType gst_esdsink_get_type(void); -gboolean gst_esdsink_factory_init (GstPlugin *plugin); +GType gst_esdsink_get_type (void); +gboolean gst_esdsink_factory_init (GstPlugin * plugin); G_END_DECLS - #endif /* __GST_ESDSINK_H__ */ diff --git a/ext/esd/gstesd.c b/ext/esd/gstesd.c index ea480a30..4ee03364 100644 --- a/ext/esd/gstesd.c +++ b/ext/esd/gstesd.c @@ -27,30 +27,27 @@ GST_DEBUG_CATEGORY (esd_debug); static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { gboolean ret; - if (!gst_library_load ("gstaudio")) return FALSE; + if (!gst_library_load ("gstaudio")) + return FALSE; - ret = gst_esdsink_factory_init(plugin); - if(ret == FALSE) return FALSE; + ret = gst_esdsink_factory_init (plugin); + if (ret == FALSE) + return FALSE; - ret = gst_esdmon_factory_init(plugin); - if(ret == FALSE) return FALSE; + ret = gst_esdmon_factory_init (plugin); + if (ret == FALSE) + return FALSE; GST_DEBUG_CATEGORY_INIT (esd_debug, "esd", 0, "ESounD elements"); return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "esdsink", - "ESD Element Plugins", - plugin_init, - VERSION, - "LGPL", - GST_PACKAGE, - GST_ORIGIN) - +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "esdsink", + "ESD Element Plugins", + plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN) |