jack: change the transport-mode enum into flags

One can use (or not use) master and slave mode independently.
This commit is contained in:
Stefan Sauer 2012-03-04 19:55:26 +01:00
parent 073a03ef5c
commit 18e8aa48e6
7 changed files with 22 additions and 24 deletions

View file

@ -52,16 +52,14 @@ gst_jack_transport_get_type (void)
static volatile gsize type = 0;
if (g_once_init_enter (&type)) {
static const GEnumValue enum_values[] = {
{GST_JACK_TRANSPORT_AUTONOMOUS,
"No transport support", "autonomous"},
static const GFlagsValue flag_values[] = {
{GST_JACK_TRANSPORT_MASTER,
"Start and stop transport with state changes", "master"},
{GST_JACK_TRANSPORT_SLAVE,
"Follow transport state changes", "slave"},
{0, NULL, NULL},
};
GType tmp = g_enum_register_static ("GstJackTransport", enum_values);
GType tmp = g_flags_register_static ("GstJackTransport", flag_values);
g_once_init_leave (&type, tmp);
}
return (GType) type;

View file

@ -53,9 +53,9 @@ typedef enum {
* client behaviour regarding to the transport mechanism.
*/
typedef enum {
GST_JACK_TRANSPORT_AUTONOMOUS,
GST_JACK_TRANSPORT_MASTER,
GST_JACK_TRANSPORT_SLAVE
GST_JACK_TRANSPORT_AUTONOMOUS = 0,
GST_JACK_TRANSPORT_MASTER = (0 << 1),
GST_JACK_TRANSPORT_SLAVE = (1 << 1),
} GstJackTransport;
typedef jack_default_audio_sample_t sample_t;

View file

@ -88,10 +88,10 @@ static gboolean
jack_handle_transport_change (GstJackAudioClient * client, GstState state)
{
GstObject *obj = GST_OBJECT_PARENT (client->user_data);
GstJackTransport mode;
guint mode;
g_object_get (obj, "transport", &mode, NULL);
if ((mode == GST_JACK_TRANSPORT_SLAVE) && (GST_STATE (obj) != state)) {
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),

View file

@ -560,7 +560,7 @@ gst_jack_ring_buffer_start (GstRingBuffer * buf)
GST_DEBUG_OBJECT (sink, "start");
if (sink->transport == GST_JACK_TRANSPORT_MASTER) {
if (sink->transport & GST_JACK_TRANSPORT_MASTER) {
jack_client_t *client;
client = gst_jack_audio_client_get_client (sink->client);
@ -579,7 +579,7 @@ gst_jack_ring_buffer_pause (GstRingBuffer * buf)
GST_DEBUG_OBJECT (sink, "pause");
if (sink->transport == GST_JACK_TRANSPORT_MASTER) {
if (sink->transport & GST_JACK_TRANSPORT_MASTER) {
jack_client_t *client;
client = gst_jack_audio_client_get_client (sink->client);
@ -598,7 +598,7 @@ gst_jack_ring_buffer_stop (GstRingBuffer * buf)
GST_DEBUG_OBJECT (sink, "stop");
if (sink->transport == GST_JACK_TRANSPORT_MASTER) {
if (sink->transport & GST_JACK_TRANSPORT_MASTER) {
jack_client_t *client;
client = gst_jack_audio_client_get_client (sink->client);
@ -767,7 +767,7 @@ gst_jack_audio_sink_class_init (GstJackAudioSinkClass * klass)
* Since: 0.10.31
*/
g_object_class_install_property (gobject_class, PROP_TRANSPORT,
g_param_spec_enum ("transport", "Transport mode",
g_param_spec_flags ("transport", "Transport mode",
"Jack transport behaviour of the client",
GST_TYPE_JACK_TRANSPORT, DEFAULT_PROP_TRANSPORT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
@ -840,7 +840,7 @@ gst_jack_audio_sink_set_property (GObject * object, guint prop_id,
}
break;
case PROP_TRANSPORT:
sink->transport = g_value_get_enum (value);
sink->transport = g_value_get_flags (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -870,7 +870,7 @@ gst_jack_audio_sink_get_property (GObject * object, guint prop_id,
g_value_set_boxed (value, sink->jclient);
break;
case PROP_TRANSPORT:
g_value_set_enum (value, sink->transport);
g_value_set_flags (value, sink->transport);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);

View file

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

View file

@ -572,7 +572,7 @@ gst_jack_ring_buffer_start (GstRingBuffer * buf)
GST_DEBUG_OBJECT (src, "start");
if (src->transport == GST_JACK_TRANSPORT_MASTER) {
if (src->transport & GST_JACK_TRANSPORT_MASTER) {
jack_client_t *client;
client = gst_jack_audio_client_get_client (src->client);
@ -591,7 +591,7 @@ gst_jack_ring_buffer_pause (GstRingBuffer * buf)
GST_DEBUG_OBJECT (src, "pause");
if (src->transport == GST_JACK_TRANSPORT_MASTER) {
if (src->transport & GST_JACK_TRANSPORT_MASTER) {
jack_client_t *client;
client = gst_jack_audio_client_get_client (src->client);
@ -610,7 +610,7 @@ gst_jack_ring_buffer_stop (GstRingBuffer * buf)
GST_DEBUG_OBJECT (src, "stop");
if (src->transport == GST_JACK_TRANSPORT_MASTER) {
if (src->transport & GST_JACK_TRANSPORT_MASTER) {
jack_client_t *client;
client = gst_jack_audio_client_get_client (src->client);
@ -787,7 +787,7 @@ gst_jack_audio_src_class_init (GstJackAudioSrcClass * klass)
* Since: 0.10.31
*/
g_object_class_install_property (gobject_class, PROP_TRANSPORT,
g_param_spec_enum ("transport", "Transport mode",
g_param_spec_flags ("transport", "Transport mode",
"Jack transport behaviour of the client",
GST_TYPE_JACK_TRANSPORT, DEFAULT_PROP_TRANSPORT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
@ -857,7 +857,7 @@ gst_jack_audio_src_set_property (GObject * object, guint prop_id,
}
break;
case PROP_TRANSPORT:
src->transport = g_value_get_enum (value);
src->transport = g_value_get_flags (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -885,7 +885,7 @@ gst_jack_audio_src_get_property (GObject * object, guint prop_id,
g_value_set_boxed (value, src->jclient);
break;
case PROP_TRANSPORT:
g_value_set_enum (value, src->transport);
g_value_set_flags (value, src->transport);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);

View file

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