mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 13:06:23 +00:00
gst-indent
Original commit message from CVS: gst-indent
This commit is contained in:
parent
d952e72d42
commit
c2bcfc8446
3 changed files with 595 additions and 557 deletions
|
@ -65,24 +65,25 @@ static GstElementClass *parent_class = NULL;
|
||||||
static void gst_jack_base_init (gpointer g_class);
|
static void gst_jack_base_init (gpointer g_class);
|
||||||
static void gst_jack_src_base_init (gpointer g_class);
|
static void gst_jack_src_base_init (gpointer g_class);
|
||||||
static void gst_jack_sink_base_init (gpointer g_class);
|
static void gst_jack_sink_base_init (gpointer g_class);
|
||||||
static void gst_jack_init(GstJack *this);
|
static void gst_jack_init (GstJack * this);
|
||||||
static void gst_jack_class_init(GstJackClass *klass);
|
static void gst_jack_class_init (GstJackClass * klass);
|
||||||
static void gst_jack_set_property (GObject *object, guint prop_id,
|
static void gst_jack_set_property (GObject * object, guint prop_id,
|
||||||
const GValue *value, GParamSpec *pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_jack_get_property (GObject *object, guint prop_id,
|
static void gst_jack_get_property (GObject * object, guint prop_id,
|
||||||
GValue *value, GParamSpec *pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static GstPadTemplate* gst_jack_src_request_pad_factory();
|
static GstPadTemplate *gst_jack_src_request_pad_factory ();
|
||||||
static GstPadTemplate* gst_jack_sink_request_pad_factory();
|
static GstPadTemplate *gst_jack_sink_request_pad_factory ();
|
||||||
static GstPad* gst_jack_request_new_pad (GstElement *element, GstPadTemplate *templ,
|
static GstPad *gst_jack_request_new_pad (GstElement * element,
|
||||||
const gchar *name);
|
GstPadTemplate * templ, const gchar * name);
|
||||||
static GstElementStateReturn gst_jack_change_state (GstElement *element);
|
static GstElementStateReturn gst_jack_change_state (GstElement * element);
|
||||||
static GstPadLinkReturn gst_jack_link (GstPad *pad, const GstCaps *caps);
|
static GstPadLinkReturn gst_jack_link (GstPad * pad, const GstCaps * caps);
|
||||||
|
|
||||||
static void gst_jack_loop (GstElement *element);
|
static void gst_jack_loop (GstElement * element);
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
ARG_0,
|
ARG_0,
|
||||||
ARG_PORT_NAME_PREFIX,
|
ARG_PORT_NAME_PREFIX,
|
||||||
};
|
};
|
||||||
|
@ -95,17 +96,18 @@ gst_jack_get_type (void)
|
||||||
|
|
||||||
if (!jack_type) {
|
if (!jack_type) {
|
||||||
static const GTypeInfo jack_info = {
|
static const GTypeInfo jack_info = {
|
||||||
sizeof(GstJackClass),
|
sizeof (GstJackClass),
|
||||||
gst_jack_base_init,
|
gst_jack_base_init,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
sizeof(GstJack),
|
sizeof (GstJack),
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
jack_type = g_type_register_static (GST_TYPE_ELEMENT, "GstJack", &jack_info, 0);
|
jack_type =
|
||||||
|
g_type_register_static (GST_TYPE_ELEMENT, "GstJack", &jack_info, 0);
|
||||||
}
|
}
|
||||||
return jack_type;
|
return jack_type;
|
||||||
}
|
}
|
||||||
|
@ -117,17 +119,18 @@ gst_jack_sink_get_type (void)
|
||||||
|
|
||||||
if (!jack_type) {
|
if (!jack_type) {
|
||||||
static const GTypeInfo jack_info = {
|
static const GTypeInfo jack_info = {
|
||||||
sizeof(GstJackClass),
|
sizeof (GstJackClass),
|
||||||
gst_jack_sink_base_init,
|
gst_jack_sink_base_init,
|
||||||
NULL,
|
NULL,
|
||||||
(GClassInitFunc)gst_jack_class_init,
|
(GClassInitFunc) gst_jack_class_init,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
sizeof(GstJack),
|
sizeof (GstJack),
|
||||||
0,
|
0,
|
||||||
(GInstanceInitFunc)gst_jack_init,
|
(GInstanceInitFunc) gst_jack_init,
|
||||||
};
|
};
|
||||||
jack_type = g_type_register_static (GST_TYPE_JACK, "GstJackSink", &jack_info, 0);
|
jack_type =
|
||||||
|
g_type_register_static (GST_TYPE_JACK, "GstJackSink", &jack_info, 0);
|
||||||
}
|
}
|
||||||
return jack_type;
|
return jack_type;
|
||||||
}
|
}
|
||||||
|
@ -139,17 +142,18 @@ gst_jack_src_get_type (void)
|
||||||
|
|
||||||
if (!jack_type) {
|
if (!jack_type) {
|
||||||
static const GTypeInfo jack_info = {
|
static const GTypeInfo jack_info = {
|
||||||
sizeof(GstJackClass),
|
sizeof (GstJackClass),
|
||||||
gst_jack_src_base_init,
|
gst_jack_src_base_init,
|
||||||
NULL,
|
NULL,
|
||||||
(GClassInitFunc)gst_jack_class_init,
|
(GClassInitFunc) gst_jack_class_init,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
sizeof(GstJack),
|
sizeof (GstJack),
|
||||||
0,
|
0,
|
||||||
(GInstanceInitFunc)gst_jack_init,
|
(GInstanceInitFunc) gst_jack_init,
|
||||||
};
|
};
|
||||||
jack_type = g_type_register_static (GST_TYPE_JACK, "GstJackSrc", &jack_info, 0);
|
jack_type =
|
||||||
|
g_type_register_static (GST_TYPE_JACK, "GstJackSrc", &jack_info, 0);
|
||||||
}
|
}
|
||||||
return jack_type;
|
return jack_type;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +171,8 @@ gst_jack_src_base_init (gpointer g_class)
|
||||||
{
|
{
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class, gst_jack_src_request_pad_factory ());
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_jack_src_request_pad_factory ());
|
||||||
gst_element_class_set_details (element_class, &gst_jack_src_details);
|
gst_element_class_set_details (element_class, &gst_jack_src_details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,23 +181,24 @@ gst_jack_sink_base_init (gpointer g_class)
|
||||||
{
|
{
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class, gst_jack_sink_request_pad_factory ());
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_jack_sink_request_pad_factory ());
|
||||||
gst_element_class_set_details (element_class, &gst_jack_sink_details);
|
gst_element_class_set_details (element_class, &gst_jack_sink_details);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_jack_class_init(GstJackClass *klass)
|
gst_jack_class_init (GstJackClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class;
|
GObjectClass *object_class;
|
||||||
GstElementClass *element_class;
|
GstElementClass *element_class;
|
||||||
GParamSpec *pspec;
|
GParamSpec *pspec;
|
||||||
gchar *prefix;
|
gchar *prefix;
|
||||||
|
|
||||||
object_class = (GObjectClass *)klass;
|
object_class = (GObjectClass *) klass;
|
||||||
element_class = (GstElementClass *)klass;
|
element_class = (GstElementClass *) klass;
|
||||||
|
|
||||||
if (parent_class == NULL)
|
if (parent_class == NULL)
|
||||||
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
||||||
|
|
||||||
object_class->get_property = gst_jack_get_property;
|
object_class->get_property = gst_jack_get_property;
|
||||||
object_class->set_property = gst_jack_set_property;
|
object_class->set_property = gst_jack_set_property;
|
||||||
|
@ -213,7 +219,7 @@ gst_jack_class_init(GstJackClass *klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_jack_init(GstJack *this)
|
gst_jack_init (GstJack * this)
|
||||||
{
|
{
|
||||||
if (G_OBJECT_TYPE (this) == GST_TYPE_JACK_SRC)
|
if (G_OBJECT_TYPE (this) == GST_TYPE_JACK_SRC)
|
||||||
this->direction = GST_PAD_SRC;
|
this->direction = GST_PAD_SRC;
|
||||||
|
@ -226,9 +232,10 @@ gst_jack_init(GstJack *this)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_jack_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
gst_jack_set_property (GObject * object, guint prop_id, const GValue * value,
|
||||||
|
GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
GstJack *this = (GstJack*)object;
|
GstJack *this = (GstJack *) object;
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_PORT_NAME_PREFIX:
|
case ARG_PORT_NAME_PREFIX:
|
||||||
|
@ -243,9 +250,10 @@ gst_jack_set_property(GObject *object, guint prop_id, const GValue *value, GPara
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_jack_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
gst_jack_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
|
GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
GstJack *this = (GstJack*)object;
|
GstJack *this = (GstJack *) object;
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_PORT_NAME_PREFIX:
|
case ARG_PORT_NAME_PREFIX:
|
||||||
|
@ -257,38 +265,39 @@ gst_jack_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstPadTemplate*
|
static GstPadTemplate *
|
||||||
gst_jack_src_request_pad_factory (void)
|
gst_jack_src_request_pad_factory (void)
|
||||||
{
|
{
|
||||||
static GstPadTemplate *template = NULL;
|
static GstPadTemplate *template = NULL;
|
||||||
|
|
||||||
if (!template) {
|
if (!template) {
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
caps = gst_caps_from_string (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
|
caps = gst_caps_from_string (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
|
||||||
template = gst_pad_template_new ("%s", GST_PAD_SRC,
|
template = gst_pad_template_new ("%s", GST_PAD_SRC, GST_PAD_REQUEST, caps);
|
||||||
GST_PAD_REQUEST, caps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstPadTemplate*
|
static GstPadTemplate *
|
||||||
gst_jack_sink_request_pad_factory (void)
|
gst_jack_sink_request_pad_factory (void)
|
||||||
{
|
{
|
||||||
static GstPadTemplate *template = NULL;
|
static GstPadTemplate *template = NULL;
|
||||||
|
|
||||||
if (!template) {
|
if (!template) {
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
caps = gst_caps_from_string (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
|
caps = gst_caps_from_string (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
|
||||||
template = gst_pad_template_new ("%s", GST_PAD_SINK,
|
template = gst_pad_template_new ("%s", GST_PAD_SINK, GST_PAD_REQUEST, caps);
|
||||||
GST_PAD_REQUEST, caps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstPad*
|
static GstPad *
|
||||||
gst_jack_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name)
|
gst_jack_request_new_pad (GstElement * element, GstPadTemplate * templ,
|
||||||
|
const gchar * name)
|
||||||
{
|
{
|
||||||
GstJack *this;
|
GstJack *this;
|
||||||
gchar *newname;
|
gchar *newname;
|
||||||
|
@ -308,8 +317,8 @@ gst_jack_request_new_pad (GstElement *element, GstPadTemplate *templ, const gcha
|
||||||
if (name) {
|
if (name) {
|
||||||
l = *pad_list;
|
l = *pad_list;
|
||||||
while (l) {
|
while (l) {
|
||||||
if (strcmp (GST_JACK_PAD(l)->name, name) == 0) {
|
if (strcmp (GST_JACK_PAD (l)->name, name) == 0) {
|
||||||
g_warning("requested port name %s already in use.", name);
|
g_warning ("requested port name %s already in use.", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
l = l->next;
|
l = l->next;
|
||||||
|
@ -327,8 +336,11 @@ gst_jack_request_new_pad (GstElement *element, GstPadTemplate *templ, const gcha
|
||||||
if (!port_name_counts)
|
if (!port_name_counts)
|
||||||
port_name_counts = g_hash_table_new (g_str_hash, g_str_equal);
|
port_name_counts = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
|
|
||||||
count = GPOINTER_TO_INT (g_hash_table_lookup (port_name_counts, this->port_name_prefix));
|
count =
|
||||||
g_hash_table_insert (port_name_counts, g_strdup (this->port_name_prefix), GINT_TO_POINTER (count+1));
|
GPOINTER_TO_INT (g_hash_table_lookup (port_name_counts,
|
||||||
|
this->port_name_prefix));
|
||||||
|
g_hash_table_insert (port_name_counts, g_strdup (this->port_name_prefix),
|
||||||
|
GINT_TO_POINTER (count + 1));
|
||||||
|
|
||||||
pad->name = g_strdup_printf ("%s%d", this->port_name_prefix, count);
|
pad->name = g_strdup_printf ("%s%d", this->port_name_prefix, count);
|
||||||
|
|
||||||
|
@ -339,12 +351,13 @@ gst_jack_request_new_pad (GstElement *element, GstPadTemplate *templ, const gcha
|
||||||
|
|
||||||
this->pads = g_list_append (this->pads, pad);
|
this->pads = g_list_append (this->pads, pad);
|
||||||
|
|
||||||
g_print ("returning from request_new_pad, pad %s created, to connect to %s\n", pad->name, pad->peer_name);
|
g_print ("returning from request_new_pad, pad %s created, to connect to %s\n",
|
||||||
|
pad->name, pad->peer_name);
|
||||||
return pad->pad;
|
return pad->pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstElementStateReturn
|
static GstElementStateReturn
|
||||||
gst_jack_change_state (GstElement *element)
|
gst_jack_change_state (GstElement * element)
|
||||||
{
|
{
|
||||||
GstJack *this;
|
GstJack *this;
|
||||||
GList *l = NULL, **pads;
|
GList *l = NULL, **pads;
|
||||||
|
@ -364,7 +377,7 @@ gst_jack_change_state (GstElement *element)
|
||||||
JACK_DEBUG ("%s: READY", GST_OBJECT_NAME (GST_OBJECT (this)));
|
JACK_DEBUG ("%s: READY", GST_OBJECT_NAME (GST_OBJECT (this)));
|
||||||
|
|
||||||
if (!this->bin) {
|
if (!this->bin) {
|
||||||
if (!(this->bin = (GstJackBin*)gst_element_get_managing_bin (element))
|
if (!(this->bin = (GstJackBin *) gst_element_get_managing_bin (element))
|
||||||
|| !GST_IS_JACK_BIN (this->bin)) {
|
|| !GST_IS_JACK_BIN (this->bin)) {
|
||||||
this->bin = NULL;
|
this->bin = NULL;
|
||||||
g_warning ("jack element %s needs to be contained in a jack bin.",
|
g_warning ("jack element %s needs to be contained in a jack bin.",
|
||||||
|
@ -374,10 +387,13 @@ gst_jack_change_state (GstElement *element)
|
||||||
|
|
||||||
/* fixme: verify that all names are unique */
|
/* fixme: verify that all names are unique */
|
||||||
l = this->pads;
|
l = this->pads;
|
||||||
pads = (this->direction == GST_PAD_SRC) ? &this->bin->src_pads : &this->bin->sink_pads;
|
pads =
|
||||||
|
(this->direction ==
|
||||||
|
GST_PAD_SRC) ? &this->bin->src_pads : &this->bin->sink_pads;
|
||||||
while (l) {
|
while (l) {
|
||||||
pad = GST_JACK_PAD (l);
|
pad = GST_JACK_PAD (l);
|
||||||
JACK_DEBUG ("%s: appending pad %s:%s to list", GST_OBJECT_NAME (this), pad->name, pad->peer_name);
|
JACK_DEBUG ("%s: appending pad %s:%s to list", GST_OBJECT_NAME (this),
|
||||||
|
pad->name, pad->peer_name);
|
||||||
*pads = g_list_append (*pads, pad);
|
*pads = g_list_append (*pads, pad);
|
||||||
l = g_list_next (l);
|
l = g_list_next (l);
|
||||||
}
|
}
|
||||||
|
@ -394,9 +410,8 @@ gst_jack_change_state (GstElement *element)
|
||||||
pad = GST_JACK_PAD (l);
|
pad = GST_JACK_PAD (l);
|
||||||
caps = gst_caps_copy (gst_pad_get_negotiated_caps (pad->pad));
|
caps = gst_caps_copy (gst_pad_get_negotiated_caps (pad->pad));
|
||||||
gst_caps_set_simple (caps,
|
gst_caps_set_simple (caps,
|
||||||
"rate", G_TYPE_INT, (int)this->bin->rate,
|
"rate", G_TYPE_INT, (int) this->bin->rate,
|
||||||
"buffer-frames", G_TYPE_INT, (gint)this->bin->nframes,
|
"buffer-frames", G_TYPE_INT, (gint) this->bin->nframes, NULL);
|
||||||
NULL);
|
|
||||||
if (gst_pad_try_set_caps (pad->pad, caps) <= 0)
|
if (gst_pad_try_set_caps (pad->pad, caps) <= 0)
|
||||||
return GST_STATE_FAILURE;
|
return GST_STATE_FAILURE;
|
||||||
l = g_list_next (l);
|
l = g_list_next (l);
|
||||||
|
@ -417,7 +432,7 @@ gst_jack_change_state (GstElement *element)
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstPadLinkReturn
|
static GstPadLinkReturn
|
||||||
gst_jack_link (GstPad *pad, const GstCaps *caps)
|
gst_jack_link (GstPad * pad, const GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstJack *this;
|
GstJack *this;
|
||||||
gint rate, buffer_frames;
|
gint rate, buffer_frames;
|
||||||
|
@ -436,7 +451,7 @@ gst_jack_link (GstPad *pad, const GstCaps *caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_jack_loop (GstElement *element)
|
gst_jack_loop (GstElement * element)
|
||||||
{
|
{
|
||||||
GstJack *this;
|
GstJack *this;
|
||||||
GList *pads;
|
GList *pads;
|
||||||
|
@ -457,6 +472,7 @@ gst_jack_loop (GstElement *element)
|
||||||
|
|
||||||
if (GST_IS_EVENT (buffer)) {
|
if (GST_IS_EVENT (buffer)) {
|
||||||
GstEvent *event = GST_EVENT (buffer);
|
GstEvent *event = GST_EVENT (buffer);
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (buffer)) {
|
switch (GST_EVENT_TYPE (buffer)) {
|
||||||
case GST_EVENT_EOS:
|
case GST_EVENT_EOS:
|
||||||
gst_element_set_eos (element);
|
gst_element_set_eos (element);
|
||||||
|
@ -472,8 +488,7 @@ gst_jack_loop (GstElement *element)
|
||||||
they should), if the length of the GstBuffer is different
|
they should), if the length of the GstBuffer is different
|
||||||
from nframes then the buffer is short and we will get EOS
|
from nframes then the buffer is short and we will get EOS
|
||||||
next */
|
next */
|
||||||
memcpy (pad->data, GST_BUFFER_DATA (buffer),
|
memcpy (pad->data, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
|
||||||
GST_BUFFER_SIZE (buffer));
|
|
||||||
if (len != GST_BUFFER_SIZE (buffer))
|
if (len != GST_BUFFER_SIZE (buffer))
|
||||||
memset (pad->data + GST_BUFFER_SIZE (buffer), 0,
|
memset (pad->data + GST_BUFFER_SIZE (buffer), 0,
|
||||||
len - GST_BUFFER_SIZE (buffer));
|
len - GST_BUFFER_SIZE (buffer));
|
||||||
|
@ -482,7 +497,7 @@ gst_jack_loop (GstElement *element)
|
||||||
} else {
|
} else {
|
||||||
buffer = gst_buffer_new ();
|
buffer = gst_buffer_new ();
|
||||||
gst_buffer_set_data (buffer, pad->data, len);
|
gst_buffer_set_data (buffer, pad->data, len);
|
||||||
GST_BUFFER_FLAG_SET(buffer, GST_BUFFER_DONTFREE);
|
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_DONTFREE);
|
||||||
|
|
||||||
gst_pad_push (pad->pad, GST_DATA (buffer));
|
gst_pad_push (pad->pad, GST_DATA (buffer));
|
||||||
}
|
}
|
||||||
|
@ -491,27 +506,24 @@ gst_jack_loop (GstElement *element)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
plugin_init (GstPlugin *plugin)
|
plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
if (!gst_element_register (plugin, "jackbin", GST_RANK_NONE, GST_TYPE_JACK_BIN))
|
if (!gst_element_register (plugin, "jackbin", GST_RANK_NONE,
|
||||||
|
GST_TYPE_JACK_BIN))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!gst_element_register (plugin, "jacksrc", GST_RANK_NONE, GST_TYPE_JACK_SRC))
|
if (!gst_element_register (plugin, "jacksrc", GST_RANK_NONE,
|
||||||
|
GST_TYPE_JACK_SRC))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!gst_element_register (plugin, "jacksink", GST_RANK_NONE, GST_TYPE_JACK_SINK))
|
if (!gst_element_register (plugin, "jacksink", GST_RANK_NONE,
|
||||||
|
GST_TYPE_JACK_SINK))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_PLUGIN_DEFINE (
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||||
GST_VERSION_MAJOR,
|
|
||||||
GST_VERSION_MINOR,
|
GST_VERSION_MINOR,
|
||||||
"jack",
|
"jack",
|
||||||
"Jack Plugin Library",
|
"Jack Plugin Library", plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
|
||||||
plugin_init,
|
|
||||||
VERSION,
|
|
||||||
"GPL",
|
|
||||||
GST_PACKAGE,
|
|
||||||
GST_ORIGIN)
|
|
||||||
|
|
|
@ -64,7 +64,8 @@ typedef GstJack GstJackSrc;
|
||||||
typedef GstJackClass GstJackSrcClass;
|
typedef GstJackClass GstJackSrcClass;
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
GST_JACK_OPEN = GST_BIN_FLAG_LAST,
|
GST_JACK_OPEN = GST_BIN_FLAG_LAST,
|
||||||
GST_JACK_ACTIVE,
|
GST_JACK_ACTIVE,
|
||||||
GST_JACK_FLAG_LAST = GST_BIN_FLAG_LAST + 3,
|
GST_JACK_FLAG_LAST = GST_BIN_FLAG_LAST + 3,
|
||||||
|
@ -73,7 +74,8 @@ enum {
|
||||||
|
|
||||||
typedef jack_default_audio_sample_t sample_t;
|
typedef jack_default_audio_sample_t sample_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
GstPad *pad;
|
GstPad *pad;
|
||||||
void *data;
|
void *data;
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
|
@ -81,7 +83,8 @@ typedef struct {
|
||||||
jack_port_t *port;
|
jack_port_t *port;
|
||||||
} GstJackPad;
|
} GstJackPad;
|
||||||
|
|
||||||
struct _GstJack {
|
struct _GstJack
|
||||||
|
{
|
||||||
GstElement element;
|
GstElement element;
|
||||||
|
|
||||||
/* list of GstJackPads */
|
/* list of GstJackPads */
|
||||||
|
@ -95,11 +98,13 @@ struct _GstJack {
|
||||||
GstJackBin *bin;
|
GstJackBin *bin;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstJackClass {
|
struct _GstJackClass
|
||||||
|
{
|
||||||
GstElementClass parent_class;
|
GstElementClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstJackBin {
|
struct _GstJackBin
|
||||||
|
{
|
||||||
GstBin bin;
|
GstBin bin;
|
||||||
|
|
||||||
jack_client_t *client;
|
jack_client_t *client;
|
||||||
|
@ -115,7 +120,8 @@ struct _GstJackBin {
|
||||||
jack_nframes_t nframes;
|
jack_nframes_t nframes;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstJackBinClass {
|
struct _GstJackBinClass
|
||||||
|
{
|
||||||
GstBinClass parent_class;
|
GstBinClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
|
|
||||||
static GstBinClass *parent_class = NULL;
|
static GstBinClass *parent_class = NULL;
|
||||||
|
|
||||||
static void gst_jack_bin_init(GstJackBin *this);
|
static void gst_jack_bin_init (GstJackBin * this);
|
||||||
static void gst_jack_bin_class_init(GstJackBinClass *klass);
|
static void gst_jack_bin_class_init (GstJackBinClass * klass);
|
||||||
|
|
||||||
static GstElementStateReturn gst_jack_bin_change_state(GstElement *element);
|
static GstElementStateReturn gst_jack_bin_change_state (GstElement * element);
|
||||||
|
|
||||||
/* jack callbacks */
|
/* jack callbacks */
|
||||||
static int process (jack_nframes_t nframes, void *arg);
|
static int process (jack_nframes_t nframes, void *arg);
|
||||||
|
@ -51,39 +51,41 @@ GType
|
||||||
gst_jack_bin_get_type (void)
|
gst_jack_bin_get_type (void)
|
||||||
{
|
{
|
||||||
static GType jack_bin_type = 0;
|
static GType jack_bin_type = 0;
|
||||||
if (!jack_bin_type) {
|
|
||||||
|
if (!jack_bin_type) {
|
||||||
static const GTypeInfo jack_bin_info = {
|
static const GTypeInfo jack_bin_info = {
|
||||||
sizeof(GstJackBinClass),
|
sizeof (GstJackBinClass),
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(GClassInitFunc)gst_jack_bin_class_init,
|
(GClassInitFunc) gst_jack_bin_class_init,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
sizeof(GstJackBin),
|
sizeof (GstJackBin),
|
||||||
0,
|
0,
|
||||||
(GInstanceInitFunc)gst_jack_bin_init,
|
(GInstanceInitFunc) gst_jack_bin_init,
|
||||||
};
|
};
|
||||||
jack_bin_type = g_type_register_static (GST_TYPE_BIN, "GstJackBin", &jack_bin_info, 0);
|
jack_bin_type =
|
||||||
|
g_type_register_static (GST_TYPE_BIN, "GstJackBin", &jack_bin_info, 0);
|
||||||
}
|
}
|
||||||
return jack_bin_type;
|
return jack_bin_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_jack_bin_class_init(GstJackBinClass *klass)
|
gst_jack_bin_class_init (GstJackBinClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class;
|
GObjectClass *object_class;
|
||||||
GstElementClass *element_class;
|
GstElementClass *element_class;
|
||||||
|
|
||||||
object_class = (GObjectClass *)klass;
|
object_class = (GObjectClass *) klass;
|
||||||
element_class = (GstElementClass *)klass;
|
element_class = (GstElementClass *) klass;
|
||||||
|
|
||||||
parent_class = g_type_class_ref(GST_TYPE_BIN);
|
parent_class = g_type_class_ref (GST_TYPE_BIN);
|
||||||
|
|
||||||
element_class->change_state = gst_jack_bin_change_state;
|
element_class->change_state = gst_jack_bin_change_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_jack_bin_init(GstJackBin *this)
|
gst_jack_bin_init (GstJackBin * this)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("initializing jack bin");
|
GST_DEBUG ("initializing jack bin");
|
||||||
|
|
||||||
|
@ -96,7 +98,7 @@ gst_jack_bin_init(GstJackBin *this)
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstElementStateReturn
|
static GstElementStateReturn
|
||||||
gst_jack_bin_change_state (GstElement *element)
|
gst_jack_bin_change_state (GstElement * element)
|
||||||
{
|
{
|
||||||
GstJackBin *this;
|
GstJackBin *this;
|
||||||
GList *l = NULL;
|
GList *l = NULL;
|
||||||
|
@ -146,13 +148,15 @@ gst_jack_bin_change_state (GstElement *element)
|
||||||
if (GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_OPEN)) {
|
if (GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_OPEN)) {
|
||||||
l = this->src_pads;
|
l = this->src_pads;
|
||||||
while (l) {
|
while (l) {
|
||||||
JACK_DEBUG ("jackbin: unregistering pad %s:%s", GST_JACK_PAD (l)->name, GST_JACK_PAD (l)->peer_name);
|
JACK_DEBUG ("jackbin: unregistering pad %s:%s",
|
||||||
|
GST_JACK_PAD (l)->name, GST_JACK_PAD (l)->peer_name);
|
||||||
jack_port_unregister (this->client, GST_JACK_PAD (l)->port);
|
jack_port_unregister (this->client, GST_JACK_PAD (l)->port);
|
||||||
l = g_list_next (l);
|
l = g_list_next (l);
|
||||||
}
|
}
|
||||||
l = this->sink_pads;
|
l = this->sink_pads;
|
||||||
while (l) {
|
while (l) {
|
||||||
JACK_DEBUG ("jackbin: unregistering pad %s:%s", GST_JACK_PAD (l)->name, GST_JACK_PAD (l)->peer_name);
|
JACK_DEBUG ("jackbin: unregistering pad %s:%s",
|
||||||
|
GST_JACK_PAD (l)->name, GST_JACK_PAD (l)->peer_name);
|
||||||
jack_port_unregister (this->client, GST_JACK_PAD (l)->port);
|
jack_port_unregister (this->client, GST_JACK_PAD (l)->port);
|
||||||
l = g_list_next (l);
|
l = g_list_next (l);
|
||||||
}
|
}
|
||||||
|
@ -176,15 +180,22 @@ gst_jack_bin_change_state (GstElement *element)
|
||||||
l = this->src_pads;
|
l = this->src_pads;
|
||||||
while (l) {
|
while (l) {
|
||||||
pad = GST_JACK_PAD (l);
|
pad = GST_JACK_PAD (l);
|
||||||
JACK_DEBUG ("jackbin: registering input port %s (peer %s)", pad->name, pad->peer_name);
|
JACK_DEBUG ("jackbin: registering input port %s (peer %s)", pad->name,
|
||||||
pad->port = jack_port_register (this->client, pad->name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput|JackPortIsTerminal, 0);
|
pad->peer_name);
|
||||||
|
pad->port =
|
||||||
|
jack_port_register (this->client, pad->name,
|
||||||
|
JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput | JackPortIsTerminal, 0);
|
||||||
l = g_list_next (l);
|
l = g_list_next (l);
|
||||||
}
|
}
|
||||||
l = this->sink_pads;
|
l = this->sink_pads;
|
||||||
while (l) {
|
while (l) {
|
||||||
pad = GST_JACK_PAD (l);
|
pad = GST_JACK_PAD (l);
|
||||||
JACK_DEBUG ("jackbin: registering output port %s (peer %s)", pad->name, pad->peer_name);
|
JACK_DEBUG ("jackbin: registering output port %s (peer %s)",
|
||||||
pad->port = jack_port_register (this->client, pad->name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput|JackPortIsTerminal, 0);
|
pad->name, pad->peer_name);
|
||||||
|
pad->port =
|
||||||
|
jack_port_register (this->client, pad->name,
|
||||||
|
JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput | JackPortIsTerminal,
|
||||||
|
0);
|
||||||
l = g_list_next (l);
|
l = g_list_next (l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,9 +209,12 @@ gst_jack_bin_change_state (GstElement *element)
|
||||||
l = this->src_pads;
|
l = this->src_pads;
|
||||||
while (l) {
|
while (l) {
|
||||||
pad = GST_JACK_PAD (l);
|
pad = GST_JACK_PAD (l);
|
||||||
JACK_DEBUG ("connecting jack port %s to gst jack port %s", pad->peer_name, jack_port_name (pad->port));
|
JACK_DEBUG ("connecting jack port %s to gst jack port %s",
|
||||||
if (jack_connect (this->client, pad->peer_name, jack_port_name (pad->port))) {
|
pad->peer_name, jack_port_name (pad->port));
|
||||||
g_warning ("jackbin: could not connect %s and %s", pad->peer_name, jack_port_name (pad->port));
|
if (jack_connect (this->client, pad->peer_name,
|
||||||
|
jack_port_name (pad->port))) {
|
||||||
|
g_warning ("jackbin: could not connect %s and %s", pad->peer_name,
|
||||||
|
jack_port_name (pad->port));
|
||||||
return GST_STATE_FAILURE;
|
return GST_STATE_FAILURE;
|
||||||
}
|
}
|
||||||
l = g_list_next (l);
|
l = g_list_next (l);
|
||||||
|
@ -208,9 +222,12 @@ gst_jack_bin_change_state (GstElement *element)
|
||||||
l = this->sink_pads;
|
l = this->sink_pads;
|
||||||
while (l) {
|
while (l) {
|
||||||
pad = GST_JACK_PAD (l);
|
pad = GST_JACK_PAD (l);
|
||||||
JACK_DEBUG ("connecting gst jack port %s to jack port %s", jack_port_name (pad->port), pad->peer_name);
|
JACK_DEBUG ("connecting gst jack port %s to jack port %s",
|
||||||
if (jack_connect (this->client, jack_port_name (pad->port), pad->peer_name)) {
|
jack_port_name (pad->port), pad->peer_name);
|
||||||
g_warning ("jackbin: could not connect %s and %s", pad->peer_name, jack_port_name (pad->port));
|
if (jack_connect (this->client, jack_port_name (pad->port),
|
||||||
|
pad->peer_name)) {
|
||||||
|
g_warning ("jackbin: could not connect %s and %s", pad->peer_name,
|
||||||
|
jack_port_name (pad->port));
|
||||||
return GST_STATE_FAILURE;
|
return GST_STATE_FAILURE;
|
||||||
}
|
}
|
||||||
l = g_list_next (l);
|
l = g_list_next (l);
|
||||||
|
@ -247,7 +264,7 @@ gst_jack_bin_change_state (GstElement *element)
|
||||||
static int
|
static int
|
||||||
process (jack_nframes_t nframes, void *arg)
|
process (jack_nframes_t nframes, void *arg)
|
||||||
{
|
{
|
||||||
GstJackBin *bin = (GstJackBin*) arg;
|
GstJackBin *bin = (GstJackBin *) arg;
|
||||||
GstJackPad *pad;
|
GstJackPad *pad;
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
|
@ -292,7 +309,8 @@ process (jack_nframes_t nframes, void *arg)
|
||||||
static int
|
static int
|
||||||
sample_rate (jack_nframes_t nframes, void *arg)
|
sample_rate (jack_nframes_t nframes, void *arg)
|
||||||
{
|
{
|
||||||
GstJackBin *bin = (GstJackBin*) arg;
|
GstJackBin *bin = (GstJackBin *) arg;
|
||||||
|
|
||||||
JACK_DEBUG ("the sample rate is now %lu/sec\n", nframes);
|
JACK_DEBUG ("the sample rate is now %lu/sec\n", nframes);
|
||||||
bin->rate = nframes;
|
bin->rate = nframes;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -301,7 +319,8 @@ sample_rate (jack_nframes_t nframes, void *arg)
|
||||||
static int
|
static int
|
||||||
buffer_size (jack_nframes_t nframes, void *arg)
|
buffer_size (jack_nframes_t nframes, void *arg)
|
||||||
{
|
{
|
||||||
GstJackBin *bin = (GstJackBin*) arg;
|
GstJackBin *bin = (GstJackBin *) arg;
|
||||||
|
|
||||||
JACK_DEBUG ("the buffer size is now %lu\n", nframes);
|
JACK_DEBUG ("the buffer size is now %lu\n", nframes);
|
||||||
bin->nframes = nframes;
|
bin->nframes = nframes;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -315,7 +334,8 @@ shutdown (void *arg)
|
||||||
/* gst_element_set_state (GST_ELEMENT (client->manager), GST_STATE_READY); */
|
/* gst_element_set_state (GST_ELEMENT (client->manager), GST_STATE_READY); */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sighup_handler (int sig)
|
static void
|
||||||
|
sighup_handler (int sig)
|
||||||
{
|
{
|
||||||
g_message ("got sighup, setting state to READY");
|
g_message ("got sighup, setting state to READY");
|
||||||
watchdog_please_set_the_jackbin_to_ready = TRUE;
|
watchdog_please_set_the_jackbin_to_ready = TRUE;
|
||||||
|
|
Loading…
Reference in a new issue