summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@users.sf.net>2012-02-07 21:57:47 +0100
committerStefan Sauer <ensonic@users.sf.net>2012-02-07 21:59:29 +0100
commit7a9970fc291c4238ec379a3b08917e53a6c1b55c (patch)
tree6e7872aa480b96f662818b3c8888c37399553f1c /ext
parent32f8a04b5708d92067ffe9e3699cd889b166caf5 (diff)
jack: rework transport support
Move common code to jackclient. There we can also handle the request state message in a better way, as the element callbacks are only run if the element is active.
Diffstat (limited to 'ext')
-rw-r--r--ext/jack/gstjackaudioclient.c45
-rw-r--r--ext/jack/gstjackaudiosink.c12
-rw-r--r--ext/jack/gstjackaudiosrc.c12
3 files changed, 43 insertions, 26 deletions
diff --git a/ext/jack/gstjackaudioclient.c b/ext/jack/gstjackaudioclient.c
index c33949f02..ef544d168 100644
--- a/ext/jack/gstjackaudioclient.c
+++ b/ext/jack/gstjackaudioclient.c
@@ -22,6 +22,7 @@
#include <string.h>
#include "gstjackaudioclient.h"
+#include "gstjack.h"
#include <gst/glib-compat-private.h>
@@ -77,14 +78,29 @@ struct _GstJackAudioClient
gpointer user_data;
};
-typedef jack_default_audio_sample_t sample_t;
-
typedef struct
{
jack_nframes_t nframes;
gpointer user_data;
} JackCB;
+static gboolean
+jack_handle_transport_change (GstJackAudioClient * client, GstState state)
+{
+ GstObject *obj = GST_OBJECT_PARENT (client->user_data);
+ GstJackTransport mode;
+
+ g_object_get (obj, "transport", &mode, NULL);
+ if ((mode == GST_JACK_TRANSPORT_SLAVE) && (GST_STATE (obj) != state)) {
+ GST_INFO_OBJECT (obj, "requesting state change: %s",
+ gst_element_state_get_name (state));
+ gst_element_post_message (GST_ELEMENT (obj),
+ gst_message_new_request_state (obj, state));
+ return TRUE;
+ }
+ return FALSE;
+}
+
static int
jack_process_cb (jack_nframes_t nframes, void *arg)
{
@@ -111,6 +127,8 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
default:
break;
}
+ GST_DEBUG ("num of clients: src=%d, sink=%d",
+ g_list_length (conn->src_clients), g_list_length (conn->sink_clients));
}
g_mutex_lock (conn->lock);
@@ -141,6 +159,27 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
}
}
}
+
+ /* handle transport state requisition, do sinks first, stop after the first
+ * element that handled it */
+ if (conn->transport_state != GST_STATE_VOID_PENDING) {
+ for (walk = conn->sink_clients; walk; walk = g_list_next (walk)) {
+ if (jack_handle_transport_change ((GstJackAudioClient *) walk->data,
+ conn->transport_state)) {
+ conn->transport_state = GST_STATE_VOID_PENDING;
+ break;
+ }
+ }
+ }
+ if (conn->transport_state != GST_STATE_VOID_PENDING) {
+ for (walk = conn->src_clients; walk; walk = g_list_next (walk)) {
+ if (jack_handle_transport_change ((GstJackAudioClient *) walk->data,
+ conn->transport_state)) {
+ conn->transport_state = GST_STATE_VOID_PENDING;
+ break;
+ }
+ }
+ }
g_mutex_unlock (conn->lock);
return res;
}
@@ -259,6 +298,7 @@ gst_jack_audio_make_connection (const gchar * id, const gchar * server,
jack_on_shutdown (jclient, jack_shutdown_cb, conn);
/* all callbacks are set, activate the client */
+ GST_INFO ("activate jack_client %p", jclient);
if ((res = jack_activate (jclient)))
goto could_not_activate;
@@ -353,6 +393,7 @@ gst_jack_audio_unref_connection (GstJackAudioConnection * conn)
* waiting for the JACK thread, and can thus cause deadlock in
* jack_process_cb()
*/
+ GST_INFO ("deactivate jack_client %p", conn->client);
if ((res = jack_deactivate (conn->client))) {
/* we only warn, this means the server is probably shut down and the client
* is gone anyway. */
diff --git a/ext/jack/gstjackaudiosink.c b/ext/jack/gstjackaudiosink.c
index 681671af9..1a7fc28ee 100644
--- a/ext/jack/gstjackaudiosink.c
+++ b/ext/jack/gstjackaudiosink.c
@@ -195,18 +195,6 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
buf = GST_RING_BUFFER_CAST (arg);
sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
- /* handle transport state requisitions */
- if (sink->transport == GST_JACK_TRANSPORT_SLAVE) {
- GstState state = gst_jack_audio_client_get_transport_state (sink->client);
-
- if ((state != GST_STATE_VOID_PENDING) && (GST_STATE (sink) != state)) {
- GST_DEBUG_OBJECT (sink, "requesting state change: %s",
- gst_element_state_get_name (state));
- gst_element_post_message (GST_ELEMENT (sink),
- gst_message_new_request_state (GST_OBJECT (sink), state));
- }
- }
-
channels = buf->spec.channels;
/* get target buffers */
diff --git a/ext/jack/gstjackaudiosrc.c b/ext/jack/gstjackaudiosrc.c
index b85fe40d2..e2b2bc00a 100644
--- a/ext/jack/gstjackaudiosrc.c
+++ b/ext/jack/gstjackaudiosrc.c
@@ -215,18 +215,6 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
buf = GST_RING_BUFFER_CAST (arg);
src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
- /* handle transport state requisitions */
- if (src->transport == GST_JACK_TRANSPORT_SLAVE) {
- GstState state = gst_jack_audio_client_get_transport_state (src->client);
-
- if ((state != GST_STATE_VOID_PENDING) && (GST_STATE (src) != state)) {
- GST_DEBUG_OBJECT (src, "requesting state change: %s",
- gst_element_state_get_name (state));
- gst_element_post_message (GST_ELEMENT (src),
- gst_message_new_request_state (GST_OBJECT (src), state));
- }
- }
-
channels = buf->spec.channels;
/* get input buffers */