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

@ -292,6 +292,7 @@ static void command_remove_proplist(pa_pdispatch *pd, uint32_t command, uint32_t
static void command_extension(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
static void command_set_card_profile(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
static void command_set_sink_or_source_port(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
static void command_set_port_latency_offset(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
static const pa_pdispatch_cb_t command_table[PA_COMMAND_MAX] = {
[PA_COMMAND_ERROR] = NULL,
@ -393,6 +394,8 @@ static const pa_pdispatch_cb_t command_table[PA_COMMAND_MAX] = {
[PA_COMMAND_SET_SINK_PORT] = command_set_sink_or_source_port,
[PA_COMMAND_SET_SOURCE_PORT] = command_set_sink_or_source_port,
[PA_COMMAND_SET_PORT_LATENCY_OFFSET] = command_set_port_latency_offset,
[PA_COMMAND_EXTENSION] = command_extension
};
@ -3272,6 +3275,9 @@ static void card_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_car
PA_HASHMAP_FOREACH(p, port->profiles, state2)
pa_tagstruct_puts(t, p->name);
if (c->version >= 27)
pa_tagstruct_puts64(t, port->latency_offset);
}
}
@ -4719,6 +4725,46 @@ static void command_set_sink_or_source_port(pa_pdispatch *pd, uint32_t command,
pa_pstream_send_simple_ack(c->pstream, tag);
}
static void command_set_port_latency_offset(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_native_connection *c = PA_NATIVE_CONNECTION(userdata);
const char *port_name, *card_name;
uint32_t idx = PA_INVALID_INDEX;
int64_t offset;
pa_card *card = NULL;
pa_device_port *port = NULL;
pa_native_connection_assert_ref(c);
pa_assert(t);
if (pa_tagstruct_getu32(t, &idx) < 0 ||
pa_tagstruct_gets(t, &card_name) < 0 ||
pa_tagstruct_gets(t, &port_name) < 0 ||
pa_tagstruct_gets64(t, &offset) < 0 ||
!pa_tagstruct_eof(t)) {
protocol_error(c);
}
CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
CHECK_VALIDITY(c->pstream, !card_name || pa_namereg_is_valid_name(card_name), tag, PA_ERR_INVALID);
CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || card_name, tag, PA_ERR_INVALID);
CHECK_VALIDITY(c->pstream, idx == PA_INVALID_INDEX || !card_name, tag, PA_ERR_INVALID);
CHECK_VALIDITY(c->pstream, port_name, tag, PA_ERR_INVALID);
if (idx != PA_INVALID_INDEX)
card = pa_idxset_get_by_index(c->protocol->core->cards, idx);
else
card = pa_namereg_get(c->protocol->core, card_name, PA_NAMEREG_CARD);
CHECK_VALIDITY(c->pstream, card, tag, PA_ERR_NOENTITY);
port = pa_hashmap_get(card->ports, port_name);
CHECK_VALIDITY(c->pstream, port, tag, PA_ERR_NOENTITY);
pa_device_port_set_latency_offset(port, offset);
pa_pstream_send_simple_ack(c->pstream, tag);
}
/*** pstream callbacks ***/
static void pstream_packet_callback(pa_pstream *p, pa_packet *packet, const pa_creds *creds, void *userdata) {