X-Git-Url: https://code.delx.au/pulseaudio/blobdiff_plain/7aa84e82089a88a542f15cbf6f38c808b4f04db1..856e78f45e1ecf16fc05b98b86aeb92236f4917c:/src/pulse/introspect.c diff --git a/src/pulse/introspect.c b/src/pulse/introspect.c index e28a78c4..d7696df4 100644 --- a/src/pulse/introspect.c +++ b/src/pulse/introspect.c @@ -24,10 +24,8 @@ #include #endif -#include - #include -#include +#include #include #include @@ -54,7 +52,7 @@ static void context_stat_callback(pa_pdispatch *pd, uint32_t command, uint32_t t goto finish; if (command != PA_COMMAND_REPLY) { - if (pa_context_handle_error(o->context, command, t, FALSE) < 0) + if (pa_context_handle_error(o->context, command, t, false) < 0) goto finish; p = NULL; @@ -98,7 +96,7 @@ static void context_get_server_info_callback(pa_pdispatch *pd, uint32_t command, goto finish; if (command != PA_COMMAND_REPLY) { - if (pa_context_handle_error(o->context, command, t, FALSE) < 0) + if (pa_context_handle_error(o->context, command, t, false) < 0) goto finish; p = NULL; @@ -140,34 +138,37 @@ pa_operation* pa_context_get_server_info(pa_context *c, pa_server_info_cb_t cb, static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { pa_operation *o = userdata; int eol = 1; + pa_sink_info i; + uint32_t j; pa_assert(pd); pa_assert(o); pa_assert(PA_REFCNT_VALUE(o) >= 1); + /* For safety in case someone use fail: outside the while loop below */ + pa_zero(i); + if (!o->context) goto finish; if (command != PA_COMMAND_REPLY) { - if (pa_context_handle_error(o->context, command, t, FALSE) < 0) + if (pa_context_handle_error(o->context, command, t, false) < 0) goto finish; eol = -1; } else { while (!pa_tagstruct_eof(t)) { - pa_sink_info i; - pa_bool_t mute; + bool mute; uint32_t flags; uint32_t state; - uint32_t j; const char *ap = NULL; pa_zero(i); i.proplist = pa_proplist_new(); i.base_volume = PA_VOLUME_NORM; i.n_volume_steps = PA_VOLUME_NORM+1; - mute = FALSE; + mute = false; state = PA_SINK_INVALID_STATE; i.card = PA_INVALID_INDEX; @@ -195,9 +196,7 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u (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) { @@ -206,30 +205,29 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u i.ports[0] = pa_xnew(pa_sink_port_info, i.n_ports); for (j = 0; j < i.n_ports; j++) { - if (pa_tagstruct_gets(t, &i.ports[0][j].name) < 0 || - 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; + i.ports[j] = &i.ports[0][j]; + + if (pa_tagstruct_gets(t, &i.ports[j]->name) < 0 || + pa_tagstruct_gets(t, &i.ports[j]->description) < 0 || + pa_tagstruct_getu32(t, &i.ports[j]->priority) < 0) { + + goto fail; } - i.ports[j] = &i.ports[0][j]; + i.ports[j]->available = PA_PORT_AVAILABLE_UNKNOWN; + if (o->context->version >= 24) { + uint32_t av; + if (pa_tagstruct_getu32(t, &av) < 0 || av > PA_PORT_AVAILABLE_YES) + goto fail; + i.ports[j]->available = av; + } } 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++) @@ -241,29 +239,18 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u } if (o->context->version >= 21) { - i.formats = NULL; + uint8_t n_formats; + if (pa_tagstruct_getu8(t, &n_formats) < 0 || n_formats < 1) + goto fail; - if (pa_tagstruct_getu8(t, &i.n_formats)) { - pa_context_fail(o->context, PA_ERR_PROTOCOL); - pa_proplist_free(i.proplist); - goto finish; - } - - pa_assert(i.n_formats > 0); - i.formats = pa_xnew0(pa_format_info*, i.n_formats); + i.formats = pa_xnew0(pa_format_info*, n_formats); - for (j = 0; j < i.n_formats; j++) { + 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) { - do { - pa_format_info_free(i.formats[j]); - } while (j--); - pa_xfree(i.formats); - - pa_context_fail(o->context, PA_ERR_PROTOCOL); - pa_proplist_free(i.proplist); - goto finish; - } + + if (pa_tagstruct_get_format_info(t, i.formats[j]) < 0) + goto fail; } } @@ -276,17 +263,15 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u cb(o->context, &i, 0, o->userdata); } - if (i.ports) { - pa_xfree(i.ports[0]); - pa_xfree(i.ports); - } - 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); } } @@ -299,6 +284,25 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u 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_sink_info_list(pa_context *c, pa_sink_info_cb_t cb, void *userdata) { @@ -407,34 +411,37 @@ 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 in case someone use fail: outside the while loop below */ + pa_zero(i); + if (!o->context) goto finish; if (command != PA_COMMAND_REPLY) { - if (pa_context_handle_error(o->context, command, t, FALSE) < 0) + if (pa_context_handle_error(o->context, command, t, false) < 0) goto finish; eol = -1; } else { while (!pa_tagstruct_eof(t)) { - pa_source_info i; - pa_bool_t mute; + bool mute; uint32_t flags; uint32_t state; - unsigned j; const char *ap; pa_zero(i); i.proplist = pa_proplist_new(); i.base_volume = PA_VOLUME_NORM; i.n_volume_steps = PA_VOLUME_NORM+1; - mute = FALSE; + mute = false; state = PA_SOURCE_INVALID_STATE; i.card = PA_INVALID_INDEX; @@ -462,9 +469,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) { @@ -473,30 +478,29 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command, i.ports[0] = pa_xnew(pa_source_port_info, i.n_ports); for (j = 0; j < i.n_ports; j++) { - if (pa_tagstruct_gets(t, &i.ports[0][j].name) < 0 || - 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; + i.ports[j] = &i.ports[0][j]; + + if (pa_tagstruct_gets(t, &i.ports[j]->name) < 0 || + pa_tagstruct_gets(t, &i.ports[j]->description) < 0 || + pa_tagstruct_getu32(t, &i.ports[j]->priority) < 0) { + + goto fail; } - i.ports[j] = &i.ports[0][j]; + i.ports[j]->available = PA_PORT_AVAILABLE_UNKNOWN; + if (o->context->version >= 24) { + uint32_t av; + if (pa_tagstruct_getu32(t, &av) < 0 || av > PA_PORT_AVAILABLE_YES) + goto fail; + i.ports[j]->available = av; + } } 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++) @@ -507,6 +511,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; @@ -516,6 +536,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); @@ -532,6 +557,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) { @@ -649,7 +693,7 @@ static void context_get_client_info_callback(pa_pdispatch *pd, uint32_t command, goto finish; if (command != PA_COMMAND_REPLY) { - if (pa_context_handle_error(o->context, command, t, FALSE) < 0) + if (pa_context_handle_error(o->context, command, t, false) < 0) goto finish; eol = -1; @@ -720,9 +764,151 @@ pa_operation* pa_context_get_client_info_list(pa_context *c, pa_client_info_cb_t /*** Card info ***/ +static void card_info_free(pa_card_info* i) { + if (i->proplist) + pa_proplist_free(i->proplist); + + pa_xfree(i->profiles); + + if (i->n_profiles) { + uint32_t j; + + for (j = 0; j < i->n_profiles; j++) + pa_xfree(i->profiles2[j]); + + pa_xfree(i->profiles2); + } + + if (i->ports) { + uint32_t j; + + for (j = 0; j < i->n_ports; j++) { + if (i->ports[j]) { + if (i->ports[j]->profiles) + pa_xfree(i->ports[j]->profiles); + if (i->ports[j]->profiles2) + pa_xfree(i->ports[j]->profiles2); + if (i->ports[j]->proplist) + pa_proplist_free(i->ports[j]->proplist); + } + } + + pa_xfree(i->ports[0]); + pa_xfree(i->ports); + } +} + +static int fill_card_port_info(pa_context *context, pa_tagstruct* t, pa_card_info* i) { + uint32_t j, k, l; + + if (pa_tagstruct_getu32(t, &i->n_ports) < 0) + return -PA_ERR_PROTOCOL; + + if (i->n_ports == 0) { + i->ports = NULL; + return 0; + } + + i->ports = pa_xnew0(pa_card_port_info*, i->n_ports+1); + i->ports[0] = pa_xnew0(pa_card_port_info, i->n_ports); + + for (j = 0; j < i->n_ports; j++) { + uint8_t direction; + uint32_t available; + pa_card_port_info* port = i->ports[j] = &i->ports[0][j]; + + port->proplist = pa_proplist_new(); + + if (pa_tagstruct_gets(t, &port->name) < 0 || + pa_tagstruct_gets(t, &port->description) < 0 || + pa_tagstruct_getu32(t, &port->priority) < 0 || + pa_tagstruct_getu32(t, &available) < 0 || + pa_tagstruct_getu8(t, &direction) < 0 || + !pa_direction_valid(direction) || + pa_tagstruct_get_proplist(t, port->proplist) < 0 || + pa_tagstruct_getu32(t, &port->n_profiles) < 0) { + + return -PA_ERR_PROTOCOL; + } + + if (available > PA_PORT_AVAILABLE_YES ) { + return -PA_ERR_PROTOCOL; + } + + port->direction = direction; + port->available = available; + + if (port->n_profiles > 0) { + port->profiles = pa_xnew0(pa_card_profile_info*, i->n_profiles+1); + port->profiles2 = pa_xnew0(pa_card_profile_info2*, i->n_profiles+1); + + for (k = 0; k < port->n_profiles; k++) { + const char* profilename; + + if (pa_tagstruct_gets(t, &profilename) < 0) + return -PA_ERR_PROTOCOL; + + for (l = 0; l < i->n_profiles; l++) { + if (pa_streq(i->profiles[l].name, profilename)) { + port->profiles[k] = &i->profiles[l]; + port->profiles2[k] = i->profiles2[l]; + break; + } + } + + if (l >= i->n_profiles) + return -PA_ERR_PROTOCOL; + } + } + if (context->version >= 27) { + if (pa_tagstruct_gets64(t, &port->latency_offset) < 0) + return -PA_ERR_PROTOCOL; + } else + port->latency_offset = 0; + } + + return 0; +} + +static int fill_card_profile_info(pa_context *context, pa_tagstruct* t, pa_card_info* i) { + uint32_t j; + + i->profiles = pa_xnew0(pa_card_profile_info, i->n_profiles+1); + i->profiles2 = pa_xnew0(pa_card_profile_info2*, i->n_profiles+1); + + for (j = 0; j < i->n_profiles; j++) { + if (pa_tagstruct_gets(t, &i->profiles[j].name) < 0 || + pa_tagstruct_gets(t, &i->profiles[j].description) < 0 || + pa_tagstruct_getu32(t, &i->profiles[j].n_sinks) < 0 || + pa_tagstruct_getu32(t, &i->profiles[j].n_sources) < 0 || + pa_tagstruct_getu32(t, &i->profiles[j].priority) < 0) + return -PA_ERR_PROTOCOL; + + i->profiles2[j] = pa_xnew0(pa_card_profile_info2, 1); + i->profiles2[j]->name = i->profiles[j].name; + i->profiles2[j]->description = i->profiles[j].description; + i->profiles2[j]->n_sinks = i->profiles[j].n_sinks; + i->profiles2[j]->n_sources = i->profiles[j].n_sources; + i->profiles2[j]->priority = i->profiles[j].priority; + i->profiles2[j]->available = 1; + + if (context->version >= 29) { + uint32_t av; + + if (pa_tagstruct_getu32(t, &av) < 0) + return -PA_ERR_PROTOCOL; + + i->profiles2[j]->available = av; + } + } + + return 0; +} + static void context_get_card_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { pa_operation *o = userdata; int eol = 1; + pa_card_info i; pa_assert(pd); pa_assert(o); @@ -732,14 +918,13 @@ static void context_get_card_info_callback(pa_pdispatch *pd, uint32_t command, u goto finish; if (command != PA_COMMAND_REPLY) { - if (pa_context_handle_error(o->context, command, t, FALSE) < 0) + if (pa_context_handle_error(o->context, command, t, false) < 0) goto finish; eol = -1; } else { while (!pa_tagstruct_eof(t)) { - pa_card_info i; uint32_t j; const char*ap; @@ -749,32 +934,12 @@ static void context_get_card_info_callback(pa_pdispatch *pd, uint32_t command, u pa_tagstruct_gets(t, &i.name) < 0 || pa_tagstruct_getu32(t, &i.owner_module) < 0 || pa_tagstruct_gets(t, &i.driver) < 0 || - pa_tagstruct_getu32(t, &i.n_profiles) < 0) { - - pa_context_fail(o->context, PA_ERR_PROTOCOL); - goto finish; - } + pa_tagstruct_getu32(t, &i.n_profiles) < 0) + goto fail; if (i.n_profiles > 0) { - i.profiles = pa_xnew0(pa_card_profile_info, i.n_profiles+1); - - for (j = 0; j < i.n_profiles; j++) { - - if (pa_tagstruct_gets(t, &i.profiles[j].name) < 0 || - pa_tagstruct_gets(t, &i.profiles[j].description) < 0 || - pa_tagstruct_getu32(t, &i.profiles[j].n_sinks) < 0 || - pa_tagstruct_getu32(t, &i.profiles[j].n_sources) < 0 || - pa_tagstruct_getu32(t, &i.profiles[j].priority) < 0) { - - pa_context_fail(o->context, PA_ERR_PROTOCOL); - pa_xfree(i.profiles); - goto finish; - } - } - - /* Terminate with an extra NULL entry, just to make sure */ - i.profiles[j].name = NULL; - i.profiles[j].description = NULL; + if (fill_card_profile_info(o->context, t, &i) < 0) + goto fail; } i.proplist = pa_proplist_new(); @@ -783,8 +948,7 @@ static void context_get_card_info_callback(pa_pdispatch *pd, uint32_t command, u pa_tagstruct_get_proplist(t, i.proplist) < 0) { pa_context_fail(o->context, PA_ERR_PROTOCOL); - pa_xfree(i.profiles); - pa_proplist_free(i.proplist); + card_info_free(&i); goto finish; } @@ -792,17 +956,22 @@ static void context_get_card_info_callback(pa_pdispatch *pd, uint32_t command, u for (j = 0; j < i.n_profiles; j++) if (pa_streq(i.profiles[j].name, ap)) { i.active_profile = &i.profiles[j]; + i.active_profile2 = i.profiles2[j]; break; } } + if (o->context->version >= 26) { + if (fill_card_port_info(o->context, t, &i) < 0) + goto fail; + } + if (o->callback) { pa_card_info_cb_t cb = (pa_card_info_cb_t) o->callback; cb(o->context, &i, 0, o->userdata); } - pa_proplist_free(i.proplist); - pa_xfree(i.profiles); + card_info_free(&i); } } @@ -814,6 +983,12 @@ static void context_get_card_info_callback(pa_pdispatch *pd, uint32_t command, u finish: pa_operation_done(o); pa_operation_unref(o); + return; + +fail: + pa_context_fail(o->context, PA_ERR_PROTOCOL); + card_info_free(&i); + goto finish; } pa_operation* pa_context_get_card_info_by_index(pa_context *c, uint32_t idx, pa_card_info_cb_t cb, void *userdata) { @@ -936,7 +1111,7 @@ static void context_get_module_info_callback(pa_pdispatch *pd, uint32_t command, goto finish; if (command != PA_COMMAND_REPLY) { - if (pa_context_handle_error(o->context, command, t, FALSE) < 0) + if (pa_context_handle_error(o->context, command, t, false) < 0) goto finish; eol = -1; @@ -944,7 +1119,7 @@ static void context_get_module_info_callback(pa_pdispatch *pd, uint32_t command, while (!pa_tagstruct_eof(t)) { pa_module_info i; - pa_bool_t auto_unload = FALSE; + bool auto_unload = false; pa_zero(i); i.proplist = pa_proplist_new(); @@ -1021,7 +1196,7 @@ static void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t comm goto finish; if (command != PA_COMMAND_REPLY) { - if (pa_context_handle_error(o->context, command, t, FALSE) < 0) + if (pa_context_handle_error(o->context, command, t, false) < 0) goto finish; eol = -1; @@ -1029,7 +1204,7 @@ static void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t comm while (!pa_tagstruct_eof(t)) { pa_sink_input_info i; - pa_bool_t mute = FALSE, corked = FALSE, has_volume = FALSE, volume_writable = TRUE; + bool mute = false, corked = false, has_volume = false, volume_writable = true; pa_zero(i); i.proplist = pa_proplist_new(); @@ -1126,7 +1301,7 @@ static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t c goto finish; if (command != PA_COMMAND_REPLY) { - if (pa_context_handle_error(o->context, command, t, FALSE) < 0) + if (pa_context_handle_error(o->context, command, t, false) < 0) goto finish; eol = -1; @@ -1134,10 +1309,11 @@ static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t c while (!pa_tagstruct_eof(t)) { pa_source_output_info i; - pa_bool_t corked = FALSE; + bool mute = false, corked = false, has_volume = false, volume_writable = true; pa_zero(i); i.proplist = pa_proplist_new(); + i.format = pa_format_info_new(); if (pa_tagstruct_getu32(t, &i.index) < 0 || pa_tagstruct_gets(t, &i.name) < 0 || @@ -1151,14 +1327,23 @@ static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t c pa_tagstruct_gets(t, &i.resample_method) < 0 || pa_tagstruct_gets(t, &i.driver) < 0 || (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0) || - (o->context->version >= 19 && pa_tagstruct_get_boolean(t, &corked) < 0)) { + (o->context->version >= 19 && pa_tagstruct_get_boolean(t, &corked) < 0) || + (o->context->version >= 22 && (pa_tagstruct_get_cvolume(t, &i.volume) < 0 || + pa_tagstruct_get_boolean(t, &mute) < 0 || + pa_tagstruct_get_boolean(t, &has_volume) < 0 || + pa_tagstruct_get_boolean(t, &volume_writable) < 0 || + pa_tagstruct_get_format_info(t, i.format) < 0))) { pa_context_fail(o->context, PA_ERR_PROTOCOL); pa_proplist_free(i.proplist); + pa_format_info_free(i.format); goto finish; } + i.mute = (int) mute; i.corked = (int) corked; + i.has_volume = (int) has_volume; + i.volume_writable = (int) volume_writable; if (o->callback) { pa_source_output_info_cb_t cb = (pa_source_output_info_cb_t) o->callback; @@ -1166,6 +1351,7 @@ static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t c } pa_proplist_free(i.proplist); + pa_format_info_free(i.format); } } @@ -1457,6 +1643,56 @@ pa_operation* pa_context_set_source_mute_by_name(pa_context *c, const char *name return o; } +pa_operation* pa_context_set_source_output_volume(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata) { + pa_operation *o; + pa_tagstruct *t; + uint32_t tag; + + pa_assert(c); + pa_assert(PA_REFCNT_VALUE(c) >= 1); + pa_assert(volume); + + PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); + PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); + PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); + PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 22, PA_ERR_NOTSUPPORTED); + PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID); + + o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); + + t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_OUTPUT_VOLUME, &tag); + pa_tagstruct_putu32(t, idx); + pa_tagstruct_put_cvolume(t, volume); + pa_pstream_send_tagstruct(c->pstream, t); + pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref); + + return o; +} + +pa_operation* pa_context_set_source_output_mute(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata) { + pa_operation *o; + pa_tagstruct *t; + uint32_t tag; + + pa_assert(c); + pa_assert(PA_REFCNT_VALUE(c) >= 1); + + PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); + PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); + PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); + PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 22, PA_ERR_NOTSUPPORTED); + + o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); + + t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_OUTPUT_MUTE, &tag); + pa_tagstruct_putu32(t, idx); + pa_tagstruct_put_boolean(t, mute); + pa_pstream_send_tagstruct(c->pstream, t); + pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref); + + return o; +} + /** Sample Cache **/ static void context_get_sample_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { @@ -1471,7 +1707,7 @@ static void context_get_sample_info_callback(pa_pdispatch *pd, uint32_t command, goto finish; if (command != PA_COMMAND_REPLY) { - if (pa_context_handle_error(o->context, command, t, FALSE) < 0) + if (pa_context_handle_error(o->context, command, t, false) < 0) goto finish; eol = -1; @@ -1479,7 +1715,7 @@ static void context_get_sample_info_callback(pa_pdispatch *pd, uint32_t command, while (!pa_tagstruct_eof(t)) { pa_sample_info i; - pa_bool_t lazy = FALSE; + bool lazy = false; pa_zero(i); i.proplist = pa_proplist_new(); @@ -1618,7 +1854,7 @@ static void context_index_callback(pa_pdispatch *pd, uint32_t command, uint32_t goto finish; if (command != PA_COMMAND_REPLY) { - if (pa_context_handle_error(o->context, command, t, FALSE) < 0) + if (pa_context_handle_error(o->context, command, t, false) < 0) goto finish; idx = PA_INVALID_INDEX; @@ -1633,7 +1869,6 @@ static void context_index_callback(pa_pdispatch *pd, uint32_t command, uint32_t cb(o->context, idx, o->userdata); } - finish: pa_operation_done(o); pa_operation_unref(o); @@ -1666,6 +1901,33 @@ pa_operation* pa_context_unload_module(pa_context *c, uint32_t idx, pa_context_s return command_kill(c, PA_COMMAND_UNLOAD_MODULE, idx, cb, userdata); } +pa_operation* pa_context_set_port_latency_offset(pa_context *c, const char *card_name, const char *port_name, int64_t offset, pa_context_success_cb_t cb, void *userdata) { + pa_operation *o; + pa_tagstruct *t; + uint32_t tag; + + pa_assert(c); + pa_assert(PA_REFCNT_VALUE(c) >= 1); + + PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); + PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); + PA_CHECK_VALIDITY_RETURN_NULL(c, card_name && *card_name, PA_ERR_INVALID); + PA_CHECK_VALIDITY_RETURN_NULL(c, port_name && *port_name, PA_ERR_INVALID); + PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 27, PA_ERR_NOTSUPPORTED); + + o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); + + t = pa_tagstruct_command(c, PA_COMMAND_SET_PORT_LATENCY_OFFSET, &tag); + pa_tagstruct_putu32(t, PA_INVALID_INDEX); + pa_tagstruct_puts(t, card_name); + pa_tagstruct_puts(t, port_name); + pa_tagstruct_puts64(t, offset); + pa_pstream_send_tagstruct(c->pstream, t); + pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref); + + return o; +} + /*** Autoload stuff ***/ PA_WARN_REFERENCE(pa_context_get_autoload_info_by_name, "Module auto-loading no longer supported.");