jack: Add property port-pattern to specify which JACK ports to connect to

https://bugzilla.gnome.org/show_bug.cgi?id=690719
This commit is contained in:
hark 2015-02-17 12:20:57 +01:00 committed by Sebastian Dröge
parent 6798dc7912
commit b1098c2ea5
4 changed files with 70 additions and 7 deletions

View file

@ -458,8 +458,13 @@ gst_jack_ring_buffer_acquire (GstAudioRingBuffer * buf,
/* find all the physical input ports. A physical input port is a port
* associated with a hardware device. Someone needs connect to a physical
* port in order to hear something. */
ports = jack_get_ports (client, NULL, NULL,
JackPortIsPhysical | JackPortIsInput);
if (sink->port_pattern == NULL) {
ports = jack_get_ports (client, NULL, NULL,
JackPortIsPhysical | JackPortIsInput);
} else {
ports = jack_get_ports (client, sink->port_pattern, NULL,
JackPortIsInput);
}
if (ports == NULL) {
/* no ports? fine then we don't do anything except for posting a warning
* message. */
@ -675,6 +680,7 @@ enum
#define DEFAULT_PROP_CONNECT GST_JACK_CONNECT_AUTO
#define DEFAULT_PROP_SERVER NULL
#define DEFAULT_PROP_CLIENT_NAME NULL
#define DEFAULT_PROP_PORT_PATTERN NULL
#define DEFAULT_PROP_TRANSPORT GST_JACK_TRANSPORT_AUTONOMOUS
enum
@ -684,6 +690,7 @@ enum
PROP_SERVER,
PROP_CLIENT,
PROP_CLIENT_NAME,
PROP_PORT_PATTERN,
PROP_TRANSPORT,
PROP_LAST
};
@ -750,6 +757,19 @@ gst_jack_audio_sink_class_init (GstJackAudioSinkClass * klass)
GST_PARAM_MUTABLE_READY | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* GstJackAudioSink:port-pattern
*
* autoconnect to ports matching pattern, when NULL connect to physical ports
*
* Since: 1.6
*/
g_object_class_install_property (gobject_class, PROP_PORT_PATTERN,
g_param_spec_string ("port-pattern", "port pattern",
"A pattern to select which ports to connect to (NULL = first physical ports)",
DEFAULT_PROP_PORT_PATTERN,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstJackAudioSink:transport:
*
@ -805,6 +825,11 @@ gst_jack_audio_sink_dispose (GObject * object)
sink->client_name = NULL;
}
if (sink->port_pattern != NULL) {
g_free (sink->port_pattern);
sink->port_pattern = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@ -821,6 +846,10 @@ gst_jack_audio_sink_set_property (GObject * object, guint prop_id,
g_free (sink->client_name);
sink->client_name = g_value_dup_string (value);
break;
case PROP_PORT_PATTERN:
g_free (sink->port_pattern);
sink->port_pattern = g_value_dup_string (value);
break;
case PROP_CONNECT:
sink->connect = g_value_get_enum (value);
break;
@ -855,6 +884,9 @@ gst_jack_audio_sink_get_property (GObject * object, guint prop_id,
case PROP_CLIENT_NAME:
g_value_set_string (value, sink->client_name);
break;
case PROP_PORT_PATTERN:
g_value_set_string (value, sink->port_pattern);
break;
case PROP_CONNECT:
g_value_set_enum (value, sink->connect);
break;

View file

@ -59,6 +59,7 @@ struct _GstJackAudioSink {
gchar *server;
jack_client_t *jclient;
gchar *client_name;
gchar *port_pattern;
guint transport;
/* our client */

View file

@ -469,9 +469,15 @@ gst_jack_ring_buffer_acquire (GstAudioRingBuffer * buf,
/* find all the physical output ports. A physical output port is a port
* associated with a hardware device. Someone needs connect to a physical
* port in order to capture something. */
ports =
jack_get_ports (client, NULL, NULL,
JackPortIsPhysical | JackPortIsOutput);
if (src->port_pattern == NULL) {
ports = jack_get_ports (client, NULL, NULL,
JackPortIsPhysical | JackPortIsOutput);
} else {
ports = jack_get_ports (client, src->port_pattern, NULL,
JackPortIsOutput);
}
if (ports == NULL) {
/* no ports? fine then we don't do anything except for posting a warning
* message. */
@ -680,7 +686,7 @@ enum
#define DEFAULT_PROP_SERVER NULL
#define DEFAULT_PROP_CLIENT_NAME NULL
#define DEFAULT_PROP_TRANSPORT GST_JACK_TRANSPORT_AUTONOMOUS
#define DEFAULT_PROP_PORT_PATTERN NULL
enum
{
PROP_0,
@ -688,11 +694,11 @@ enum
PROP_SERVER,
PROP_CLIENT,
PROP_CLIENT_NAME,
PROP_PORT_PATTERN,
PROP_TRANSPORT,
PROP_LAST
};
/* the capabilities of the inputs and outputs.
*
* describe the real formats here.
@ -771,6 +777,18 @@ gst_jack_audio_src_class_init (GstJackAudioSrcClass * klass)
GST_TYPE_JACK_CLIENT,
GST_PARAM_MUTABLE_READY | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* GstJackAudioSrc:port-pattern
*
* autoconnect to ports matching pattern, when NULL connect to physical ports
*
* Since: 1.6
*/
g_object_class_install_property (gobject_class, PROP_PORT_PATTERN,
g_param_spec_string ("port-pattern", "port pattern",
"A pattern to select which ports to connect to (NULL = first physical ports)",
DEFAULT_PROP_PORT_PATTERN,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstJackAudioSink:transport:
@ -828,6 +846,11 @@ gst_jack_audio_src_dispose (GObject * object)
src->client_name = NULL;
}
if (src->port_pattern != NULL) {
g_free (src->port_pattern);
src->port_pattern = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@ -842,6 +865,10 @@ gst_jack_audio_src_set_property (GObject * object, guint prop_id,
g_free (src->client_name);
src->client_name = g_value_dup_string (value);
break;
case PROP_PORT_PATTERN:
g_free (src->port_pattern);
src->port_pattern = g_value_dup_string (value);
break;
case PROP_CONNECT:
src->connect = g_value_get_enum (value);
break;
@ -874,6 +901,8 @@ gst_jack_audio_src_get_property (GObject * object, guint prop_id,
case PROP_CLIENT_NAME:
g_value_set_string (value, src->client_name);
break;
case PROP_PORT_PATTERN:
g_value_set_string (value, src->port_pattern);
case PROP_CONNECT:
g_value_set_enum (value, src->connect);
break;

View file

@ -76,6 +76,7 @@ struct _GstJackAudioSrc
gchar *server;
jack_client_t *jclient;
gchar *client_name;
gchar *port_pattern;
guint transport;
/* our client */