Commit c070cfa7 authored by Tristan Matthews's avatar Tristan Matthews Committed by Tim-Philipp Müller

jack: added client property

parent a110fe33
......@@ -46,6 +46,35 @@ gst_jack_connect_get_type (void)
}
static gpointer
gst_jack_client_copy (gpointer jclient)
{
return jclient;
}
static void
gst_jack_client_free (gpointer jclient)
{
return;
}
GType
gst_jack_client_get_type (void)
{
static GType type; /* 0 */
if (type == 0) {
/* hackish, but makes it show up nicely in gst-inspect */
type = g_boxed_type_register_static ("JackClient",
(GBoxedCopyFunc) gst_jack_client_copy,
(GBoxedFreeFunc) gst_jack_client_free);
}
return type;
}
static gboolean
plugin_init (GstPlugin * plugin)
{
......
......@@ -47,6 +47,9 @@ typedef enum {
typedef jack_default_audio_sample_t sample_t;
#define GST_TYPE_JACK_CONNECT (gst_jack_connect_get_type())
#define GST_TYPE_JACK_CLIENT (gst_jack_client_get_type ())
GType gst_jack_client_get_type(void);
GType gst_jack_connect_get_type(void);
#endif // _GST_JACK_H_
......@@ -189,11 +189,10 @@ connection_find (GstJackAudioConnection * conn, FindData * data)
* status set. */
static GstJackAudioConnection *
gst_jack_audio_make_connection (const gchar * id, const gchar * server,
jack_status_t * status)
jack_client_t * jclient, jack_status_t * status)
{
GstJackAudioConnection *conn;
jack_options_t options;
jack_client_t *jclient;
gint res;
*status = 0;
......@@ -207,7 +206,8 @@ gst_jack_audio_make_connection (const gchar * id, const gchar * server,
if (server != NULL)
options |= JackServerName;
/* open the client */
jclient = jack_client_open (id, options, status, server);
if (jclient == NULL)
jclient = jack_client_open (id, options, status, server);
if (jclient == NULL)
goto could_not_open;
......@@ -258,7 +258,7 @@ could_not_activate:
static GstJackAudioConnection *
gst_jack_audio_get_connection (const gchar * id, const gchar * server,
jack_status_t * status)
jack_client_t * jclient, jack_status_t * status)
{
GstJackAudioConnection *conn;
GList *found;
......@@ -273,7 +273,7 @@ gst_jack_audio_get_connection (const gchar * id, const gchar * server,
G_LOCK (connections_lock);
found =
g_list_find_custom (connections, &data, (GCompareFunc) connection_find);
if (found != NULL) {
if (found != NULL && jclient != NULL) {
/* we found it, increase refcount and return it */
conn = (GstJackAudioConnection *) found->data;
conn->refcount++;
......@@ -281,7 +281,7 @@ gst_jack_audio_get_connection (const gchar * id, const gchar * server,
GST_DEBUG ("found connection %p", conn);
} else {
/* make new connection */
conn = gst_jack_audio_make_connection (id, server, status);
conn = gst_jack_audio_make_connection (id, server, jclient, status);
if (conn != NULL) {
GST_DEBUG ("created connection %p", conn);
/* add to list on success */
......@@ -407,10 +407,10 @@ gst_jack_audio_connection_remove_client (GstJackAudioConnection * conn,
*/
GstJackAudioClient *
gst_jack_audio_client_new (const gchar * id, const gchar * server,
GstJackClientType type, void (*shutdown) (void *arg),
JackProcessCallback process, JackBufferSizeCallback buffer_size,
JackSampleRateCallback sample_rate, gpointer user_data,
jack_status_t * status)
jack_client_t * jclient, GstJackClientType type,
void (*shutdown) (void *arg), JackProcessCallback process,
JackBufferSizeCallback buffer_size, JackSampleRateCallback sample_rate,
gpointer user_data, jack_status_t * status)
{
GstJackAudioClient *client;
GstJackAudioConnection *conn;
......@@ -419,7 +419,7 @@ gst_jack_audio_client_new (const gchar * id, const gchar * server,
g_return_val_if_fail (status != NULL, NULL);
/* first get a connection for the id/server pair */
conn = gst_jack_audio_get_connection (id, server, status);
conn = gst_jack_audio_get_connection (id, server, jclient, status);
if (conn == NULL)
goto no_connection;
......
......@@ -40,6 +40,7 @@ void gst_jack_audio_client_init (void);
GstJackAudioClient * gst_jack_audio_client_new (const gchar *id, const gchar *server,
jack_client_t *jclient,
GstJackClientType type,
void (*shutdown) (void *arg),
JackProcessCallback process,
......
......@@ -334,6 +334,7 @@ gst_jack_ring_buffer_open_device (GstRingBuffer * buf)
name = "GStreamer";
sink->client = gst_jack_audio_client_new (name, sink->server,
sink->jclient,
GST_JACK_CLIENT_SINK,
jack_shutdown_cb,
jack_process_cb, jack_buffer_size_cb, jack_sample_rate_cb, buf, &status);
......@@ -627,6 +628,7 @@ enum
PROP_0,
PROP_CONNECT,
PROP_SERVER,
PROP_CLIENT,
PROP_LAST
};
......@@ -685,6 +687,12 @@ gst_jack_audio_sink_class_init (GstJackAudioSinkClass * klass)
"The Jack server to connect to (NULL = default)",
DEFAULT_PROP_SERVER, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CLIENT,
g_param_spec_boxed ("client", "JackClient", "Handle for jack client",
GST_TYPE_JACK_CLIENT,
GST_PARAM_MUTABLE_READY | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_jack_audio_sink_getcaps);
gstbaseaudiosink_class->create_ringbuffer =
......@@ -703,6 +711,7 @@ gst_jack_audio_sink_init (GstJackAudioSink * sink,
{
sink->connect = DEFAULT_PROP_CONNECT;
sink->server = g_strdup (DEFAULT_PROP_SERVER);
sink->jclient = NULL;
sink->ports = NULL;
sink->port_count = 0;
}
......@@ -732,6 +741,12 @@ gst_jack_audio_sink_set_property (GObject * object, guint prop_id,
g_free (sink->server);
sink->server = g_value_dup_string (value);
break;
case PROP_CLIENT:
if (GST_STATE (sink) == GST_STATE_NULL ||
GST_STATE (sink) == GST_STATE_READY) {
sink->jclient = g_value_get_boxed (value);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -753,6 +768,9 @@ gst_jack_audio_sink_get_property (GObject * object, guint prop_id,
case PROP_SERVER:
g_value_set_string (value, sink->server);
break;
case PROP_CLIENT:
g_value_set_boxed (value, sink->jclient);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......
......@@ -57,6 +57,7 @@ struct _GstJackAudioSink {
/* properties */
GstJackConnect connect;
gchar *server;
jack_client_t *jclient;
/* our client */
GstJackAudioClient *client;
......
......@@ -341,6 +341,7 @@ gst_jack_ring_buffer_open_device (GstRingBuffer * buf)
name = "GStreamer";
src->client = gst_jack_audio_client_new (name, src->server,
src->jclient,
GST_JACK_CLIENT_SOURCE,
jack_shutdown_cb,
jack_process_cb, jack_buffer_size_cb, jack_sample_rate_cb, buf, &status);
......@@ -629,6 +630,7 @@ enum
PROP_0,
PROP_CONNECT,
PROP_SERVER,
PROP_CLIENT,
PROP_LAST
};
......@@ -707,6 +709,12 @@ gst_jack_audio_src_class_init (GstJackAudioSrcClass * klass)
"The Jack server to connect to (NULL = default)",
DEFAULT_PROP_SERVER, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CLIENT,
g_param_spec_boxed ("client", "JackClient", "Handle for jack client",
GST_TYPE_JACK_CLIENT,
GST_PARAM_MUTABLE_READY | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
gstbasesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_jack_audio_src_getcaps);
gstbaseaudiosrc_class->create_ringbuffer =
GST_DEBUG_FUNCPTR (gst_jack_audio_src_create_ringbuffer);
......@@ -729,6 +737,7 @@ gst_jack_audio_src_init (GstJackAudioSrc * src, GstJackAudioSrcClass * gclass)
//gst_base_src_set_live(GST_BASE_SRC (src), TRUE);
src->connect = DEFAULT_PROP_CONNECT;
src->server = g_strdup (DEFAULT_PROP_SERVER);
src->jclient = NULL;
src->ports = NULL;
src->port_count = 0;
src->buffers = NULL;
......@@ -757,6 +766,12 @@ gst_jack_audio_src_set_property (GObject * object, guint prop_id,
g_free (src->server);
src->server = g_value_dup_string (value);
break;
case PROP_CLIENT:
if (GST_STATE (src) == GST_STATE_NULL ||
GST_STATE (src) == GST_STATE_READY) {
src->jclient = g_value_get_boxed (value);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -776,6 +791,9 @@ gst_jack_audio_src_get_property (GObject * object, guint prop_id,
case PROP_SERVER:
g_value_set_string (value, src->server);
break;
case PROP_CLIENT:
g_value_set_boxed (value, src->jclient);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......
......@@ -74,6 +74,7 @@ struct _GstJackAudioSrc
/* properties */
GstJackConnect connect;
gchar *server;
jack_client_t *jclient;
/* our client */
GstJackAudioClient *client;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment