pulseaudio: require pulseaudio >= 1.0

This commit is contained in:
Tim-Philipp Müller 2011-11-26 13:54:22 +00:00
parent be0d6baac5
commit eeaa9e0bbc
9 changed files with 7 additions and 150 deletions

View file

@ -806,15 +806,7 @@ AG_GST_CHECK_FEATURE(PULSE, [pulseaudio plug-in], pulseaudio, [
dnl used in ext/pulse/pulseutil.c dnl used in ext/pulse/pulseutil.c
AC_CHECK_HEADERS([process.h]) AC_CHECK_HEADERS([process.h])
AG_GST_PKG_CHECK_MODULES(PULSE, libpulse >= 0.9.16) AG_GST_PKG_CHECK_MODULES(PULSE, libpulse >= 1.0)
AG_GST_PKG_CHECK_MODULES(PULSE_0_9_20, libpulse >= 0.9.20)
if test x$HAVE_PULSE_0_9_20 = xyes; then
AC_DEFINE(HAVE_PULSE_0_9_20, 1, [defined if pulseaudio >= 0.9.20 is available])
fi
AG_GST_PKG_CHECK_MODULES(PULSE_1_0, libpulse >= 0.98)
if test x$HAVE_PULSE_1_0 = xyes; then
AC_DEFINE(HAVE_PULSE_1_0, 1, [defined if pulseaudio >= 1.0 is available])
fi
]) ])
dnl *** dv1394 *** dnl *** dv1394 ***

View file

@ -49,11 +49,11 @@ plugin_init (GstPlugin * plugin)
GST_TYPE_PULSESRC)) GST_TYPE_PULSESRC))
return FALSE; return FALSE;
#ifdef HAVE_PULSE_1_0 /* FIXME 0.11: this helper bin sink should just go away, reconfiguration
* should be handled using reconfigure events */
if (!gst_element_register (plugin, "pulseaudiosink", GST_RANK_PRIMARY + 11, if (!gst_element_register (plugin, "pulseaudiosink", GST_RANK_PRIMARY + 11,
GST_TYPE_PULSE_AUDIO_SINK)) GST_TYPE_PULSE_AUDIO_SINK))
return FALSE; return FALSE;
#endif
if (!gst_element_register (plugin, "pulsemixer", GST_RANK_NONE, if (!gst_element_register (plugin, "pulsemixer", GST_RANK_NONE,
GST_TYPE_PULSEMIXER)) GST_TYPE_PULSEMIXER))

View file

@ -49,7 +49,7 @@
#include "config.h" #include "config.h"
#endif #endif
#ifdef HAVE_PULSE_1_0 /* FIXME 0.11: pulseaudiosink helper bin must die */
#include <gst/pbutils/pbutils.h> #include <gst/pbutils/pbutils.h>
#include <gst/gst-i18n-plugin.h> #include <gst/gst-i18n-plugin.h>
@ -958,5 +958,3 @@ gst_pulse_audio_sink_change_state (GstElement * element,
out: out:
return ret; return ret;
} }
#endif /* HAVE_PULSE_1_0 */

View file

@ -139,13 +139,9 @@ struct _GstPulseRingBuffer
pa_context *context; pa_context *context;
pa_stream *stream; pa_stream *stream;
#ifdef HAVE_PULSE_1_0
pa_format_info *format; pa_format_info *format;
guint channels; guint channels;
gboolean is_pcm; gboolean is_pcm;
#else
pa_sample_spec sample_spec;
#endif
void *m_data; void *m_data;
size_t m_towrite; size_t m_towrite;
@ -230,13 +226,9 @@ gst_pulseringbuffer_init (GstPulseRingBuffer * pbuf)
pbuf->context = NULL; pbuf->context = NULL;
pbuf->stream = NULL; pbuf->stream = NULL;
#ifdef HAVE_PULSE_1_0
pbuf->format = NULL; pbuf->format = NULL;
pbuf->channels = 0; pbuf->channels = 0;
pbuf->is_pcm = FALSE; pbuf->is_pcm = FALSE;
#else
pa_sample_spec_init (&pbuf->sample_spec);
#endif
pbuf->m_data = NULL; pbuf->m_data = NULL;
pbuf->m_towrite = 0; pbuf->m_towrite = 0;
@ -265,14 +257,12 @@ gst_pulsering_destroy_stream (GstPulseRingBuffer * pbuf)
pbuf->m_offset = 0; pbuf->m_offset = 0;
pbuf->m_lastoffset = 0; pbuf->m_lastoffset = 0;
} }
#ifdef HAVE_PULSE_1_0
if (pbuf->format) { if (pbuf->format) {
pa_format_info_free (pbuf->format); pa_format_info_free (pbuf->format);
pbuf->format = NULL; pbuf->format = NULL;
pbuf->channels = 0; pbuf->channels = 0;
pbuf->is_pcm = FALSE; pbuf->is_pcm = FALSE;
} }
#endif
pa_stream_disconnect (pbuf->stream); pa_stream_disconnect (pbuf->stream);
@ -424,7 +414,6 @@ gst_pulsering_context_subscribe_cb (pa_context * c,
if (idx != pa_stream_get_index (pbuf->stream)) if (idx != pa_stream_get_index (pbuf->stream))
continue; continue;
#ifdef HAVE_PULSE_1_0
if (psink->device && pbuf->is_pcm && if (psink->device && pbuf->is_pcm &&
!g_str_equal (psink->device, !g_str_equal (psink->device,
pa_stream_get_device_name (pbuf->stream))) { pa_stream_get_device_name (pbuf->stream))) {
@ -443,7 +432,6 @@ gst_pulsering_context_subscribe_cb (pa_context * c,
if (!gst_pad_push_event (GST_BASE_SINK (psink)->sinkpad, renego)) if (!gst_pad_push_event (GST_BASE_SINK (psink)->sinkpad, renego))
GST_DEBUG_OBJECT (psink, "Emitted sink-changed - nobody was listening"); GST_DEBUG_OBJECT (psink, "Emitted sink-changed - nobody was listening");
} }
#endif
/* Actually this event is also triggered when other properties of /* Actually this event is also triggered when other properties of
* the stream change that are unrelated to the volume. However it is * the stream change that are unrelated to the volume. However it is
@ -738,7 +726,6 @@ gst_pulsering_stream_event_cb (pa_stream * p, const char *name,
gst_element_post_message (GST_ELEMENT_CAST (psink), gst_element_post_message (GST_ELEMENT_CAST (psink),
gst_message_new_request_state (GST_OBJECT_CAST (psink), gst_message_new_request_state (GST_OBJECT_CAST (psink),
GST_STATE_PLAYING)); GST_STATE_PLAYING));
#ifdef HAVE_PULSE_1_0
} else if (!strcmp (name, PA_STREAM_EVENT_FORMAT_LOST)) { } else if (!strcmp (name, PA_STREAM_EVENT_FORMAT_LOST)) {
GstEvent *renego; GstEvent *renego;
@ -763,7 +750,6 @@ gst_pulsering_stream_event_cb (pa_stream * p, const char *name,
GST_ELEMENT_ERROR (psink, STREAM, FORMAT, ("Sink format changed"), GST_ELEMENT_ERROR (psink, STREAM, FORMAT, ("Sink format changed"),
("Sink format changed")); ("Sink format changed"));
} }
#endif
} else { } else {
GST_DEBUG_OBJECT (psink, "got unknown event %s", name); GST_DEBUG_OBJECT (psink, "got unknown event %s", name);
} }
@ -804,18 +790,14 @@ gst_pulseringbuffer_acquire (GstAudioRingBuffer * buf,
const pa_buffer_attr *actual; const pa_buffer_attr *actual;
pa_channel_map channel_map; pa_channel_map channel_map;
pa_operation *o = NULL; pa_operation *o = NULL;
#ifdef HAVE_PULSE_0_9_20
pa_cvolume v; pa_cvolume v;
#endif
pa_cvolume *pv = NULL; pa_cvolume *pv = NULL;
pa_stream_flags_t flags; pa_stream_flags_t flags;
const gchar *name; const gchar *name;
GstAudioClock *clock; GstAudioClock *clock;
#ifdef HAVE_PULSE_1_0
pa_format_info *formats[1]; pa_format_info *formats[1];
#ifndef GST_DISABLE_GST_DEBUG #ifndef GST_DISABLE_GST_DEBUG
gchar print_buf[PA_FORMAT_INFO_SNPRINT_MAX]; gchar print_buf[PA_FORMAT_INFO_SNPRINT_MAX];
#endif
#endif #endif
psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (buf)); psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (buf));
@ -823,14 +805,9 @@ gst_pulseringbuffer_acquire (GstAudioRingBuffer * buf,
GST_LOG_OBJECT (psink, "creating sample spec"); GST_LOG_OBJECT (psink, "creating sample spec");
/* convert the gstreamer sample spec to the pulseaudio format */ /* convert the gstreamer sample spec to the pulseaudio format */
#ifdef HAVE_PULSE_1_0
if (!gst_pulse_fill_format_info (spec, &pbuf->format, &pbuf->channels)) if (!gst_pulse_fill_format_info (spec, &pbuf->format, &pbuf->channels))
goto invalid_spec; goto invalid_spec;
pbuf->is_pcm = pa_format_info_is_pcm (pbuf->format); pbuf->is_pcm = pa_format_info_is_pcm (pbuf->format);
#else
if (!gst_pulse_fill_sample_spec (spec, &pbuf->sample_spec))
goto invalid_spec;
#endif
pa_threaded_mainloop_lock (mainloop); pa_threaded_mainloop_lock (mainloop);
@ -847,12 +824,8 @@ gst_pulseringbuffer_acquire (GstAudioRingBuffer * buf,
pa_operation_unref (o); pa_operation_unref (o);
/* initialize the channel map */ /* initialize the channel map */
#ifdef HAVE_PULSE_1_0
if (pbuf->is_pcm && gst_pulse_gst_to_channel_map (&channel_map, spec)) if (pbuf->is_pcm && gst_pulse_gst_to_channel_map (&channel_map, spec))
pa_format_info_set_channel_map (pbuf->format, &channel_map); pa_format_info_set_channel_map (pbuf->format, &channel_map);
#else
gst_pulse_gst_to_channel_map (&channel_map, spec);
#endif
/* find a good name for the stream */ /* find a good name for the stream */
if (psink->stream_name) if (psink->stream_name)
@ -861,17 +834,10 @@ gst_pulseringbuffer_acquire (GstAudioRingBuffer * buf,
name = "Playback Stream"; name = "Playback Stream";
/* create a stream */ /* create a stream */
#ifdef HAVE_PULSE_1_0
formats[0] = pbuf->format; formats[0] = pbuf->format;
if (!(pbuf->stream = pa_stream_new_extended (pbuf->context, name, formats, 1, if (!(pbuf->stream = pa_stream_new_extended (pbuf->context, name, formats, 1,
psink->proplist))) psink->proplist)))
goto stream_failed; goto stream_failed;
#else
GST_LOG_OBJECT (psink, "creating stream with name %s", name);
if (!(pbuf->stream = pa_stream_new_with_proplist (pbuf->context, name,
&pbuf->sample_spec, &channel_map, psink->proplist)))
goto stream_failed;
#endif
/* install essential callbacks */ /* install essential callbacks */
pa_stream_set_state_callback (pbuf->stream, pa_stream_set_state_callback (pbuf->stream,
@ -904,26 +870,19 @@ gst_pulseringbuffer_acquire (GstAudioRingBuffer * buf,
GST_INFO_OBJECT (psink, "prebuf: %d", wanted.prebuf); GST_INFO_OBJECT (psink, "prebuf: %d", wanted.prebuf);
GST_INFO_OBJECT (psink, "minreq: %d", wanted.minreq); GST_INFO_OBJECT (psink, "minreq: %d", wanted.minreq);
#ifdef HAVE_PULSE_0_9_20
/* configure volume when we changed it, else we leave the default */ /* configure volume when we changed it, else we leave the default */
if (psink->volume_set) { if (psink->volume_set) {
GST_LOG_OBJECT (psink, "have volume of %f", psink->volume); GST_LOG_OBJECT (psink, "have volume of %f", psink->volume);
pv = &v; pv = &v;
#ifdef HAVE_PULSE_1_0
if (pbuf->is_pcm) if (pbuf->is_pcm)
gst_pulse_cvolume_from_linear (pv, pbuf->channels, psink->volume); gst_pulse_cvolume_from_linear (pv, pbuf->channels, psink->volume);
else { else {
GST_DEBUG_OBJECT (psink, "passthrough stream, not setting volume"); GST_DEBUG_OBJECT (psink, "passthrough stream, not setting volume");
pv = NULL; pv = NULL;
} }
#else
gst_pulse_cvolume_from_linear (pv, pbuf->sample_spec.channels,
psink->volume);
#endif
} else { } else {
pv = NULL; pv = NULL;
} }
#endif
/* construct the flags */ /* construct the flags */
flags = PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE | flags = PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE |
@ -949,7 +908,6 @@ gst_pulseringbuffer_acquire (GstAudioRingBuffer * buf,
if (!gst_pulsering_wait_for_stream_ready (psink, pbuf->stream)) if (!gst_pulsering_wait_for_stream_ready (psink, pbuf->stream))
goto connect_failed; goto connect_failed;
#ifdef HAVE_PULSE_1_0
g_free (psink->device); g_free (psink->device);
psink->device = g_strdup (pa_stream_get_device_name (pbuf->stream)); psink->device = g_strdup (pa_stream_get_device_name (pbuf->stream));
@ -957,7 +915,6 @@ gst_pulseringbuffer_acquire (GstAudioRingBuffer * buf,
pa_format_info_snprint (print_buf, sizeof (print_buf), pa_format_info_snprint (print_buf, sizeof (print_buf),
pa_stream_get_format_info (pbuf->stream)); pa_stream_get_format_info (pbuf->stream));
GST_INFO_OBJECT (psink, "negotiated to: %s", print_buf); GST_INFO_OBJECT (psink, "negotiated to: %s", print_buf);
#endif
#endif #endif
/* After we passed the volume off of to PA we never want to set it /* After we passed the volume off of to PA we never want to set it
@ -1032,7 +989,6 @@ gst_pulseringbuffer_release (GstAudioRingBuffer * buf)
gst_pulsering_destroy_stream (pbuf); gst_pulsering_destroy_stream (pbuf);
pa_threaded_mainloop_unlock (mainloop); pa_threaded_mainloop_unlock (mainloop);
#ifdef HAVE_PULSE_1_0
{ {
GstPulseSink *psink; GstPulseSink *psink;
@ -1040,7 +996,6 @@ gst_pulseringbuffer_release (GstAudioRingBuffer * buf)
g_atomic_int_set (&psink->format_lost, FALSE); g_atomic_int_set (&psink->format_lost, FALSE);
psink->format_lost_time = GST_CLOCK_TIME_NONE; psink->format_lost_time = GST_CLOCK_TIME_NONE;
} }
#endif
return TRUE; return TRUE;
} }
@ -1063,12 +1018,10 @@ gst_pulsering_set_corked (GstPulseRingBuffer * pbuf, gboolean corked,
psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf)); psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf));
#ifdef HAVE_PULSE_1_0
if (g_atomic_int_get (&psink->format_lost)) { if (g_atomic_int_get (&psink->format_lost)) {
/* Sink format changed, stream's gone so fake being paused */ /* Sink format changed, stream's gone so fake being paused */
return TRUE; return TRUE;
} }
#endif
GST_DEBUG_OBJECT (psink, "setting corked state to %d", corked); GST_DEBUG_OBJECT (psink, "setting corked state to %d", corked);
if (pbuf->corked != corked) { if (pbuf->corked != corked) {
@ -1251,13 +1204,11 @@ gst_pulseringbuffer_stop (GstAudioRingBuffer * buf)
GST_DEBUG_OBJECT (psink, "signal commit thread"); GST_DEBUG_OBJECT (psink, "signal commit thread");
pa_threaded_mainloop_signal (mainloop, 0); pa_threaded_mainloop_signal (mainloop, 0);
} }
#ifdef HAVE_PULSE_1_0
if (g_atomic_int_get (&psink->format_lost)) { if (g_atomic_int_get (&psink->format_lost)) {
/* Don't try to flush, the stream's probably gone by now */ /* Don't try to flush, the stream's probably gone by now */
res = TRUE; res = TRUE;
goto cleanup; goto cleanup;
} }
#endif
/* then try to flush, it's not fatal when this fails */ /* then try to flush, it's not fatal when this fails */
GST_DEBUG_OBJECT (psink, "flushing"); GST_DEBUG_OBJECT (psink, "flushing");
@ -1428,12 +1379,10 @@ gst_pulseringbuffer_commit (GstAudioRingBuffer * buf, guint64 * sample,
* needed to properly handle reverse playback: it points to the last sample. */ * needed to properly handle reverse playback: it points to the last sample. */
data_end = data + (bpf * inr); data_end = data + (bpf * inr);
#ifdef HAVE_PULSE_1_0
if (g_atomic_int_get (&psink->format_lost)) { if (g_atomic_int_get (&psink->format_lost)) {
/* Sink format changed, drop the data and hope upstream renegotiates */ /* Sink format changed, drop the data and hope upstream renegotiates */
goto fake_done; goto fake_done;
} }
#endif
if (pbuf->paused) if (pbuf->paused)
goto was_paused; goto was_paused;
@ -1482,12 +1431,10 @@ gst_pulseringbuffer_commit (GstAudioRingBuffer * buf, guint64 * sample,
for (;;) { for (;;) {
pbuf->m_writable = pa_stream_writable_size (pbuf->stream); pbuf->m_writable = pa_stream_writable_size (pbuf->stream);
#ifdef HAVE_PULSE_1_0
if (g_atomic_int_get (&psink->format_lost)) { if (g_atomic_int_get (&psink->format_lost)) {
/* Sink format changed, give up and hope upstream renegotiates */ /* Sink format changed, give up and hope upstream renegotiates */
goto fake_done; goto fake_done;
} }
#endif
if (pbuf->m_writable == (size_t) - 1) if (pbuf->m_writable == (size_t) - 1)
goto writable_size_failed; goto writable_size_failed;
@ -1538,13 +1485,11 @@ gst_pulseringbuffer_commit (GstAudioRingBuffer * buf, guint64 * sample,
GST_LOG_OBJECT (psink, "writing %u samples at offset %" G_GUINT64_FORMAT, GST_LOG_OBJECT (psink, "writing %u samples at offset %" G_GUINT64_FORMAT,
(guint) avail, offset); (guint) avail, offset);
#ifdef HAVE_PULSE_1_0
/* No trick modes for passthrough streams */ /* No trick modes for passthrough streams */
if (G_UNLIKELY (!pbuf->is_pcm && (inr != outr || reverse))) { if (G_UNLIKELY (!pbuf->is_pcm && (inr != outr || reverse))) {
GST_WARNING_OBJECT (psink, "Passthrough stream can't run in trick mode"); GST_WARNING_OBJECT (psink, "Passthrough stream can't run in trick mode");
goto unlock_and_fail; goto unlock_and_fail;
} }
#endif
if (G_LIKELY (inr == outr && !reverse)) { if (G_LIKELY (inr == outr && !reverse)) {
/* no rate conversion, simply write out the samples */ /* no rate conversion, simply write out the samples */
@ -1626,9 +1571,7 @@ gst_pulseringbuffer_commit (GstAudioRingBuffer * buf, guint64 * sample,
} }
} }
#ifdef HAVE_PULSE_1_0
fake_done: fake_done:
#endif
/* we consumed all samples here */ /* we consumed all samples here */
data = data_end + bpf; data = data_end + bpf;
@ -1931,13 +1874,11 @@ gst_pulsesink_get_time (GstClock * clock, GstAudioBaseSink * sink)
pbuf = GST_PULSERING_BUFFER_CAST (sink->ringbuffer); pbuf = GST_PULSERING_BUFFER_CAST (sink->ringbuffer);
psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf)); psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf));
#ifdef HAVE_PULSE_1_0
if (g_atomic_int_get (&psink->format_lost)) { if (g_atomic_int_get (&psink->format_lost)) {
/* Stream was lost in a format change, it'll get set up again once /* Stream was lost in a format change, it'll get set up again once
* upstream renegotiates */ * upstream renegotiates */
return psink->format_lost_time; return psink->format_lost_time;
} }
#endif
pa_threaded_mainloop_lock (mainloop); pa_threaded_mainloop_lock (mainloop);
if (gst_pulsering_is_dead (psink, pbuf, TRUE)) if (gst_pulsering_is_dead (psink, pbuf, TRUE))
@ -1973,10 +1914,8 @@ gst_pulsesink_sink_info_cb (pa_context * c, const pa_sink_info * i, int eol,
{ {
GstPulseRingBuffer *pbuf; GstPulseRingBuffer *pbuf;
GstPulseSink *psink; GstPulseSink *psink;
#ifdef HAVE_PULSE_1_0
GList *l; GList *l;
guint8 j; guint8 j;
#endif
pbuf = GST_PULSERING_BUFFER_CAST (userdata); pbuf = GST_PULSERING_BUFFER_CAST (userdata);
psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf)); psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf));
@ -1987,7 +1926,6 @@ gst_pulsesink_sink_info_cb (pa_context * c, const pa_sink_info * i, int eol,
g_free (psink->device_description); g_free (psink->device_description);
psink->device_description = g_strdup (i->description); psink->device_description = g_strdup (i->description);
#ifdef HAVE_PULSE_1_0
g_mutex_lock (psink->sink_formats_lock); g_mutex_lock (psink->sink_formats_lock);
for (l = g_list_first (psink->sink_formats); l; l = g_list_next (l)) for (l = g_list_first (psink->sink_formats); l; l = g_list_next (l))
@ -2001,13 +1939,11 @@ gst_pulsesink_sink_info_cb (pa_context * c, const pa_sink_info * i, int eol,
pa_format_info_copy (i->formats[j])); pa_format_info_copy (i->formats[j]));
g_mutex_unlock (psink->sink_formats_lock); g_mutex_unlock (psink->sink_formats_lock);
#endif
done: done:
pa_threaded_mainloop_signal (mainloop, 0); pa_threaded_mainloop_signal (mainloop, 0);
} }
#ifdef HAVE_PULSE_1_0
/* NOTE: If you're making changes here, see if pulseaudiosink acceptcaps also /* NOTE: If you're making changes here, see if pulseaudiosink acceptcaps also
* needs to be changed accordingly. */ * needs to be changed accordingly. */
static gboolean static gboolean
@ -2139,7 +2075,6 @@ info_failed:
goto out; goto out;
} }
} }
#endif
static void static void
gst_pulsesink_init (GstPulseSink * pulsesink) gst_pulsesink_init (GstPulseSink * pulsesink)
@ -2149,10 +2084,8 @@ gst_pulsesink_init (GstPulseSink * pulsesink)
pulsesink->device_description = NULL; pulsesink->device_description = NULL;
pulsesink->client_name = gst_pulse_client_name (); pulsesink->client_name = gst_pulse_client_name ();
#ifdef HAVE_PULSE_1_0
pulsesink->sink_formats_lock = g_mutex_new (); pulsesink->sink_formats_lock = g_mutex_new ();
pulsesink->sink_formats = NULL; pulsesink->sink_formats = NULL;
#endif
pulsesink->volume = DEFAULT_VOLUME; pulsesink->volume = DEFAULT_VOLUME;
pulsesink->volume_set = FALSE; pulsesink->volume_set = FALSE;
@ -2162,10 +2095,8 @@ gst_pulsesink_init (GstPulseSink * pulsesink)
pulsesink->notify = 0; pulsesink->notify = 0;
#ifdef HAVE_PULSE_1_0
g_atomic_int_set (&pulsesink->format_lost, FALSE); g_atomic_int_set (&pulsesink->format_lost, FALSE);
pulsesink->format_lost_time = GST_CLOCK_TIME_NONE; pulsesink->format_lost_time = GST_CLOCK_TIME_NONE;
#endif
pulsesink->properties = NULL; pulsesink->properties = NULL;
pulsesink->proplist = NULL; pulsesink->proplist = NULL;
@ -2188,22 +2119,18 @@ static void
gst_pulsesink_finalize (GObject * object) gst_pulsesink_finalize (GObject * object)
{ {
GstPulseSink *pulsesink = GST_PULSESINK_CAST (object); GstPulseSink *pulsesink = GST_PULSESINK_CAST (object);
#ifdef HAVE_PULSE_1_0
GList *i; GList *i;
#endif
g_free (pulsesink->server); g_free (pulsesink->server);
g_free (pulsesink->device); g_free (pulsesink->device);
g_free (pulsesink->device_description); g_free (pulsesink->device_description);
g_free (pulsesink->client_name); g_free (pulsesink->client_name);
#ifdef HAVE_PULSE_1_0
for (i = g_list_first (pulsesink->sink_formats); i; i = g_list_next (i)) for (i = g_list_first (pulsesink->sink_formats); i; i = g_list_next (i))
pa_format_info_free ((pa_format_info *) i->data); pa_format_info_free ((pa_format_info *) i->data);
g_list_free (pulsesink->sink_formats); g_list_free (pulsesink->sink_formats);
g_mutex_free (pulsesink->sink_formats_lock); g_mutex_free (pulsesink->sink_formats_lock);
#endif
if (pulsesink->properties) if (pulsesink->properties)
gst_structure_free (pulsesink->properties); gst_structure_free (pulsesink->properties);
@ -2240,16 +2167,12 @@ gst_pulsesink_set_volume (GstPulseSink * psink, gdouble volume)
if ((idx = pa_stream_get_index (pbuf->stream)) == PA_INVALID_INDEX) if ((idx = pa_stream_get_index (pbuf->stream)) == PA_INVALID_INDEX)
goto no_index; goto no_index;
#ifdef HAVE_PULSE_1_0
if (pbuf->is_pcm) if (pbuf->is_pcm)
gst_pulse_cvolume_from_linear (&v, pbuf->channels, volume); gst_pulse_cvolume_from_linear (&v, pbuf->channels, volume);
else else
/* FIXME: this will eventually be superceded by checks to see if the volume /* FIXME: this will eventually be superceded by checks to see if the volume
* is readable/writable */ * is readable/writable */
goto unlock; goto unlock;
#else
gst_pulse_cvolume_from_linear (&v, pbuf->sample_spec.channels, volume);
#endif
if (!(o = pa_context_set_sink_input_volume (pbuf->context, idx, if (!(o = pa_context_set_sink_input_volume (pbuf->context, idx,
&v, NULL, NULL))) &v, NULL, NULL)))
@ -2874,7 +2797,6 @@ gst_pulsesink_event (GstBaseSink * sink, GstEvent * event)
static gboolean static gboolean
gst_pulsesink_query (GstBaseSink * sink, GstQuery * query) gst_pulsesink_query (GstBaseSink * sink, GstQuery * query)
{ {
#ifdef HAVE_PULSE_1_0
GstPulseSink *pulsesink = GST_PULSESINK_CAST (sink); GstPulseSink *pulsesink = GST_PULSESINK_CAST (sink);
gboolean ret; gboolean ret;
@ -2894,9 +2816,6 @@ gst_pulsesink_query (GstBaseSink * sink, GstQuery * query)
break; break;
} }
return ret; return ret;
#else
return GST_BASE_SINK_CLASS (parent_class)->query (sink, query);
#endif
} }
static void static void

View file

@ -77,12 +77,10 @@ struct _GstPulseSink
GstStructure *properties; GstStructure *properties;
pa_proplist *proplist; pa_proplist *proplist;
#ifdef HAVE_PULSE_1_0
GMutex *sink_formats_lock; GMutex *sink_formats_lock;
GList *sink_formats; GList *sink_formats;
volatile gint format_lost; volatile gint format_lost;
GstClockTime format_lost_time; GstClockTime format_lost_time;
#endif
}; };
struct _GstPulseSinkClass struct _GstPulseSinkClass
@ -111,7 +109,6 @@ GType gst_pulsesink_get_type (void);
"audio/x-mulaw, " \ "audio/x-mulaw, " \
"rate = (int) [ 1, MAX], " "channels = (int) [ 1, 32 ];" "rate = (int) [ 1, MAX], " "channels = (int) [ 1, 32 ];"
#ifdef HAVE_PULSE_1_0
#define _PULSE_SINK_CAPS_1_0 \ #define _PULSE_SINK_CAPS_1_0 \
"audio/x-ac3, framed = (boolean) true;" \ "audio/x-ac3, framed = (boolean) true;" \
"audio/x-eac3, framed = (boolean) true; " \ "audio/x-eac3, framed = (boolean) true; " \
@ -119,15 +116,12 @@ GType gst_pulsesink_get_type (void);
"block-size = (int) { 512, 1024, 2048 }; " \ "block-size = (int) { 512, 1024, 2048 }; " \
"audio/mpeg, mpegversion = (int) 1, " \ "audio/mpeg, mpegversion = (int) 1, " \
"mpegaudioversion = (int) [ 1, 2 ], parsed = (boolean) true;" "mpegaudioversion = (int) [ 1, 2 ], parsed = (boolean) true;"
#else
#define _PULSE_SINK_CAPS_1_0 ""
#endif
#define PULSE_SINK_TEMPLATE_CAPS \ #define PULSE_SINK_TEMPLATE_CAPS \
_PULSE_SINK_CAPS_COMMON \ _PULSE_SINK_CAPS_COMMON \
_PULSE_SINK_CAPS_1_0 _PULSE_SINK_CAPS_1_0
#ifdef HAVE_PULSE_1_0 /* FIXME 0.11: pulseaudiosink helper bin must die */
#define GST_TYPE_PULSE_AUDIO_SINK \ #define GST_TYPE_PULSE_AUDIO_SINK \
(gst_pulse_audio_sink_get_type()) (gst_pulse_audio_sink_get_type())
@ -144,8 +138,6 @@ GType gst_pulsesink_get_type (void);
GType gst_pulse_audio_sink_get_type (void); GType gst_pulse_audio_sink_get_type (void);
#endif /* HAVE_PULSE_1_0 */
G_END_DECLS G_END_DECLS
#endif /* __GST_PULSESINK_H__ */ #endif /* __GST_PULSESINK_H__ */

View file

@ -43,9 +43,7 @@
#include <gst/base/gstbasesrc.h> #include <gst/base/gstbasesrc.h>
#include <gst/gsttaglist.h> #include <gst/gsttaglist.h>
#ifdef HAVE_PULSE_1_0
#include <gst/interfaces/streamvolume.h> #include <gst/interfaces/streamvolume.h>
#endif
#include "pulsesrc.h" #include "pulsesrc.h"
#include "pulseutil.h" #include "pulseutil.h"
@ -58,11 +56,9 @@ GST_DEBUG_CATEGORY_EXTERN (pulse_debug);
#define DEFAULT_DEVICE NULL #define DEFAULT_DEVICE NULL
#define DEFAULT_DEVICE_NAME NULL #define DEFAULT_DEVICE_NAME NULL
#ifdef HAVE_PULSE_1_0
#define DEFAULT_VOLUME 1.0 #define DEFAULT_VOLUME 1.0
#define DEFAULT_MUTE FALSE #define DEFAULT_MUTE FALSE
#define MAX_VOLUME 10.0 #define MAX_VOLUME 10.0
#endif
enum enum
{ {
@ -73,10 +69,8 @@ enum
PROP_CLIENT, PROP_CLIENT,
PROP_STREAM_PROPERTIES, PROP_STREAM_PROPERTIES,
PROP_SOURCE_OUTPUT_INDEX, PROP_SOURCE_OUTPUT_INDEX,
#ifdef HAVE_PULSE_1_0
PROP_VOLUME, PROP_VOLUME,
PROP_MUTE, PROP_MUTE,
#endif
PROP_LAST PROP_LAST
}; };
@ -245,14 +239,10 @@ gst_pulsesrc_class_init (GstPulseSrcClass * klass)
gst_element_class_add_pad_template (gstelement_class, gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&pad_template)); gst_static_pad_template_get (&pad_template));
#ifdef HAVE_PULSE_1_0
/** /**
* GstPulseSrc:volume * GstPulseSrc:volume
* *
* The volume of the record stream. Only works when using PulseAudio 1.0 or * The volume of the record stream.
* later.
*
* Since: 0.10.36
*/ */
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_VOLUME, g_param_spec_double ("volume", "Volume", PROP_VOLUME, g_param_spec_double ("volume", "Volume",
@ -263,16 +253,12 @@ gst_pulsesrc_class_init (GstPulseSrcClass * klass)
/** /**
* GstPulseSrc:mute * GstPulseSrc:mute
* *
* Whether the stream is muted or not. Only works when using PulseAudio 1.0 * Whether the stream is muted or not.
* or later.
*
* Since: 0.10.36
*/ */
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_MUTE, g_param_spec_boolean ("mute", "Mute", PROP_MUTE, g_param_spec_boolean ("mute", "Mute",
"Mute state of this stream", "Mute state of this stream",
DEFAULT_MUTE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); DEFAULT_MUTE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
#endif
} }
static void static void
@ -297,7 +283,6 @@ gst_pulsesrc_init (GstPulseSrc * pulsesrc)
pulsesrc->paused = TRUE; pulsesrc->paused = TRUE;
pulsesrc->in_read = FALSE; pulsesrc->in_read = FALSE;
#ifdef HAVE_PULSE_1_0
pulsesrc->volume = DEFAULT_VOLUME; pulsesrc->volume = DEFAULT_VOLUME;
pulsesrc->volume_set = FALSE; pulsesrc->volume_set = FALSE;
@ -305,7 +290,6 @@ gst_pulsesrc_init (GstPulseSrc * pulsesrc)
pulsesrc->mute_set = FALSE; pulsesrc->mute_set = FALSE;
pulsesrc->notify = 0; pulsesrc->notify = 0;
#endif
pulsesrc->mixer = NULL; pulsesrc->mixer = NULL;
@ -346,9 +330,7 @@ gst_pulsesrc_destroy_context (GstPulseSrc * pulsesrc)
/* Make sure we don't get any further callbacks */ /* Make sure we don't get any further callbacks */
pa_context_set_state_callback (pulsesrc->context, NULL, NULL); pa_context_set_state_callback (pulsesrc->context, NULL, NULL);
#ifdef HAVE_PULSE_1_0
pa_context_set_subscribe_callback (pulsesrc->context, NULL, NULL); pa_context_set_subscribe_callback (pulsesrc->context, NULL, NULL);
#endif
pa_context_unref (pulsesrc->context); pa_context_unref (pulsesrc->context);
@ -469,7 +451,6 @@ no_mainloop:
} }
} }
#ifdef HAVE_PULSE_1_0
static void static void
gst_pulsesrc_source_output_info_cb (pa_context * c, gst_pulsesrc_source_output_info_cb (pa_context * c,
const pa_source_output_info * i, int eol, void *userdata) const pa_source_output_info * i, int eol, void *userdata)
@ -721,7 +702,6 @@ mute_failed:
goto unlock; goto unlock;
} }
} }
#endif
static void static void
gst_pulsesrc_set_property (GObject * object, gst_pulsesrc_set_property (GObject * object,
@ -759,14 +739,12 @@ gst_pulsesrc_set_property (GObject * object,
pa_proplist_free (pulsesrc->proplist); pa_proplist_free (pulsesrc->proplist);
pulsesrc->proplist = gst_pulse_make_proplist (pulsesrc->properties); pulsesrc->proplist = gst_pulse_make_proplist (pulsesrc->properties);
break; break;
#ifdef HAVE_PULSE_1_0
case PROP_VOLUME: case PROP_VOLUME:
gst_pulsesrc_set_stream_volume (pulsesrc, g_value_get_double (value)); gst_pulsesrc_set_stream_volume (pulsesrc, g_value_get_double (value));
break; break;
case PROP_MUTE: case PROP_MUTE:
gst_pulsesrc_set_stream_mute (pulsesrc, g_value_get_boolean (value)); gst_pulsesrc_set_stream_mute (pulsesrc, g_value_get_boolean (value));
break; break;
#endif
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -799,14 +777,12 @@ gst_pulsesrc_get_property (GObject * object,
case PROP_SOURCE_OUTPUT_INDEX: case PROP_SOURCE_OUTPUT_INDEX:
g_value_set_uint (value, pulsesrc->source_output_idx); g_value_set_uint (value, pulsesrc->source_output_idx);
break; break;
#ifdef HAVE_PULSE_1_0
case PROP_VOLUME: case PROP_VOLUME:
g_value_set_double (value, gst_pulsesrc_get_stream_volume (pulsesrc)); g_value_set_double (value, gst_pulsesrc_get_stream_volume (pulsesrc));
break; break;
case PROP_MUTE: case PROP_MUTE:
g_value_set_boolean (value, gst_pulsesrc_get_stream_mute (pulsesrc)); g_value_set_boolean (value, gst_pulsesrc_get_stream_mute (pulsesrc));
break; break;
#endif
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -900,7 +876,6 @@ gst_pulsesrc_stream_overflow_cb (pa_stream * s, void *userdata)
GST_WARNING_OBJECT (GST_PULSESRC_CAST (userdata), "Got overflow"); GST_WARNING_OBJECT (GST_PULSESRC_CAST (userdata), "Got overflow");
} }
#ifdef HAVE_PULSE_1_0
static void static void
gst_pulsesrc_context_subscribe_cb (pa_context * c, gst_pulsesrc_context_subscribe_cb (pa_context * c,
pa_subscription_event_type_t t, uint32_t idx, void *userdata) pa_subscription_event_type_t t, uint32_t idx, void *userdata)
@ -922,7 +897,6 @@ gst_pulsesrc_context_subscribe_cb (pa_context * c,
/* inform streaming thread to notify */ /* inform streaming thread to notify */
g_atomic_int_compare_and_exchange (&psrc->notify, 0, 1); g_atomic_int_compare_and_exchange (&psrc->notify, 0, 1);
} }
#endif
static gboolean static gboolean
gst_pulsesrc_open (GstAudioSrc * asrc) gst_pulsesrc_open (GstAudioSrc * asrc)
@ -946,10 +920,8 @@ gst_pulsesrc_open (GstAudioSrc * asrc)
pa_context_set_state_callback (pulsesrc->context, pa_context_set_state_callback (pulsesrc->context,
gst_pulsesrc_context_state_cb, pulsesrc); gst_pulsesrc_context_state_cb, pulsesrc);
#ifdef HAVE_PULSE_1_0
pa_context_set_subscribe_callback (pulsesrc->context, pa_context_set_subscribe_callback (pulsesrc->context,
gst_pulsesrc_context_subscribe_cb, pulsesrc); gst_pulsesrc_context_subscribe_cb, pulsesrc);
#endif
GST_DEBUG_OBJECT (pulsesrc, "connect to server %s", GST_DEBUG_OBJECT (pulsesrc, "connect to server %s",
GST_STR_NULL (pulsesrc->server)); GST_STR_NULL (pulsesrc->server));
@ -1031,12 +1003,10 @@ gst_pulsesrc_read (GstAudioSrc * asrc, gpointer data, guint length)
pa_threaded_mainloop_lock (pulsesrc->mainloop); pa_threaded_mainloop_lock (pulsesrc->mainloop);
pulsesrc->in_read = TRUE; pulsesrc->in_read = TRUE;
#ifdef HAVE_PULSE_1_0
if (g_atomic_int_compare_and_exchange (&pulsesrc->notify, 1, 0)) { if (g_atomic_int_compare_and_exchange (&pulsesrc->notify, 1, 0)) {
g_object_notify (G_OBJECT (pulsesrc), "volume"); g_object_notify (G_OBJECT (pulsesrc), "volume");
g_object_notify (G_OBJECT (pulsesrc), "mute"); g_object_notify (G_OBJECT (pulsesrc), "mute");
} }
#endif
if (pulsesrc->paused) if (pulsesrc->paused)
goto was_paused; goto was_paused;
@ -1352,13 +1322,10 @@ gst_pulsesrc_prepare (GstAudioSrc * asrc, GstAudioRingBufferSpec * spec)
const pa_buffer_attr *actual; const pa_buffer_attr *actual;
GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (asrc); GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (asrc);
pa_stream_flags_t flags; pa_stream_flags_t flags;
#ifdef HAVE_PULSE_1_0
pa_operation *o; pa_operation *o;
#endif
pa_threaded_mainloop_lock (pulsesrc->mainloop); pa_threaded_mainloop_lock (pulsesrc->mainloop);
#ifdef HAVE_PULSE_1_0
/* enable event notifications */ /* enable event notifications */
GST_LOG_OBJECT (pulsesrc, "subscribing to context events"); GST_LOG_OBJECT (pulsesrc, "subscribing to context events");
if (!(o = pa_context_subscribe (pulsesrc->context, if (!(o = pa_context_subscribe (pulsesrc->context,
@ -1370,7 +1337,6 @@ gst_pulsesrc_prepare (GstAudioSrc * asrc, GstAudioRingBufferSpec * spec)
} }
pa_operation_unref (o); pa_operation_unref (o);
#endif
wanted.maxlength = -1; wanted.maxlength = -1;
wanted.tlength = -1; wanted.tlength = -1;
@ -1388,10 +1354,8 @@ gst_pulsesrc_prepare (GstAudioSrc * asrc, GstAudioRingBufferSpec * spec)
PA_STREAM_NOT_MONOTONIC | PA_STREAM_ADJUST_LATENCY | PA_STREAM_NOT_MONOTONIC | PA_STREAM_ADJUST_LATENCY |
PA_STREAM_START_CORKED; PA_STREAM_START_CORKED;
#ifdef HAVE_PULSE_1_0
if (pulsesrc->mute_set && pulsesrc->mute) if (pulsesrc->mute_set && pulsesrc->mute)
flags |= PA_STREAM_START_MUTED; flags |= PA_STREAM_START_MUTED;
#endif
if (pa_stream_connect_record (pulsesrc->stream, pulsesrc->device, &wanted, if (pa_stream_connect_record (pulsesrc->stream, pulsesrc->device, &wanted,
flags) < 0) { flags) < 0) {
@ -1420,12 +1384,10 @@ gst_pulsesrc_prepare (GstAudioSrc * asrc, GstAudioRingBufferSpec * spec)
pulsesrc->source_output_idx = pa_stream_get_index (pulsesrc->stream); pulsesrc->source_output_idx = pa_stream_get_index (pulsesrc->stream);
g_object_notify (G_OBJECT (pulsesrc), "source-output-index"); g_object_notify (G_OBJECT (pulsesrc), "source-output-index");
#ifdef HAVE_PULSE_1_0
if (pulsesrc->volume_set) { if (pulsesrc->volume_set) {
gst_pulsesrc_set_stream_volume (pulsesrc, pulsesrc->volume); gst_pulsesrc_set_stream_volume (pulsesrc, pulsesrc->volume);
pulsesrc->volume_set = FALSE; pulsesrc->volume_set = FALSE;
} }
#endif
/* get the actual buffering properties now */ /* get the actual buffering properties now */
actual = pa_stream_get_buffer_attr (pulsesrc->stream); actual = pa_stream_get_buffer_attr (pulsesrc->stream);

View file

@ -72,14 +72,12 @@ struct _GstPulseSrc
GstPulseMixerCtrl *mixer; GstPulseMixerCtrl *mixer;
GstPulseProbe *probe; GstPulseProbe *probe;
#ifdef HAVE_PULSE_1_0
gdouble volume; gdouble volume;
gboolean volume_set:1; gboolean volume_set:1;
gboolean mute:1; gboolean mute:1;
gboolean mute_set:1; gboolean mute_set:1;
gint notify; /* atomic */ gint notify; /* atomic */
#endif
gboolean corked:1; gboolean corked:1;
gboolean stream_connected:1; gboolean stream_connected:1;

View file

@ -156,7 +156,6 @@ gst_pulse_fill_sample_spec (GstAudioRingBufferSpec * spec, pa_sample_spec * ss)
return TRUE; return TRUE;
} }
#ifdef HAVE_PULSE_1_0
gboolean gboolean
gst_pulse_fill_format_info (GstAudioRingBufferSpec * spec, pa_format_info ** f, gst_pulse_fill_format_info (GstAudioRingBufferSpec * spec, pa_format_info ** f,
guint * channels) guint * channels)
@ -210,7 +209,6 @@ fail:
pa_format_info_free (format); pa_format_info_free (format);
return FALSE; return FALSE;
} }
#endif
/* PATH_MAX is not defined everywhere, e.g. on GNU Hurd */ /* PATH_MAX is not defined everywhere, e.g. on GNU Hurd */
#ifndef PATH_MAX #ifndef PATH_MAX

View file

@ -33,10 +33,8 @@
gboolean gst_pulse_fill_sample_spec (GstAudioRingBufferSpec * spec, gboolean gst_pulse_fill_sample_spec (GstAudioRingBufferSpec * spec,
pa_sample_spec * ss); pa_sample_spec * ss);
#ifdef HAVE_PULSE_1_0
gboolean gst_pulse_fill_format_info (GstAudioRingBufferSpec * spec, gboolean gst_pulse_fill_format_info (GstAudioRingBufferSpec * spec,
pa_format_info ** f, guint * channels); pa_format_info ** f, guint * channels);
#endif
gchar *gst_pulse_client_name (void); gchar *gst_pulse_client_name (void);