summaryrefslogtreecommitdiffstats
path: root/src/pulse/introspect.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulse/introspect.c')
-rw-r--r--src/pulse/introspect.c66
1 files changed, 49 insertions, 17 deletions
diff --git a/src/pulse/introspect.c b/src/pulse/introspect.c
index c4001331..a781c14f 100644
--- a/src/pulse/introspect.c
+++ b/src/pulse/introspect.c
@@ -405,11 +405,16 @@ pa_operation* pa_context_set_sink_port_by_name(pa_context *c, const char *name,
static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_operation *o = userdata;
int eol = 1;
+ pa_source_info i;
+ uint32_t j;
pa_assert(pd);
pa_assert(o);
pa_assert(PA_REFCNT_VALUE(o) >= 1);
+ /* For safety incase someone use fail: outside the while loop below */
+ pa_zero(i);
+
if (!o->context)
goto finish;
@@ -421,11 +426,9 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
} else {
while (!pa_tagstruct_eof(t)) {
- pa_source_info i;
pa_bool_t mute;
uint32_t flags;
uint32_t state;
- unsigned j;
const char *ap;
pa_zero(i);
@@ -460,9 +463,7 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
(o->context->version >= 16 &&
(pa_tagstruct_getu32(t, &i.n_ports)))) {
- pa_context_fail(o->context, PA_ERR_PROTOCOL);
- pa_proplist_free(i.proplist);
- goto finish;
+ goto fail;
}
if (o->context->version >= 16) {
@@ -475,11 +476,7 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
pa_tagstruct_gets(t, &i.ports[0][j].description) < 0 ||
pa_tagstruct_getu32(t, &i.ports[0][j].priority) < 0) {
- pa_context_fail(o->context, PA_ERR_PROTOCOL);
- pa_xfree(i.ports[0]);
- pa_xfree(i.ports);
- pa_proplist_free(i.proplist);
- goto finish;
+ goto fail;
}
i.ports[j] = &i.ports[0][j];
@@ -488,13 +485,8 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
i.ports[j] = NULL;
}
- if (pa_tagstruct_gets(t, &ap) < 0) {
- pa_context_fail(o->context, PA_ERR_PROTOCOL);
- pa_xfree(i.ports[0]);
- pa_xfree(i.ports);
- pa_proplist_free(i.proplist);
- goto finish;
- }
+ if (pa_tagstruct_gets(t, &ap) < 0)
+ goto fail;
if (ap) {
for (j = 0; j < i.n_ports; j++)
@@ -505,6 +497,22 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
}
}
+ if (o->context->version >= 22) {
+ uint8_t n_formats;
+ if (pa_tagstruct_getu8(t, &n_formats) < 0 || n_formats < 1)
+ goto fail;
+
+ i.formats = pa_xnew0(pa_format_info*, n_formats);
+
+ for (j = 0; j < n_formats; j++) {
+ i.n_formats++;
+ i.formats[j] = pa_format_info_new();
+
+ if (pa_tagstruct_get_format_info(t, i.formats[j]) < 0)
+ goto fail;
+ }
+ }
+
i.mute = (int) mute;
i.flags = (pa_source_flags_t) flags;
i.state = (pa_source_state_t) state;
@@ -514,6 +522,11 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
cb(o->context, &i, 0, o->userdata);
}
+ if (i.formats) {
+ for (j = 0; j < i.n_formats; j++)
+ pa_format_info_free(i.formats[j]);
+ pa_xfree(i.formats);
+ }
if (i.ports) {
pa_xfree(i.ports[0]);
pa_xfree(i.ports);
@@ -530,6 +543,25 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
finish:
pa_operation_done(o);
pa_operation_unref(o);
+ return;
+
+fail:
+ pa_assert(i.proplist);
+
+ pa_context_fail(o->context, PA_ERR_PROTOCOL);
+
+ if (i.formats) {
+ for (j = 0; j < i.n_formats; j++)
+ pa_format_info_free(i.formats[j]);
+ pa_xfree(i.formats);
+ }
+ if (i.ports) {
+ pa_xfree(i.ports[0]);
+ pa_xfree(i.ports);
+ }
+ pa_proplist_free(i.proplist);
+
+ goto finish;
}
pa_operation* pa_context_get_source_info_list(pa_context *c, pa_source_info_cb_t cb, void *userdata) {