From 397da5daf007694488c8558471a59d7c58feb2ad Mon Sep 17 00:00:00 2001 From: Laszlo Pandy Date: Wed, 13 Aug 2008 12:01:01 +0000 Subject: [PATCH] ext/pulse/: Implement GstPropertyProbe interface on pulsesink for detecting sink devices and on pulsesrc for detectin... Original commit message from CVS: Patch by: Laszlo Pandy * ext/pulse/pulsesink.c: (gst_pulsesink_interface_supported), (gst_pulsesink_implements_interface_init), (gst_pulsesink_init_interfaces), (gst_pulsesink_init), (gst_pulsesink_finalize), (gst_pulsesink_set_property), (gst_pulsesink_get_type): * ext/pulse/pulsesink.h: * ext/pulse/pulsesrc.c: (gst_pulsesrc_interface_supported), (gst_pulsesrc_init_interfaces), (gst_pulsesrc_init), (gst_pulsesrc_finalize), (gst_pulsesrc_set_property): * ext/pulse/pulsesrc.h: Implement GstPropertyProbe interface on pulsesink for detecting sink devices and on pulsesrc for detecting source devices. Fixes bugs #547227 and #547217. --- ChangeLog | 18 +++++++++++++ ext/pulse/pulsesink.c | 63 ++++++++++++++++++++++++++++++++++++++----- ext/pulse/pulsesink.h | 4 +++ ext/pulse/pulsesrc.c | 28 ++++++++++++++++--- ext/pulse/pulsesrc.h | 2 ++ 5 files changed, 106 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 406a68638b..c17c62509c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2008-08-13 Sebastian Dröge + + Patch by: Laszlo Pandy + + * ext/pulse/pulsesink.c: (gst_pulsesink_interface_supported), + (gst_pulsesink_implements_interface_init), + (gst_pulsesink_init_interfaces), (gst_pulsesink_init), + (gst_pulsesink_finalize), (gst_pulsesink_set_property), + (gst_pulsesink_get_type): + * ext/pulse/pulsesink.h: + * ext/pulse/pulsesrc.c: (gst_pulsesrc_interface_supported), + (gst_pulsesrc_init_interfaces), (gst_pulsesrc_init), + (gst_pulsesrc_finalize), (gst_pulsesrc_set_property): + * ext/pulse/pulsesrc.h: + Implement GstPropertyProbe interface on pulsesink for detecting + sink devices and on pulsesrc for detecting source devices. + Fixes bugs #547227 and #547217. + 2008-08-13 Stefan Kost * gst/spectrum/gstspectrum.c: diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c index 432c39be24..b22f52d2fb 100644 --- a/ext/pulse/pulsesink.c +++ b/ext/pulse/pulsesink.c @@ -103,6 +103,46 @@ static gboolean gst_pulsesink_event (GstBaseSink * sink, GstEvent * event); # define ENDIANNESS "BIG_ENDIAN, LITTLE_ENDIAN" #endif +GST_IMPLEMENT_PULSEPROBE_METHODS (GstPulseSink, gst_pulsesink); + +static gboolean +gst_pulsesink_interface_supported (GstImplementsInterface * + iface, GType interface_type) +{ + GstPulseSink *this = GST_PULSESINK (iface); + + if (interface_type == GST_TYPE_PROPERTY_PROBE && this->probe) + return TRUE; + + return FALSE; +} + +static void +gst_pulsesink_implements_interface_init (GstImplementsInterfaceClass * klass) +{ + klass->supported = gst_pulsesink_interface_supported; +} + +static void +gst_pulsesink_init_interfaces (GType type) +{ + static const GInterfaceInfo implements_iface_info = { + (GInterfaceInitFunc) gst_pulsesink_implements_interface_init, + NULL, + NULL, + }; + static const GInterfaceInfo probe_iface_info = { + (GInterfaceInitFunc) gst_pulsesink_property_probe_interface_init, + NULL, + NULL, + }; + + g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE, + &implements_iface_info); + g_type_add_interface_static (type, GST_TYPE_PROPERTY_PROBE, + &probe_iface_info); +} + static void gst_pulsesink_base_init (gpointer g_class) { @@ -208,6 +248,8 @@ gst_pulsesink_init (GTypeInstance * instance, gpointer g_class) e = pa_threaded_mainloop_start (pulsesink->mainloop); g_assert (e == 0); + + pulsesink->probe = gst_pulseprobe_new (G_OBJECT_GET_CLASS (pulsesink), PROP_DEVICE, pulsesink->device, TRUE, FALSE); /* TRUE for sinks, FALSE for sources */ } static void @@ -251,6 +293,11 @@ gst_pulsesink_finalize (GObject * object) pa_threaded_mainloop_free (pulsesink->mainloop); + if (pulsesink->probe) { + gst_pulseprobe_free (pulsesink->probe); + pulsesink->probe = NULL; + } + G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -270,6 +317,10 @@ gst_pulsesink_set_property (GObject * object, case PROP_SERVER: g_free (pulsesink->server); pulsesink->server = g_value_dup_string (value); + + if (pulsesink->probe) + gst_pulseprobe_set_server (pulsesink->probe, pulsesink->server); + break; case PROP_DEVICE: @@ -438,16 +489,14 @@ gst_pulsesink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec) if (!pulsesink->context || pa_context_get_state (pulsesink->context) != PA_CONTEXT_READY) { GST_ELEMENT_ERROR (pulsesink, RESOURCE, FAILED, ("Bad context state: %s", - pulsesink-> - context ? pa_strerror (pa_context_errno (pulsesink->context)) : - NULL), (NULL)); + pulsesink->context ? pa_strerror (pa_context_errno (pulsesink-> + context)) : NULL), (NULL)); goto unlock_and_fail; } if (!(pulsesink->stream = pa_stream_new (pulsesink->context, - pulsesink-> - stream_name ? pulsesink->stream_name : "Playback Stream", - &pulsesink->sample_spec, + pulsesink->stream_name ? pulsesink-> + stream_name : "Playback Stream", &pulsesink->sample_spec, gst_pulse_gst_to_channel_map (&channel_map, spec)))) { GST_ELEMENT_ERROR (pulsesink, RESOURCE, FAILED, ("Failed to create stream: %s", @@ -766,6 +815,8 @@ gst_pulsesink_get_type (void) pulsesink_type = g_type_register_static (GST_TYPE_AUDIO_SINK, "GstPulseSink", &pulsesink_info, 0); + + gst_pulsesink_init_interfaces (pulsesink_type); } return pulsesink_type; diff --git a/ext/pulse/pulsesink.h b/ext/pulse/pulsesink.h index d7a3b78148..3ea57adc8e 100644 --- a/ext/pulse/pulsesink.h +++ b/ext/pulse/pulsesink.h @@ -28,6 +28,8 @@ #include #include +#include "pulseprobe.h" + G_BEGIN_DECLS #define GST_TYPE_PULSESINK \ @@ -57,6 +59,8 @@ struct _GstPulseSink pa_sample_spec sample_spec; + GstPulseProbe *probe; + int operation_success; }; diff --git a/ext/pulse/pulsesrc.c b/ext/pulse/pulsesrc.c index af76fdff45..e270c43005 100644 --- a/ext/pulse/pulsesrc.c +++ b/ext/pulse/pulsesrc.c @@ -98,6 +98,8 @@ static GstStateChangeReturn gst_pulsesrc_change_state (GstElement * # define ENDIANNESS "BIG_ENDIAN, LITTLE_ENDIAN" #endif +GST_IMPLEMENT_PULSEPROBE_METHODS (GstPulseSrc, gst_pulsesrc); + static gboolean gst_pulsesrc_interface_supported (GstImplementsInterface * iface, GType interface_type) @@ -107,6 +109,9 @@ gst_pulsesrc_interface_supported (GstImplementsInterface * if (interface_type == GST_TYPE_MIXER && this->mixer) return TRUE; + if (interface_type == GST_TYPE_PROPERTY_PROBE && this->probe) + return TRUE; + return FALSE; } @@ -129,10 +134,17 @@ gst_pulsesrc_init_interfaces (GType type) NULL, NULL, }; + static const GInterfaceInfo probe_iface_info = { + (GInterfaceInitFunc) gst_pulsesrc_property_probe_interface_init, + NULL, + NULL, + }; g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE, &implements_iface_info); g_type_add_interface_static (type, GST_TYPE_MIXER, &mixer_iface_info); + g_type_add_interface_static (type, GST_TYPE_PROPERTY_PROBE, + &probe_iface_info); } static void @@ -246,6 +258,8 @@ gst_pulsesrc_init (GTypeInstance * instance, gpointer g_class) g_assert (e == 0); pulsesrc->mixer = NULL; + + pulsesrc->probe = gst_pulseprobe_new (G_OBJECT_GET_CLASS (pulsesrc), PROP_DEVICE, pulsesrc->device, FALSE, TRUE); /* FALSE for sinks, TRUE for sources */ } static void @@ -288,6 +302,11 @@ gst_pulsesrc_finalize (GObject * object) if (pulsesrc->mixer) gst_pulsemixer_ctrl_free (pulsesrc->mixer); + if (pulsesrc->probe) { + gst_pulseprobe_free (pulsesrc->probe); + pulsesrc->probe = NULL; + } + G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -308,6 +327,10 @@ gst_pulsesrc_set_property (GObject * object, case PROP_SERVER: g_free (pulsesrc->server); pulsesrc->server = g_value_dup_string (value); + + if (pulsesrc->probe) + gst_pulseprobe_set_server (pulsesrc->probe, pulsesrc->server); + break; case PROP_DEVICE: @@ -470,9 +493,8 @@ gst_pulsesrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec) if (!pulsesrc->context || pa_context_get_state (pulsesrc->context) != PA_CONTEXT_READY) { GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED, ("Bad context state: %s", - pulsesrc-> - context ? pa_strerror (pa_context_errno (pulsesrc->context)) : - NULL), (NULL)); + pulsesrc->context ? pa_strerror (pa_context_errno (pulsesrc-> + context)) : NULL), (NULL)); goto unlock_and_fail; } diff --git a/ext/pulse/pulsesrc.h b/ext/pulse/pulsesrc.h index 408a1588b9..b07bfe2638 100644 --- a/ext/pulse/pulsesrc.h +++ b/ext/pulse/pulsesrc.h @@ -29,6 +29,7 @@ #include #include "pulsemixerctrl.h" +#include "pulseprobe.h" G_BEGIN_DECLS @@ -63,6 +64,7 @@ struct _GstPulseSrc size_t read_buffer_length; GstPulseMixerCtrl *mixer; + GstPulseProbe *probe; }; struct _GstPulseSrcClass -- 2.34.1