mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
ext/pulse/: Use GST_BOILERPLATE everywhere and fix coding style at some places.
Original commit message from CVS: * ext/pulse/pulsemixer.c: (gst_pulsemixer_class_init), (gst_pulsemixer_set_property), (gst_pulsemixer_get_property): * ext/pulse/pulsemixerctrl.c: (gst_pulsemixer_ctrl_subscribe_cb), (gst_pulsemixer_ctrl_open), (gst_pulsemixer_ctrl_timeout_event), (gst_pulsemixer_ctrl_set_volume): * ext/pulse/pulsemixertrack.c: (gst_pulsemixer_track_new): * ext/pulse/pulseprobe.c: (gst_pulseprobe_open): * ext/pulse/pulsesink.c: (gst_pulsesink_class_init), (gst_pulsesink_init), (gst_pulsesink_open), (gst_pulsesink_prepare), (gst_pulsesink_write), (gst_pulsesink_delay), (gst_pulsesink_reset): * ext/pulse/pulsesrc.c: (gst_pulsesrc_class_init), (gst_pulsesrc_init): Use GST_BOILERPLATE everywhere and fix coding style at some places. Fix a locking issue in pulsesink's prepare function. * ext/pulse/pulseutil.c: (gst_pulse_channel_map_to_gst): Check if the created channel layout is valid for GStreamer.
This commit is contained in:
parent
7f88043553
commit
95d4239819
8 changed files with 57 additions and 111 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
|||
2008-08-20 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||
|
||||
* ext/pulse/pulsemixer.c: (gst_pulsemixer_class_init),
|
||||
(gst_pulsemixer_set_property), (gst_pulsemixer_get_property):
|
||||
* ext/pulse/pulsemixerctrl.c: (gst_pulsemixer_ctrl_subscribe_cb),
|
||||
(gst_pulsemixer_ctrl_open), (gst_pulsemixer_ctrl_timeout_event),
|
||||
(gst_pulsemixer_ctrl_set_volume):
|
||||
* ext/pulse/pulsemixertrack.c: (gst_pulsemixer_track_new):
|
||||
* ext/pulse/pulseprobe.c: (gst_pulseprobe_open):
|
||||
* ext/pulse/pulsesink.c: (gst_pulsesink_class_init),
|
||||
(gst_pulsesink_init), (gst_pulsesink_open),
|
||||
(gst_pulsesink_prepare), (gst_pulsesink_write),
|
||||
(gst_pulsesink_delay), (gst_pulsesink_reset):
|
||||
* ext/pulse/pulsesrc.c: (gst_pulsesrc_class_init),
|
||||
(gst_pulsesrc_init):
|
||||
Use GST_BOILERPLATE everywhere and fix coding style at some places.
|
||||
Fix a locking issue in pulsesink's prepare function.
|
||||
|
||||
* ext/pulse/pulseutil.c: (gst_pulse_channel_map_to_gst):
|
||||
Check if the created channel layout is valid for GStreamer.
|
||||
|
||||
2008-08-20 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||
|
||||
* gst/rtsp/gstrtspgoogle.c:
|
||||
|
|
|
@ -134,7 +134,6 @@ static void
|
|||
gst_pulsemixer_class_init (GstPulseMixerClass * g_class)
|
||||
{
|
||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
|
||||
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
|
||||
|
||||
gstelement_class->change_state =
|
||||
|
@ -200,7 +199,6 @@ static void
|
|||
gst_pulsemixer_set_property (GObject * object,
|
||||
guint prop_id, const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
|
||||
GstPulseMixer *this = GST_PULSEMIXER (object);
|
||||
|
||||
switch (prop_id) {
|
||||
|
@ -228,11 +226,9 @@ static void
|
|||
gst_pulsemixer_get_property (GObject * object,
|
||||
guint prop_id, GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
|
||||
GstPulseMixer *this = GST_PULSEMIXER (object);
|
||||
|
||||
switch (prop_id) {
|
||||
|
||||
case PROP_SERVER:
|
||||
g_value_set_string (value, this->server);
|
||||
break;
|
||||
|
@ -242,7 +238,6 @@ gst_pulsemixer_get_property (GObject * object,
|
|||
break;
|
||||
|
||||
case PROP_DEVICE_NAME:
|
||||
|
||||
if (this->mixer) {
|
||||
char *t = g_strdup_printf ("%s: %s",
|
||||
this->mixer->type == GST_PULSEMIXER_SINK ? "Playback" : "Capture",
|
||||
|
|
|
@ -157,7 +157,6 @@ gst_pulsemixer_ctrl_subscribe_cb (pa_context * context,
|
|||
pa_subscription_event_type_t t, uint32_t idx, void *userdata)
|
||||
{
|
||||
GstPulseMixerCtrl *c = GST_PULSEMIXER_CTRL (userdata);
|
||||
|
||||
pa_operation *o = NULL;
|
||||
|
||||
/* Called from the background thread! */
|
||||
|
@ -207,9 +206,7 @@ static gboolean
|
|||
gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c)
|
||||
{
|
||||
int e;
|
||||
|
||||
gchar *name = gst_pulse_client_name ();
|
||||
|
||||
pa_operation *o = NULL;
|
||||
|
||||
g_assert (c);
|
||||
|
@ -442,7 +439,6 @@ gst_pulsemixer_ctrl_timeout_event (pa_mainloop_api * a, pa_time_event * e,
|
|||
const struct timeval *tv, void *userdata)
|
||||
{
|
||||
pa_operation *o;
|
||||
|
||||
GstPulseMixerCtrl *c = GST_PULSEMIXER_CTRL (userdata);
|
||||
|
||||
if (c->update_volume) {
|
||||
|
@ -516,7 +512,6 @@ gst_pulsemixer_ctrl_set_volume (GstPulseMixerCtrl * c, GstMixerTrack * track,
|
|||
gint * volumes)
|
||||
{
|
||||
pa_cvolume v;
|
||||
|
||||
int i;
|
||||
|
||||
g_assert (c);
|
||||
|
|
|
@ -47,7 +47,6 @@ GstMixerTrack *
|
|||
gst_pulsemixer_track_new (GstPulseMixerCtrl * control)
|
||||
{
|
||||
GstPulseMixerTrack *pulsetrack;
|
||||
|
||||
GstMixerTrack *track;
|
||||
|
||||
pulsetrack = g_object_new (GST_TYPE_PULSEMIXER_TRACK, NULL);
|
||||
|
|
|
@ -99,7 +99,6 @@ static gboolean
|
|||
gst_pulseprobe_open (GstPulseProbe * c)
|
||||
{
|
||||
int e;
|
||||
|
||||
gchar *name = gst_pulse_client_name ();
|
||||
|
||||
g_assert (c);
|
||||
|
|
|
@ -69,8 +69,6 @@ enum
|
|||
PROP_VOLUME
|
||||
};
|
||||
|
||||
static GstAudioSinkClass *parent_class = NULL;
|
||||
|
||||
static void gst_pulsesink_destroy_stream (GstPulseSink * pulsesink);
|
||||
|
||||
static void gst_pulsesink_destroy_context (GstPulseSink * pulsesink);
|
||||
|
@ -102,6 +100,8 @@ static gboolean gst_pulsesink_event (GstBaseSink * sink, GstEvent * event);
|
|||
static GstStateChangeReturn gst_pulsesink_change_state (GstElement *
|
||||
element, GstStateChange transition);
|
||||
|
||||
static void gst_pulsesink_init_interfaces (GType type);
|
||||
|
||||
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
|
||||
# define ENDIANNESS "LITTLE_ENDIAN, BIG_ENDIAN"
|
||||
#else
|
||||
|
@ -109,6 +109,8 @@ static GstStateChangeReturn gst_pulsesink_change_state (GstElement *
|
|||
#endif
|
||||
|
||||
GST_IMPLEMENT_PULSEPROBE_METHODS (GstPulseSink, gst_pulsesink);
|
||||
GST_BOILERPLATE_FULL (GstPulseSink, gst_pulsesink, GstAudioSink,
|
||||
GST_TYPE_AUDIO_SINK, gst_pulsesink_init_interfaces);
|
||||
|
||||
static gboolean
|
||||
gst_pulsesink_interface_supported (GstImplementsInterface *
|
||||
|
@ -197,15 +199,12 @@ gst_pulsesink_base_init (gpointer g_class)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_pulsesink_class_init (gpointer g_class, gpointer class_data)
|
||||
gst_pulsesink_class_init (GstPulseSinkClass * klass)
|
||||
{
|
||||
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
|
||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
|
||||
GstBaseSinkClass *gstbasesink_class = GST_BASE_SINK_CLASS (g_class);
|
||||
GstAudioSinkClass *gstaudiosink_class = GST_AUDIO_SINK_CLASS (g_class);
|
||||
|
||||
parent_class = g_type_class_peek_parent (g_class);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
||||
GstBaseSinkClass *gstbasesink_class = GST_BASE_SINK_CLASS (klass);
|
||||
GstAudioSinkClass *gstaudiosink_class = GST_AUDIO_SINK_CLASS (klass);
|
||||
|
||||
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_pulsesink_dispose);
|
||||
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_pulsesink_finalize);
|
||||
|
@ -250,11 +249,8 @@ gst_pulsesink_class_init (gpointer g_class, gpointer class_data)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_pulsesink_init (GTypeInstance * instance, gpointer g_class)
|
||||
gst_pulsesink_init (GstPulseSink * pulsesink, GstPulseSinkClass * klass)
|
||||
{
|
||||
|
||||
GstPulseSink *pulsesink = GST_PULSESINK (instance);
|
||||
|
||||
int e;
|
||||
|
||||
pulsesink->server = pulsesink->device = pulsesink->stream_name = NULL;
|
||||
|
@ -510,7 +506,6 @@ static gboolean
|
|||
gst_pulsesink_open (GstAudioSink * asink)
|
||||
{
|
||||
GstPulseSink *pulsesink = GST_PULSESINK (asink);
|
||||
|
||||
gchar *name = gst_pulse_client_name ();
|
||||
|
||||
pa_threaded_mainloop_lock (pulsesink->mainloop);
|
||||
|
@ -568,15 +563,13 @@ static gboolean
|
|||
gst_pulsesink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec)
|
||||
{
|
||||
pa_buffer_attr buf_attr;
|
||||
|
||||
pa_channel_map channel_map;
|
||||
|
||||
GstPulseSink *pulsesink = GST_PULSESINK (asink);
|
||||
|
||||
if (!gst_pulse_fill_sample_spec (spec, &pulsesink->sample_spec)) {
|
||||
GST_ELEMENT_ERROR (pulsesink, RESOURCE, SETTINGS,
|
||||
("Invalid sample specification."), (NULL));
|
||||
goto unlock_and_fail;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pa_threaded_mainloop_lock (pulsesink->mainloop);
|
||||
|
@ -584,14 +577,16 @@ 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",
|
||||
|
@ -641,8 +636,9 @@ gst_pulsesink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec)
|
|||
return TRUE;
|
||||
|
||||
unlock_and_fail:
|
||||
|
||||
pa_threaded_mainloop_unlock (pulsesink->mainloop);
|
||||
|
||||
fail:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -669,7 +665,6 @@ static guint
|
|||
gst_pulsesink_write (GstAudioSink * asink, gpointer data, guint length)
|
||||
{
|
||||
GstPulseSink *pulsesink = GST_PULSESINK (asink);
|
||||
|
||||
size_t sum = 0;
|
||||
|
||||
pa_threaded_mainloop_lock (pulsesink->mainloop);
|
||||
|
@ -724,7 +719,6 @@ static guint
|
|||
gst_pulsesink_delay (GstAudioSink * asink)
|
||||
{
|
||||
GstPulseSink *pulsesink = GST_PULSESINK (asink);
|
||||
|
||||
pa_usec_t t;
|
||||
|
||||
pa_threaded_mainloop_lock (pulsesink->mainloop);
|
||||
|
@ -768,7 +762,6 @@ static void
|
|||
gst_pulsesink_reset (GstAudioSink * asink)
|
||||
{
|
||||
GstPulseSink *pulsesink = GST_PULSESINK (asink);
|
||||
|
||||
pa_operation *o = NULL;
|
||||
|
||||
pa_threaded_mainloop_lock (pulsesink->mainloop);
|
||||
|
@ -926,31 +919,3 @@ gst_pulsesink_change_state (GstElement * element, GstStateChange transition)
|
|||
|
||||
return GST_STATE_CHANGE_SUCCESS;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_pulsesink_get_type (void)
|
||||
{
|
||||
static GType pulsesink_type = 0;
|
||||
|
||||
if (!pulsesink_type) {
|
||||
|
||||
static const GTypeInfo pulsesink_info = {
|
||||
sizeof (GstPulseSinkClass),
|
||||
gst_pulsesink_base_init,
|
||||
NULL,
|
||||
gst_pulsesink_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GstPulseSink),
|
||||
0,
|
||||
gst_pulsesink_init,
|
||||
};
|
||||
|
||||
pulsesink_type = g_type_register_static (GST_TYPE_AUDIO_SINK,
|
||||
"GstPulseSink", &pulsesink_info, 0);
|
||||
|
||||
gst_pulsesink_init_interfaces (pulsesink_type);
|
||||
}
|
||||
|
||||
return pulsesink_type;
|
||||
}
|
||||
|
|
|
@ -62,10 +62,6 @@ enum
|
|||
PROP_DEVICE_NAME
|
||||
};
|
||||
|
||||
static GstAudioSrcClass *parent_class = NULL;
|
||||
|
||||
GST_IMPLEMENT_PULSEMIXER_CTRL_METHODS (GstPulseSrc, gst_pulsesrc);
|
||||
|
||||
static void gst_pulsesrc_destroy_stream (GstPulseSrc * pulsesrc);
|
||||
|
||||
static void gst_pulsesrc_destroy_context (GstPulseSrc * pulsesrc);
|
||||
|
@ -96,13 +92,18 @@ static gboolean gst_pulsesrc_negotiate (GstBaseSrc * basesrc);
|
|||
static GstStateChangeReturn gst_pulsesrc_change_state (GstElement *
|
||||
element, GstStateChange transition);
|
||||
|
||||
static void gst_pulsesrc_init_interfaces (GType type);
|
||||
|
||||
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
|
||||
# define ENDIANNESS "LITTLE_ENDIAN, BIG_ENDIAN"
|
||||
#else
|
||||
# define ENDIANNESS "BIG_ENDIAN, LITTLE_ENDIAN"
|
||||
#endif
|
||||
|
||||
GST_IMPLEMENT_PULSEMIXER_CTRL_METHODS (GstPulseSrc, gst_pulsesrc);
|
||||
GST_IMPLEMENT_PULSEPROBE_METHODS (GstPulseSrc, gst_pulsesrc);
|
||||
GST_BOILERPLATE_FULL (GstPulseSrc, gst_pulsesrc, GstAudioSrc,
|
||||
GST_TYPE_AUDIO_SRC, gst_pulsesrc_init_interfaces);
|
||||
|
||||
static gboolean
|
||||
gst_pulsesrc_interface_supported (GstImplementsInterface *
|
||||
|
@ -201,14 +202,12 @@ gst_pulsesrc_base_init (gpointer g_class)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_pulsesrc_class_init (gpointer g_class, gpointer class_data)
|
||||
gst_pulsesrc_class_init (GstPulseSrcClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
|
||||
GstAudioSrcClass *gstaudiosrc_class = GST_AUDIO_SRC_CLASS (g_class);
|
||||
GstBaseSrcClass *gstbasesrc_class = GST_BASE_SRC_CLASS (g_class);
|
||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
|
||||
|
||||
parent_class = g_type_class_peek_parent (g_class);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GstAudioSrcClass *gstaudiosrc_class = GST_AUDIO_SRC_CLASS (klass);
|
||||
GstBaseSrcClass *gstbasesrc_class = GST_BASE_SRC_CLASS (klass);
|
||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
gstelement_class->change_state =
|
||||
GST_DEBUG_FUNCPTR (gst_pulsesrc_change_state);
|
||||
|
@ -246,11 +245,8 @@ gst_pulsesrc_class_init (gpointer g_class, gpointer class_data)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_pulsesrc_init (GTypeInstance * instance, gpointer g_class)
|
||||
gst_pulsesrc_init (GstPulseSrc * pulsesrc, GstPulseSrcClass * klass)
|
||||
{
|
||||
|
||||
GstPulseSrc *pulsesrc = GST_PULSESRC (instance);
|
||||
|
||||
int e;
|
||||
|
||||
pulsesrc->server = pulsesrc->device = NULL;
|
||||
|
@ -653,8 +649,9 @@ gst_pulsesrc_create_stream (GstPulseSrc * pulsesrc, GstCaps * caps)
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -845,31 +842,3 @@ gst_pulsesrc_change_state (GstElement * element, GstStateChange transition)
|
|||
|
||||
return GST_STATE_CHANGE_SUCCESS;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_pulsesrc_get_type (void)
|
||||
{
|
||||
static GType pulsesrc_type = 0;
|
||||
|
||||
if (!pulsesrc_type) {
|
||||
|
||||
static const GTypeInfo pulsesrc_info = {
|
||||
sizeof (GstPulseSrcClass),
|
||||
gst_pulsesrc_base_init,
|
||||
NULL,
|
||||
gst_pulsesrc_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GstPulseSrc),
|
||||
0,
|
||||
gst_pulsesrc_init,
|
||||
};
|
||||
|
||||
pulsesrc_type = g_type_register_static (GST_TYPE_AUDIO_SRC,
|
||||
"GstPulseSrc", &pulsesrc_info, 0);
|
||||
|
||||
gst_pulsesrc_init_interfaces (pulsesrc_type);
|
||||
}
|
||||
|
||||
return pulsesrc_type;
|
||||
}
|
||||
|
|
|
@ -186,6 +186,9 @@ gst_pulse_channel_map_to_gst (const pa_channel_map * map,
|
|||
}
|
||||
}
|
||||
|
||||
if (!invalid && !gst_audio_check_channel_positions (pos, spec->channels))
|
||||
invalid = TRUE;
|
||||
|
||||
if (invalid) {
|
||||
for (i = 0; i < spec->channels; i++)
|
||||
pos[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
|
||||
|
|
Loading…
Reference in a new issue