mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
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 <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.
This commit is contained in:
parent
a12235aec7
commit
397da5daf0
5 changed files with 106 additions and 9 deletions
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include <pulse/pulseaudio.h>
|
||||
#include <pulse/thread-mainloop.h>
|
||||
|
||||
#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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <pulse/thread-mainloop.h>
|
||||
|
||||
#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
|
||||
|
|
Loading…
Reference in a new issue