introspect: Add functions to handle the latency offset.

This includes updating the native protocol and the client API.
A new command was added to allow setting the latency offset.

Also the card list command now shows the latency offset if there
are ports available.

Update protocol to 27.
This commit is contained in:
poljar (Damir Jelic) 2012-06-28 15:00:45 +02:00 committed by Tanu Kaskinen
parent 86996b4cc8
commit 529a5949fb
7 changed files with 101 additions and 6 deletions

View file

@ -763,8 +763,7 @@ 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)
{
static void card_info_free(pa_card_info* i) {
if (i->proplist)
pa_proplist_free(i->proplist);
@ -787,8 +786,7 @@ static void card_info_free(pa_card_info* i)
}
}
static int fill_card_port_info(pa_tagstruct* t, pa_card_info* i)
{
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)
@ -849,6 +847,11 @@ static int fill_card_port_info(pa_tagstruct* t, pa_card_info* i)
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;
@ -931,7 +934,7 @@ static void context_get_card_info_callback(pa_pdispatch *pd, uint32_t command, u
}
if (o->context->version >= 26) {
if (fill_card_port_info(t, &i) < 0) {
if (fill_card_port_info(o->context, t, &i) < 0) {
pa_context_fail(o->context, PA_ERR_PROTOCOL);
card_info_free(&i);
goto finish;
@ -1868,6 +1871,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.");