summaryrefslogtreecommitdiff
path: root/ext
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 13:32:04 -0400
commitc3642e3ecf925e24362e09d901d46ac9b0faacd3 (patch)
tree211113a69203f3cb0809f4bf09ffbdede0ffcd95 /ext
parente98767e8644e1ecd034c3882f6677b0ceebb383e (diff)
pulsesrc: Implement changing the device while playing
https://bugzilla.gnome.org/show_bug.cgi?id=590768
Diffstat (limited to 'ext')
-rw-r--r--ext/pulse/pulsesrc.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/ext/pulse/pulsesrc.c b/ext/pulse/pulsesrc.c
index 0f0764b4b..85fa7f7e2 100644
--- a/ext/pulse/pulsesrc.c
+++ b/ext/pulse/pulsesrc.c
@@ -680,6 +680,56 @@ mute_failed:
}
}
+
+static void
+gst_pulsesrc_set_stream_device (GstPulseSrc * pulsesrc, const gchar * device)
+{
+ pa_operation *o = NULL;
+
+ if (!pulsesrc->mainloop)
+ goto no_mainloop;
+
+ if (!pulsesrc->source_output_idx)
+ goto no_index;
+
+ pa_threaded_mainloop_lock (pulsesrc->mainloop);
+
+ GST_DEBUG_OBJECT (pulsesrc, "setting stream device to %s", device);
+
+ if (!(o = pa_context_move_source_output_by_name (pulsesrc->context,
+ pulsesrc->source_output_idx, device, NULL, NULL)))
+ goto move_failed;
+
+unlock:
+
+ if (o)
+ pa_operation_unref (o);
+
+ pa_threaded_mainloop_unlock (pulsesrc->mainloop);
+
+ return;
+
+ /* ERRORS */
+no_mainloop:
+ {
+ GST_DEBUG_OBJECT (pulsesrc, "we have no mainloop");
+ return;
+ }
+no_index:
+ {
+ GST_DEBUG_OBJECT (pulsesrc, "we don't have a stream index");
+ return;
+ }
+move_failed:
+ {
+ GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED,
+ ("pa_context_move_source_output_by_name(%s) failed: %s",
+ device, pa_strerror (pa_context_errno (pulsesrc->context))),
+ (NULL));
+ goto unlock;
+ }
+}
+
static void
gst_pulsesrc_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
@@ -695,6 +745,7 @@ gst_pulsesrc_set_property (GObject * object,
case PROP_DEVICE:
g_free (pulsesrc->device);
pulsesrc->device = g_value_dup_string (value);
+ gst_pulsesrc_set_stream_device (pulsesrc, pulsesrc->device);
break;
case PROP_CLIENT_NAME:
g_free (pulsesrc->client_name);