+2008-08-13 Sebastian Dröge <sebastian.droege@collabora.co.uk>
+
+ Patch by: Laszlo Pandy <laszlok2 at gmail dot com>
+
+ * 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 <ensonic@users.sf.net>
* gst/spectrum/gstspectrum.c:
# 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)
{
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
pa_threaded_mainloop_free (pulsesink->mainloop);
+ if (pulsesink->probe) {
+ gst_pulseprobe_free (pulsesink->probe);
+ pulsesink->probe = NULL;
+ }
+
G_OBJECT_CLASS (parent_class)->finalize (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:
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",
pulsesink_type = g_type_register_static (GST_TYPE_AUDIO_SINK,
"GstPulseSink", &pulsesink_info, 0);
+
+ gst_pulsesink_init_interfaces (pulsesink_type);
}
return pulsesink_type;
#include <pulse/pulseaudio.h>
#include <pulse/thread-mainloop.h>
+#include "pulseprobe.h"
+
G_BEGIN_DECLS
#define GST_TYPE_PULSESINK \
pa_sample_spec sample_spec;
+ GstPulseProbe *probe;
+
int operation_success;
};
# 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)
if (interface_type == GST_TYPE_MIXER && this->mixer)
return TRUE;
+ if (interface_type == GST_TYPE_PROPERTY_PROBE && this->probe)
+ return TRUE;
+
return FALSE;
}
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
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
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);
}
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:
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;
}
#include <pulse/thread-mainloop.h>
#include "pulsemixerctrl.h"
+#include "pulseprobe.h"
G_BEGIN_DECLS
size_t read_buffer_length;
GstPulseMixerCtrl *mixer;
+ GstPulseProbe *probe;
};
struct _GstPulseSrcClass