summaryrefslogtreecommitdiff
path: root/ext/pulse
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2013-08-18 22:27:37 -0400
committerOlivier CrĂȘte <olivier.crete@collabora.com>2013-08-22 14:25:30 -0400
commit8f9fbfa99297bc54a20d964d5067490fd167b22f (patch)
tree47d8d62907c46d480157574bc46ec57d51ab6796 /ext/pulse
parent691b04e5c949ba85aa8e6dc8f5259017c4f652af (diff)
downloadgstreamer-plugins-good-8f9fbfa99297bc54a20d964d5067490fd167b22f.tar.gz
pulsesink: Implement changing the device while playing
https://bugzilla.gnome.org/show_bug.cgi?id=590768
Diffstat (limited to 'ext/pulse')
-rw-r--r--ext/pulse/pulsesink.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c
index 53448a261..3f0b34f9e 100644
--- a/ext/pulse/pulsesink.c
+++ b/ext/pulse/pulsesink.c
@@ -2818,6 +2818,67 @@ info_failed:
}
static void
+gst_pulsesink_set_stream_device (GstPulseSink * psink, const gchar * device)
+{
+ pa_operation *o = NULL;
+ GstPulseRingBuffer *pbuf;
+ uint32_t idx;
+
+ if (!mainloop)
+ goto no_mainloop;
+
+ pa_threaded_mainloop_lock (mainloop);
+
+ pbuf = GST_PULSERING_BUFFER_CAST (GST_AUDIO_BASE_SINK (psink)->ringbuffer);
+ if (pbuf == NULL || pbuf->stream == NULL)
+ goto no_buffer;
+
+ if ((idx = pa_stream_get_index (pbuf->stream)) == PA_INVALID_INDEX)
+ goto no_index;
+
+
+ GST_DEBUG_OBJECT (psink, "setting stream device to %s", device);
+
+ if (!(o = pa_context_move_sink_input_by_name (pbuf->context, idx, device,
+ NULL, NULL)))
+ goto move_failed;
+
+unlock:
+
+ if (o)
+ pa_operation_unref (o);
+
+ pa_threaded_mainloop_unlock (mainloop);
+
+ return;
+
+ /* ERRORS */
+no_mainloop:
+ {
+ GST_DEBUG_OBJECT (psink, "we have no mainloop");
+ return;
+ }
+no_buffer:
+ {
+ GST_DEBUG_OBJECT (psink, "we have no ringbuffer");
+ goto unlock;
+ }
+no_index:
+ {
+ GST_DEBUG_OBJECT (psink, "we don't have a stream index");
+ return;
+ }
+move_failed:
+ {
+ GST_ELEMENT_ERROR (psink, RESOURCE, FAILED,
+ ("pa_context_move_sink_input_by_name(%s) failed: %s", device,
+ pa_strerror (pa_context_errno (pbuf->context))), (NULL));
+ goto unlock;
+ }
+}
+
+
+static void
gst_pulsesink_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
@@ -2831,6 +2892,7 @@ gst_pulsesink_set_property (GObject * object,
case PROP_DEVICE:
g_free (pulsesink->device);
pulsesink->device = g_value_dup_string (value);
+ gst_pulsesink_set_stream_device (pulsesink, pulsesink->device);
break;
case PROP_VOLUME:
gst_pulsesink_set_volume (pulsesink, g_value_get_double (value));