mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
pulsesrc: Implement changing the device while playing
https://bugzilla.gnome.org/show_bug.cgi?id=590768
This commit is contained in:
parent
e98767e864
commit
c3642e3ecf
1 changed files with 51 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue