make jack work in all its full duplex glory

Original commit message from CVS:
make jack work in all its full duplex glory
This commit is contained in:
Andy Wingo 2002-07-02 23:35:07 +00:00 committed by Tim-Philipp Müller
parent af472ca88b
commit c2880b1c6d
2 changed files with 26 additions and 8 deletions

View file

@ -64,6 +64,7 @@ static GstElementDetails gst_jack_src_details = {
}; };
static GHashTable *port_name_counts = NULL;
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
static void gst_jack_init(GstJack *this); static void gst_jack_init(GstJack *this);
@ -188,6 +189,7 @@ gst_jack_class_init(GstJackClass *klass)
{ {
GObjectClass *object_class; GObjectClass *object_class;
GstElementClass *element_class; GstElementClass *element_class;
gchar *prefix;
object_class = (GObjectClass *)klass; object_class = (GObjectClass *)klass;
element_class = (GstElementClass *)klass; element_class = (GstElementClass *)klass;
@ -198,10 +200,15 @@ gst_jack_class_init(GstJackClass *klass)
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;
if (GST_IS_JACK_SINK_CLASS (klass))
prefix = "gst-out-";
else
prefix = "gst-in-";
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PORT_NAME_PREFIX, g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PORT_NAME_PREFIX,
g_param_spec_string("port-name-prefix","Port name prefix", g_param_spec_string("port-name-prefix","Port name prefix",
"String to prepend to jack port names", "String to prepend to jack port names",
"gst-", prefix,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
element_class->change_state = gst_jack_change_state; element_class->change_state = gst_jack_change_state;
@ -230,6 +237,7 @@ gst_jack_request_new_pad (GstElement *element, GstPadTemplate *templ, const gcha
gchar *newname; gchar *newname;
GList *l, **pad_list; GList *l, **pad_list;
GstJackPad *pad; GstJackPad *pad;
gint count;
g_return_val_if_fail ((this = GST_JACK (element)), NULL); g_return_val_if_fail ((this = GST_JACK (element)), NULL);
@ -238,7 +246,7 @@ gst_jack_request_new_pad (GstElement *element, GstPadTemplate *templ, const gcha
else if (this->direction == GST_PAD_SRC) else if (this->direction == GST_PAD_SRC)
pad_list = &this->bin->src_pads; pad_list = &this->bin->src_pads;
else else
pad_list = &this->bin->src_pads; pad_list = &this->bin->sink_pads;
if (name) { if (name) {
l = *pad_list; l = *pad_list;
@ -251,12 +259,22 @@ gst_jack_request_new_pad (GstElement *element, GstPadTemplate *templ, const gcha
} }
newname = g_strdup (name); newname = g_strdup (name);
} else { } else {
newname = g_strdup ("alsa_pcm:out_1"); if (this->direction == GST_PAD_SINK)
newname = g_strdup ("alsa_pcm:out_1");
else
newname = g_strdup ("alsa_pcm:in_1");
} }
pad = g_new0(GstJackPad, 1); pad = g_new0(GstJackPad, 1);
pad->name = g_strdup_printf ("%s%d", this->port_name_prefix, 1); /* fixme :) */ if (!port_name_counts)
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));
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->peer_name = newname; pad->peer_name = newname;
pad->pad = gst_pad_new_from_template (templ, newname); pad->pad = gst_pad_new_from_template (templ, newname);
gst_element_add_pad (GST_ELEMENT (this), pad->pad); gst_element_add_pad (GST_ELEMENT (this), pad->pad);

View file

@ -160,14 +160,14 @@ 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);
g_message ("jack: registering pad %s:%s", pad->name, pad->peer_name); g_message ("jack: registering output port %s (peer %s)", pad->name, pad->peer_name);
pad->port = jack_port_register (this->client, pad->name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput|JackPortIsTerminal, 0); 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);
g_message ("jack: registering pad %s:%s", pad->name, pad->peer_name); g_message ("jack: registering input port %s (peer %s)", pad->name, pad->peer_name);
pad->port = jack_port_register (this->client, pad->name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput|JackPortIsTerminal, 0); 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);
} }
@ -186,7 +186,7 @@ gst_jack_bin_change_state (GstElement *element)
pad = GST_JACK_PAD (l); pad = GST_JACK_PAD (l);
g_message ("connecting gst jack port %s to jack port %s", jack_port_name (pad->port), pad->peer_name); g_message ("connecting gst jack port %s to jack port %s", jack_port_name (pad->port), pad->peer_name);
if (jack_connect (this->client, jack_port_name (pad->port), pad->peer_name)) { if (jack_connect (this->client, jack_port_name (pad->port), pad->peer_name)) {
g_warning ("could not connect %s and %s", pad->peer_name, jack_port_name (pad->port)); g_warning ("jack: 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);
@ -196,7 +196,7 @@ gst_jack_bin_change_state (GstElement *element)
pad = GST_JACK_PAD (l); pad = GST_JACK_PAD (l);
g_message ("connecting gst jack port %s to jack port %s", jack_port_name (pad->port), pad->peer_name); g_message ("connecting gst jack port %s to jack port %s", jack_port_name (pad->port), pad->peer_name);
if (jack_connect (this->client, jack_port_name (pad->port), pad->peer_name)) { if (jack_connect (this->client, jack_port_name (pad->port), pad->peer_name)) {
g_warning ("could not connect %s and %s", pad->peer_name, jack_port_name (pad->port)); g_warning ("jack: 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);