From 547ce2fd805f6a008df03e6deef215bbb1bb5c65 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 12 May 2006 00:20:30 +0000 Subject: add mixer interface to GstSource git-svn-id: file:///home/lennart/svn/public/gst-pulse/trunk@28 bb39ca4e-bce3-0310-b5d4-eea78a553289 --- src/polypmixerctrl.c | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'src/polypmixerctrl.c') diff --git a/src/polypmixerctrl.c b/src/polypmixerctrl.c index 5b89acc..42cea8a 100644 --- a/src/polypmixerctrl.c +++ b/src/polypmixerctrl.c @@ -210,28 +210,28 @@ static gboolean gst_polypmixer_ctrl_open(GstPolypMixerCtrl *c) { /* Get sink info */ - if (!(o = pa_context_get_sink_info_by_name(c->context, c->device, gst_polypmixer_ctrl_sink_info_cb, c))) { - GST_WARNING("Failed to get sink info: %s", pa_strerror(pa_context_errno(c->context))); - goto unlock_and_fail; - } - - c->operation_success = 0; - while (pa_operation_get_state(o) != PA_OPERATION_DONE) { - pa_threaded_mainloop_wait(c->mainloop); - CHECK_DEAD_GOTO(c, unlock_and_fail); - } - - if (!c->operation_success) { - - if (pa_context_errno(c->context) != PA_ERR_NOENTITY) { + if (c->type == GST_POLYPMIXER_UNKNOWN || c->type == GST_POLYPMIXER_SINK) { + if (!(o = pa_context_get_sink_info_by_name(c->context, c->device, gst_polypmixer_ctrl_sink_info_cb, c))) { GST_WARNING("Failed to get sink info: %s", pa_strerror(pa_context_errno(c->context))); goto unlock_and_fail; } - - /* This device wasn't a sink, hence look for a source */ + + c->operation_success = 0; + while (pa_operation_get_state(o) != PA_OPERATION_DONE) { + pa_threaded_mainloop_wait(c->mainloop); + CHECK_DEAD_GOTO(c, unlock_and_fail); + } pa_operation_unref(o); + o = NULL; + + if (!c->operation_success && (c->type == GST_POLYPMIXER_SINK || pa_context_errno(c->context) != PA_ERR_NOENTITY)) { + GST_WARNING("Failed to get sink info: %s", pa_strerror(pa_context_errno(c->context))); + goto unlock_and_fail; + } + } + if (c->type == GST_POLYPMIXER_UNKNOWN || c->type == GST_POLYPMIXER_SOURCE) { if (!(o = pa_context_get_source_info_by_name(c->context, c->device, gst_polypmixer_ctrl_source_info_cb, c))) { GST_WARNING("Failed to get source info: %s", pa_strerror(pa_context_errno(c->context))); goto unlock_and_fail; @@ -243,17 +243,20 @@ static gboolean gst_polypmixer_ctrl_open(GstPolypMixerCtrl *c) { CHECK_DEAD_GOTO(c, unlock_and_fail); } + pa_operation_unref(o); + o = NULL; + if (!c->operation_success) { GST_WARNING("Failed to get source info: %s", pa_strerror(pa_context_errno(c->context))); goto unlock_and_fail; } } + g_assert(c->type != GST_POLYPMIXER_UNKNOWN); + c->track = gst_polypmixer_track_new(c); c->tracklist = g_list_append(c->tracklist, c->track); - pa_operation_unref(o); - pa_threaded_mainloop_unlock(c->mainloop); g_free(name); @@ -302,7 +305,7 @@ static void gst_polypmixer_ctrl_close(GstPolypMixerCtrl *c) { } } -GstPolypMixerCtrl* gst_polypmixer_ctrl_new(const gchar *server, const gchar *device) { +GstPolypMixerCtrl* gst_polypmixer_ctrl_new(const gchar *server, const gchar *device, GstPolypMixerType type) { GstPolypMixerCtrl *c = NULL; c = g_new(GstPolypMixerCtrl, 1); @@ -317,7 +320,7 @@ GstPolypMixerCtrl* gst_polypmixer_ctrl_new(const gchar *server, const gchar *dev pa_channel_map_init(&c->channel_map); c->muted = 0; c->index = PA_INVALID_INDEX; - c->type = GST_POLYPMIXER_UNKNOWN; + c->type = type; c->name = NULL; c->description = NULL; -- cgit