Re-indent the siren stuff to be gst style

This commit is contained in:
Olivier Crête 2009-02-10 19:20:19 +00:00 committed by Edward Hervey
parent b1efc2f9aa
commit 11328ad67f
5 changed files with 41 additions and 68 deletions

View file

@ -27,7 +27,6 @@
#include <gst/base/gstbasetransform.h>
G_BEGIN_DECLS
/* #define's don't like whitespacey bits */
#define GST_TYPE_SIREN \
(gst_siren_get_type())
@ -41,7 +40,6 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SIREN))
#define GST_IS_SIREN_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SIREN))
typedef struct _GstSiren GstSiren;
typedef struct _GstSirenClass GstSirenClass;
typedef struct _GstSirenPrivate GstSirenPrivate;
@ -65,5 +63,4 @@ struct _GstSirenClass
GType gst_siren_get_type (void);
G_END_DECLS
#endif /* __GST_SIREN_H__ */

View file

@ -33,18 +33,16 @@ GST_DEBUG_CATEGORY (sirendec_debug);
/* elementfactory information */
static const GstElementDetails gst_siren_dec_details =
GST_ELEMENT_DETAILS (
"Siren Decoder element",
"Codec/Decoder/Audio ",
"Decode streams encoded with the Siren7 codec into 16bit PCM",
"Youness Alaoui <kakaroto@kakaroto.homelinux.net>");
GST_ELEMENT_DETAILS ("Siren Decoder element",
"Codec/Decoder/Audio ",
"Decode streams encoded with the Siren7 codec into 16bit PCM",
"Youness Alaoui <kakaroto@kakaroto.homelinux.net>");
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-siren, "
"dct-length = (int) 320"));
GST_STATIC_CAPS ("audio/x-siren, " "dct-length = (int) 320"));
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
@ -54,8 +52,7 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
"depth = (int) 16, "
"endianness = (int) 1234, "
"signed = (boolean) true, "
"rate = (int) 16000, "
"channels = (int) 1"));
"rate = (int) 16000, " "channels = (int) 1"));
/* signals and args */
enum
@ -70,16 +67,14 @@ enum
};
static GstFlowReturn
gst_siren_dec_chain (GstPad *pad, GstBuffer *buf);
static GstFlowReturn gst_siren_dec_chain (GstPad * pad, GstBuffer * buf);
static void gst_siren_dec_dispose (GObject *object);
static void gst_siren_dec_dispose (GObject * object);
static void
_do_init (GType type)
{
GST_DEBUG_CATEGORY_INIT
(sirendec_debug, "sirendec", 0, "sirendec");
GST_DEBUG_CATEGORY_INIT (sirendec_debug, "sirendec", 0, "sirendec");
}
GST_BOILERPLATE_FULL (GstSirenDec, gst_siren_dec, GstElement,
@ -99,7 +94,7 @@ gst_siren_dec_base_init (gpointer klass)
}
static void
gst_siren_dec_class_init (GstSirenDecClass *klass)
gst_siren_dec_class_init (GstSirenDecClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
@ -115,7 +110,7 @@ gst_siren_dec_class_init (GstSirenDecClass *klass)
}
static void
gst_siren_dec_init (GstSirenDec *dec, GstSirenDecClass *klass)
gst_siren_dec_init (GstSirenDec * dec, GstSirenDecClass * klass)
{
GST_DEBUG_OBJECT (dec, "Initializing");
@ -136,7 +131,7 @@ gst_siren_dec_init (GstSirenDec *dec, GstSirenDecClass *klass)
}
static void
gst_siren_dec_dispose (GObject *object)
gst_siren_dec_dispose (GObject * object)
{
GstSirenDec *dec = GST_SIREN_DEC (object);
@ -147,8 +142,7 @@ gst_siren_dec_dispose (GObject *object)
dec->decoder = NULL;
}
if (dec->srccaps)
{
if (dec->srccaps) {
gst_caps_unref (dec->srccaps);
dec->srccaps = NULL;
}
@ -157,7 +151,7 @@ gst_siren_dec_dispose (GObject *object)
}
static GstFlowReturn
gst_siren_dec_chain (GstPad *pad, GstBuffer *buf)
gst_siren_dec_chain (GstPad * pad, GstBuffer * buf)
{
GstSirenDec *dec = GST_SIREN_DEC (gst_pad_get_parent_element (pad));
GstFlowReturn ret = GST_FLOW_OK;
@ -172,8 +166,7 @@ gst_siren_dec_chain (GstPad *pad, GstBuffer *buf)
size = GST_BUFFER_SIZE (buf) * 16;
size -= size % 640;
if (size == 0)
{
if (size == 0) {
GST_LOG_OBJECT (dec, "Got buffer smaller than framesize: %u < 40",
GST_BUFFER_SIZE (buf));
return GST_FLOW_OK;
@ -190,8 +183,7 @@ gst_siren_dec_chain (GstPad *pad, GstBuffer *buf)
GST_BUFFER_TIMESTAMP (decoded) = GST_BUFFER_TIMESTAMP (buf);
while((in_offset + 40 <= GST_BUFFER_SIZE (buf)) &&
ret == GST_FLOW_OK) {
while ((in_offset + 40 <= GST_BUFFER_SIZE (buf)) && ret == GST_FLOW_OK) {
GST_LOG_OBJECT (dec, "Decoding frame");
@ -224,7 +216,7 @@ gst_siren_dec_chain (GstPad *pad, GstBuffer *buf)
gboolean
gst_siren_dec_plugin_init (GstPlugin *plugin)
gst_siren_dec_plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "sirendec",
GST_RANK_MARGINAL, GST_TYPE_SIREN_DEC);

View file

@ -29,7 +29,6 @@
#include "siren7.h"
G_BEGIN_DECLS
/* #define's don't like whitespacey bits */
#define GST_TYPE_SIREN_DEC \
(gst_siren_dec_get_type())
@ -43,7 +42,6 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SIREN_DEC))
#define GST_IS_SIREN_DEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SIREN_DEC))
typedef struct _GstSirenDec GstSirenDec;
typedef struct _GstSirenDecClass GstSirenDecClass;
typedef struct _GstSirenDecPrivate GstSirenDecPrivate;
@ -53,7 +51,7 @@ struct _GstSirenDec
GstElement parent;
/* Protected by stream lock */
SirenDecoder decoder;
SirenDecoder decoder;
GstPad *sinkpad;
GstPad *srcpad;
@ -68,9 +66,7 @@ struct _GstSirenDecClass
GType gst_siren_dec_get_type (void);
gboolean
gst_siren_dec_plugin_init (GstPlugin *plugin);
gboolean gst_siren_dec_plugin_init (GstPlugin * plugin);
G_END_DECLS
#endif /* __GST_SIREN_DEC_H__ */

View file

@ -33,18 +33,16 @@ GST_DEBUG_CATEGORY (sirenenc_debug);
/* elementfactory information */
static const GstElementDetails gst_siren_enc_details =
GST_ELEMENT_DETAILS (
"Siren Encoder element",
"Codec/Encoder/Audio ",
"Encode 16bit PCM streams into the Siren7 codec",
"Youness Alaoui <kakaroto@kakaroto.homelinux.net>");
GST_ELEMENT_DETAILS ("Siren Encoder element",
"Codec/Encoder/Audio ",
"Encode 16bit PCM streams into the Siren7 codec",
"Youness Alaoui <kakaroto@kakaroto.homelinux.net>");
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-siren, "
"dct-length = (int) 320"));
GST_STATIC_CAPS ("audio/x-siren, " "dct-length = (int) 320"));
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
@ -54,8 +52,7 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
"depth = (int) 16, "
"endianness = (int) 1234, "
"signed = (boolean) true, "
"rate = (int) 16000, "
"channels = (int) 1"));
"rate = (int) 16000, " "channels = (int) 1"));
/* signals and args */
enum
@ -71,19 +68,17 @@ enum
static void gst_siren_enc_dispose (GObject *object);
static void gst_siren_enc_dispose (GObject * object);
static GstFlowReturn
gst_siren_enc_chain (GstPad *pad, GstBuffer *buf);
static GstFlowReturn gst_siren_enc_chain (GstPad * pad, GstBuffer * buf);
static GstStateChangeReturn
gst_siren_change_state (GstElement *element, GstStateChange transition);
gst_siren_change_state (GstElement * element, GstStateChange transition);
static void
_do_init (GType type)
{
GST_DEBUG_CATEGORY_INIT
(sirenenc_debug, "sirenenc", 0, "sirenenc");
GST_DEBUG_CATEGORY_INIT (sirenenc_debug, "sirenenc", 0, "sirenenc");
}
GST_BOILERPLATE_FULL (GstSirenEnc, gst_siren_enc, GstElement,
@ -103,7 +98,7 @@ gst_siren_enc_base_init (gpointer klass)
}
static void
gst_siren_enc_class_init (GstSirenEncClass *klass)
gst_siren_enc_class_init (GstSirenEncClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
@ -121,7 +116,7 @@ gst_siren_enc_class_init (GstSirenEncClass *klass)
}
static void
gst_siren_enc_init (GstSirenEnc *enc, GstSirenEncClass *klass)
gst_siren_enc_init (GstSirenEnc * enc, GstSirenEncClass * klass)
{
GST_DEBUG_OBJECT (enc, "Initializing");
@ -143,7 +138,7 @@ gst_siren_enc_init (GstSirenEnc *enc, GstSirenEncClass *klass)
}
static void
gst_siren_enc_dispose (GObject *object)
gst_siren_enc_dispose (GObject * object)
{
GstSirenEnc *enc = GST_SIREN_ENC (object);
@ -159,8 +154,7 @@ gst_siren_enc_dispose (GObject *object)
enc->adapter = NULL;
}
if (enc->srccaps)
{
if (enc->srccaps) {
gst_caps_unref (enc->srccaps);
enc->srccaps = NULL;
}
@ -169,7 +163,7 @@ gst_siren_enc_dispose (GObject *object)
}
static GstFlowReturn
gst_siren_enc_chain (GstPad *pad, GstBuffer *buf)
gst_siren_enc_chain (GstPad * pad, GstBuffer * buf)
{
GstSirenEnc *enc = GST_SIREN_ENC (gst_pad_get_parent_element (pad));
GstFlowReturn ret = GST_FLOW_OK;
@ -210,8 +204,7 @@ gst_siren_enc_chain (GstPad *pad, GstBuffer *buf)
GST_LOG_OBJECT (enc, "Encoding frame");
encode_ret = Siren7_EncodeFrame (enc->encoder,
data + in_offset,
GST_BUFFER_DATA (encoded) + out_offset);
data + in_offset, GST_BUFFER_DATA (encoded) + out_offset);
if (encode_ret != 0) {
GST_ERROR_OBJECT (enc, "Siren7_EncodeFrame returned %d", encode_ret);
ret = GST_FLOW_ERROR;
@ -227,7 +220,7 @@ gst_siren_enc_chain (GstPad *pad, GstBuffer *buf)
ret = gst_pad_push (enc->srcpad, encoded);
out:
out:
if (data)
g_free (data);
@ -236,7 +229,7 @@ gst_siren_enc_chain (GstPad *pad, GstBuffer *buf)
}
static GstStateChangeReturn
gst_siren_change_state (GstElement *element, GstStateChange transition)
gst_siren_change_state (GstElement * element, GstStateChange transition)
{
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
GstSirenEnc *enc = GST_SIREN_ENC (element);
@ -246,8 +239,7 @@ gst_siren_change_state (GstElement *element, GstStateChange transition)
if (ret == GST_STATE_CHANGE_FAILURE)
return ret;
switch (transition)
{
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY:
GST_OBJECT_LOCK (element);
gst_adapter_clear (enc->adapter);
@ -261,7 +253,7 @@ gst_siren_change_state (GstElement *element, GstStateChange transition)
}
gboolean
gst_siren_enc_plugin_init (GstPlugin *plugin)
gst_siren_enc_plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "sirenenc",
GST_RANK_MARGINAL, GST_TYPE_SIREN_ENC);

View file

@ -29,7 +29,6 @@
#include "siren7.h"
G_BEGIN_DECLS
/* #define's don't like whitespacey bits */
#define GST_TYPE_SIREN_ENC \
(gst_siren_enc_get_type())
@ -43,7 +42,6 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SIREN_ENC))
#define GST_IS_SIREN_ENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SIREN_ENC))
typedef struct _GstSirenEnc GstSirenEnc;
typedef struct _GstSirenEncClass GstSirenEncClass;
typedef struct _GstSirenEncPrivate GstSirenEncPrivate;
@ -53,7 +51,7 @@ struct _GstSirenEnc
GstElement parent;
/* protected by the stream lock */
SirenEncoder encoder;
SirenEncoder encoder;
/* protected by the object lock */
GstAdapter *adapter;
@ -70,9 +68,7 @@ struct _GstSirenEncClass
GType gst_siren_enc_get_type (void);
gboolean
gst_siren_enc_plugin_init (GstPlugin *plugin);
gboolean gst_siren_enc_plugin_init (GstPlugin * plugin);
G_END_DECLS
#endif /* __GST_SIREN_ENC_H__ */