add "client" property

* ext/pulse/pulsesrc.c (gst_pulsesrc_class_init, gst_pulsesrc_init)
  (gst_pulsesrc_set_property, gst_pulsesrc_get_property)
  (gst_pulsesrc_open): Add a "client" property, as in pulsesink.

Fixes #634914
This commit is contained in:
Andy Wingo 2010-11-15 15:58:28 +01:00 committed by Wim Taymans
parent 96830324a5
commit 82ee35372b
2 changed files with 31 additions and 6 deletions

View file

@ -61,6 +61,7 @@ enum
PROP_SERVER, PROP_SERVER,
PROP_DEVICE, PROP_DEVICE,
PROP_DEVICE_NAME, PROP_DEVICE_NAME,
PROP_CLIENT,
PROP_STREAM_PROPERTIES, PROP_STREAM_PROPERTIES,
PROP_LAST PROP_LAST
}; };
@ -246,6 +247,20 @@ gst_pulsesrc_class_init (GstPulseSrcClass * klass)
"Human-readable name of the sound device", DEFAULT_DEVICE_NAME, "Human-readable name of the sound device", DEFAULT_DEVICE_NAME,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* GstPulseSink:client
*
* The PulseAudio client name to use.
*
* Since: 0.10.27
*/
g_object_class_install_property (gobject_class,
PROP_CLIENT,
g_param_spec_string ("client", "Client",
"The PulseAudio client_name_to_use", gst_pulse_client_name (),
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
GST_PARAM_MUTABLE_READY));
/** /**
* GstPulseSrc:stream-properties * GstPulseSrc:stream-properties
* *
@ -275,6 +290,7 @@ gst_pulsesrc_init (GstPulseSrc * pulsesrc, GstPulseSrcClass * klass)
{ {
pulsesrc->server = NULL; pulsesrc->server = NULL;
pulsesrc->device = NULL; pulsesrc->device = NULL;
pulsesrc->client_name = gst_pulse_client_name ();
pulsesrc->device_description = NULL; pulsesrc->device_description = NULL;
pulsesrc->context = NULL; pulsesrc->context = NULL;
@ -340,6 +356,7 @@ gst_pulsesrc_finalize (GObject * object)
g_free (pulsesrc->server); g_free (pulsesrc->server);
g_free (pulsesrc->device); g_free (pulsesrc->device);
g_free (pulsesrc->client_name);
if (pulsesrc->properties) if (pulsesrc->properties)
gst_structure_free (pulsesrc->properties); gst_structure_free (pulsesrc->properties);
@ -463,6 +480,15 @@ gst_pulsesrc_set_property (GObject * object,
g_free (pulsesrc->device); g_free (pulsesrc->device);
pulsesrc->device = g_value_dup_string (value); pulsesrc->device = g_value_dup_string (value);
break; break;
case PROP_CLIENT:
g_free (pulsesrc->client_name);
if (!g_value_get_string (value)) {
GST_WARNING_OBJECT (pulsesrc,
"Empty PulseAudio client name not allowed. Resetting to default value");
pulsesrc->client_name = gst_pulse_client_name ();
} else
pulsesrc->client_name = g_value_dup_string (value);
break;
case PROP_STREAM_PROPERTIES: case PROP_STREAM_PROPERTIES:
if (pulsesrc->properties) if (pulsesrc->properties)
gst_structure_free (pulsesrc->properties); gst_structure_free (pulsesrc->properties);
@ -495,6 +521,9 @@ gst_pulsesrc_get_property (GObject * object,
case PROP_DEVICE_NAME: case PROP_DEVICE_NAME:
g_value_take_string (value, gst_pulsesrc_device_description (pulsesrc)); g_value_take_string (value, gst_pulsesrc_device_description (pulsesrc));
break; break;
case PROP_CLIENT:
g_value_set_string (value, pulsesrc->client_name);
break;
case PROP_STREAM_PROPERTIES: case PROP_STREAM_PROPERTIES:
gst_value_set_structure (value, pulsesrc->properties); gst_value_set_structure (value, pulsesrc->properties);
break; break;
@ -599,7 +628,6 @@ static gboolean
gst_pulsesrc_open (GstAudioSrc * asrc) gst_pulsesrc_open (GstAudioSrc * asrc)
{ {
GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (asrc); GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (asrc);
gchar *name = gst_pulse_client_name ();
pa_threaded_mainloop_lock (pulsesrc->mainloop); pa_threaded_mainloop_lock (pulsesrc->mainloop);
@ -610,7 +638,7 @@ gst_pulsesrc_open (GstAudioSrc * asrc)
if (!(pulsesrc->context = if (!(pulsesrc->context =
pa_context_new (pa_threaded_mainloop_get_api (pulsesrc->mainloop), pa_context_new (pa_threaded_mainloop_get_api (pulsesrc->mainloop),
name))) { pulsesrc->client_name))) {
GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED, ("Failed to create context"), GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED, ("Failed to create context"),
(NULL)); (NULL));
goto unlock_and_fail; goto unlock_and_fail;
@ -649,7 +677,6 @@ gst_pulsesrc_open (GstAudioSrc * asrc)
pa_threaded_mainloop_unlock (pulsesrc->mainloop); pa_threaded_mainloop_unlock (pulsesrc->mainloop);
g_free (name);
return TRUE; return TRUE;
/* ERRORS */ /* ERRORS */
@ -659,7 +686,6 @@ unlock_and_fail:
pa_threaded_mainloop_unlock (pulsesrc->mainloop); pa_threaded_mainloop_unlock (pulsesrc->mainloop);
g_free (name);
return FALSE; return FALSE;
} }
} }

View file

@ -55,7 +55,7 @@ struct _GstPulseSrc
{ {
GstAudioSrc src; GstAudioSrc src;
gchar *server, *device; gchar *server, *device, *client_name;
pa_threaded_mainloop *mainloop; pa_threaded_mainloop *mainloop;
@ -68,7 +68,6 @@ struct _GstPulseSrc
size_t read_buffer_length; size_t read_buffer_length;
gchar *device_description; gchar *device_description;
GstPulseMixerCtrl *mixer; GstPulseMixerCtrl *mixer;
GstPulseProbe *probe; GstPulseProbe *probe;