summaryrefslogtreecommitdiffstats
path: root/src/polypmixerctrl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/polypmixerctrl.c')
-rw-r--r--src/polypmixerctrl.c43
1 files changed, 23 insertions, 20 deletions
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;