summaryrefslogtreecommitdiff
path: root/gst/adder
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2004-03-15 19:32:28 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2004-03-15 19:32:28 +0000
commitf83cb187de417a9043b46edf710a54874ba917a3 (patch)
tree6344616f73e58bf46715879a44f2e7ed55560fb0 /gst/adder
parent8392245d807cf74a5020b0909ad72dc3bfbec356 (diff)
don't mix tabs and spaces
Original commit message from CVS: don't mix tabs and spaces
Diffstat (limited to 'gst/adder')
-rw-r--r--gst/adder/gstadder.c155
1 files changed, 78 insertions, 77 deletions
diff --git a/gst/adder/gstadder.c b/gst/adder/gstadder.c
index fcdb788bc..b2f14d40b 100644
--- a/gst/adder/gstadder.c
+++ b/gst/adder/gstadder.c
@@ -27,7 +27,7 @@
#endif
#include "gstadder.h"
#include <gst/audio/audio.h>
-#include <string.h> /* strcmp */
+#include <string.h> /* strcmp */
#define GST_ADDER_BUFFER_SIZE 4096
#define GST_ADDER_NUM_BUFFERS 8
@@ -57,7 +57,7 @@ static GstStaticPadTemplate gst_adder_src_template =
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
- GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
);
static GstStaticPadTemplate gst_adder_sink_template =
@@ -65,7 +65,7 @@ static GstStaticPadTemplate gst_adder_sink_template =
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
- GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
);
static void gst_adder_class_init (GstAdderClass * klass);
@@ -97,8 +97,9 @@ gst_adder_get_type (void)
sizeof (GstAdder), 0,
(GInstanceInitFunc) gst_adder_init,
};
+
adder_type = g_type_register_static (GST_TYPE_ELEMENT, "GstAdder",
- &adder_info, 0);
+ &adder_info, 0);
}
return adder_type;
}
@@ -126,7 +127,7 @@ gst_adder_link (GstPad * pad, const GstCaps * caps)
if (otherpad != pad) {
ret = gst_pad_try_set_caps (otherpad, caps);
if (GST_PAD_LINK_FAILED (ret)) {
- return ret;
+ return ret;
}
}
pads = g_list_next (pads);
@@ -140,7 +141,7 @@ gst_adder_link (GstPad * pad, const GstCaps * caps)
if (otherpad != pad) {
ret = gst_pad_try_set_caps (otherpad, caps);
if (GST_PAD_LINK_FAILED (ret)) {
- return ret;
+ return ret;
}
}
pads = g_list_next (pads);
@@ -187,7 +188,7 @@ gst_adder_class_init (GstAdderClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS,
g_param_spec_int ("num_pads", "number of pads", "Number Of Pads",
- 0, G_MAXINT, 0, G_PARAM_READABLE));
+ 0, G_MAXINT, 0, G_PARAM_READABLE));
gobject_class->get_property = gst_adder_get_property;
@@ -310,7 +311,7 @@ gst_adder_loop (GstElement * element)
if (buf_out == NULL) {
GST_ELEMENT_ERROR (adder, CORE, TOO_LAZY, (NULL),
- ("could not get new output buffer"));
+ ("could not get new output buffer"));
return;
}
@@ -335,14 +336,14 @@ gst_adder_loop (GstElement * element)
if (!GST_PAD_IS_USABLE (input->sinkpad)) {
GST_DEBUG ("adder ignoring pad %s:%s",
- GST_DEBUG_PAD_NAME (input->sinkpad));
+ GST_DEBUG_PAD_NAME (input->sinkpad));
continue;
}
/* Get data from the bytestream of each input channel. We need to check for
events before passing on the data to the output buffer. */
got_bytes = gst_bytestream_peek_bytes (input->bytestream, &raw_in,
- GST_BUFFER_SIZE (buf_out));
+ GST_BUFFER_SIZE (buf_out));
/* FIXME we should do something with the data if got_bytes > 0 */
if (got_bytes < GST_BUFFER_SIZE (buf_out)) {
@@ -353,80 +354,80 @@ gst_adder_loop (GstElement * element)
gst_bytestream_get_status (input->bytestream, &waiting, &event);
if (event) {
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_EOS:
- /* if we get an EOS event from one of our sink pads, we assume that
- pad's finished handling data. just skip this pad. */
- GST_DEBUG ("got an EOS event");
- gst_event_unref (event);
- continue;
- case GST_EVENT_INTERRUPT:
- gst_event_unref (event);
- GST_DEBUG ("got an interrupt event");
- /* we have to call interrupt here, the scheduler will switch out
- this element ASAP or returns TRUE if we need to exit the loop */
- if (gst_element_interrupt (GST_ELEMENT (adder))) {
- gst_buffer_unref (buf_out);
- return;
- }
- default:
- break;
- }
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_EOS:
+ /* if we get an EOS event from one of our sink pads, we assume that
+ pad's finished handling data. just skip this pad. */
+ GST_DEBUG ("got an EOS event");
+ gst_event_unref (event);
+ continue;
+ case GST_EVENT_INTERRUPT:
+ gst_event_unref (event);
+ GST_DEBUG ("got an interrupt event");
+ /* we have to call interrupt here, the scheduler will switch out
+ this element ASAP or returns TRUE if we need to exit the loop */
+ if (gst_element_interrupt (GST_ELEMENT (adder))) {
+ gst_buffer_unref (buf_out);
+ return;
+ }
+ default:
+ break;
+ }
}
} else {
/* here's where the data gets copied. */
GST_DEBUG ("copying %d bytes from channel %p to output data %p "
- "in buffer %p",
- GST_BUFFER_SIZE (buf_out), input, GST_BUFFER_DATA (buf_out), buf_out);
+ "in buffer %p",
+ GST_BUFFER_SIZE (buf_out), input, GST_BUFFER_DATA (buf_out), buf_out);
if (adder->format == GST_ADDER_FORMAT_INT) {
- if (adder->width == 32) {
- gint32 *in = (gint32 *) raw_in;
- gint32 *out = (gint32 *) GST_BUFFER_DATA (buf_out);
-
- for (i = 0; i < GST_BUFFER_SIZE (buf_out) / 4; i++)
- out[i] = CLAMP (out[i] + in[i], 0x80000000, 0x7fffffff);
- } else if (adder->width == 16) {
- gint16 *in = (gint16 *) raw_in;
- gint16 *out = (gint16 *) GST_BUFFER_DATA (buf_out);
-
- for (i = 0; i < GST_BUFFER_SIZE (buf_out) / 2; i++)
- out[i] = CLAMP (out[i] + in[i], 0x8000, 0x7fff);
- } else if (adder->width == 8) {
- gint8 *in = (gint8 *) raw_in;
- gint8 *out = (gint8 *) GST_BUFFER_DATA (buf_out);
-
- for (i = 0; i < GST_BUFFER_SIZE (buf_out); i++)
- out[i] = CLAMP (out[i] + in[i], 0x80, 0x7f);
- } else {
- GST_ELEMENT_ERROR (adder, STREAM, FORMAT, (NULL),
- ("invalid width (%u) for integer audio in gstadder",
- adder->width));
- return;
- }
+ if (adder->width == 32) {
+ gint32 *in = (gint32 *) raw_in;
+ gint32 *out = (gint32 *) GST_BUFFER_DATA (buf_out);
+
+ for (i = 0; i < GST_BUFFER_SIZE (buf_out) / 4; i++)
+ out[i] = CLAMP (out[i] + in[i], 0x80000000, 0x7fffffff);
+ } else if (adder->width == 16) {
+ gint16 *in = (gint16 *) raw_in;
+ gint16 *out = (gint16 *) GST_BUFFER_DATA (buf_out);
+
+ for (i = 0; i < GST_BUFFER_SIZE (buf_out) / 2; i++)
+ out[i] = CLAMP (out[i] + in[i], 0x8000, 0x7fff);
+ } else if (adder->width == 8) {
+ gint8 *in = (gint8 *) raw_in;
+ gint8 *out = (gint8 *) GST_BUFFER_DATA (buf_out);
+
+ for (i = 0; i < GST_BUFFER_SIZE (buf_out); i++)
+ out[i] = CLAMP (out[i] + in[i], 0x80, 0x7f);
+ } else {
+ GST_ELEMENT_ERROR (adder, STREAM, FORMAT, (NULL),
+ ("invalid width (%u) for integer audio in gstadder",
+ adder->width));
+ return;
+ }
} else if (adder->format == GST_ADDER_FORMAT_FLOAT) {
- if (adder->width == 64) {
- gdouble *in = (gdouble *) raw_in;
- gdouble *out = (gdouble *) GST_BUFFER_DATA (buf_out);
-
- for (i = 0; i < GST_BUFFER_SIZE (buf_out) / sizeof (gdouble); i++)
- out[i] = CLAMP (out[i] + in[i], -1.0, 1.0);
- } else if (adder->width == 32) {
- gfloat *in = (gfloat *) raw_in;
- gfloat *out = (gfloat *) GST_BUFFER_DATA (buf_out);
-
- for (i = 0; i < GST_BUFFER_SIZE (buf_out) / sizeof (gfloat); i++)
- out[i] = CLAMP (out[i] + in[i], -1.0, 1.0);
- } else {
- GST_ELEMENT_ERROR (adder, STREAM, FORMAT, (NULL),
- ("invalid width (%u) for float audio in gstadder", adder->width));
- return;
- }
+ if (adder->width == 64) {
+ gdouble *in = (gdouble *) raw_in;
+ gdouble *out = (gdouble *) GST_BUFFER_DATA (buf_out);
+
+ for (i = 0; i < GST_BUFFER_SIZE (buf_out) / sizeof (gdouble); i++)
+ out[i] = CLAMP (out[i] + in[i], -1.0, 1.0);
+ } else if (adder->width == 32) {
+ gfloat *in = (gfloat *) raw_in;
+ gfloat *out = (gfloat *) GST_BUFFER_DATA (buf_out);
+
+ for (i = 0; i < GST_BUFFER_SIZE (buf_out) / sizeof (gfloat); i++)
+ out[i] = CLAMP (out[i] + in[i], -1.0, 1.0);
+ } else {
+ GST_ELEMENT_ERROR (adder, STREAM, FORMAT, (NULL),
+ ("invalid width (%u) for float audio in gstadder", adder->width));
+ return;
+ }
} else {
- GST_ELEMENT_ERROR (adder, STREAM, FORMAT, (NULL),
- ("invalid audio format (%d) in gstadder", adder->format));
- return;
+ GST_ELEMENT_ERROR (adder, STREAM, FORMAT, (NULL),
+ ("invalid audio format (%d) in gstadder", adder->format));
+ return;
}
gst_bytestream_flush (input->bytestream, GST_BUFFER_SIZE (buf_out));
@@ -438,10 +439,10 @@ gst_adder_loop (GstElement * element)
GST_BUFFER_TIMESTAMP (buf_out) = adder->timestamp;
if (adder->format == GST_ADDER_FORMAT_FLOAT)
adder->offset +=
- GST_BUFFER_SIZE (buf_out) / sizeof (gfloat) / adder->channels;
+ GST_BUFFER_SIZE (buf_out) / sizeof (gfloat) / adder->channels;
else
adder->offset +=
- GST_BUFFER_SIZE (buf_out) * 8 / adder->width / adder->channels;
+ GST_BUFFER_SIZE (buf_out) * 8 / adder->width / adder->channels;
adder->timestamp = adder->offset * GST_SECOND / adder->rate;
/* send it out */