On Thu, 2012-06-28 at 15:00 +0200, poljar (Damir Jeli?) wrote: > From: "poljar (Damir Jelic)" <poljarinho at gmail.com> > > 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. Looks very good. Will push soon. I did one change, described below: > +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, !card_name || idx == PA_INVALID_INDEX, tag, PA_ERR_INVALID); I claim that the last check is redundant. There are two error cases that need to be caught: when card_name is NULL and idx is INVALID (caught by the first check), and when card_name is not NULL and idx is not INVALID (caught by both the second and third checks). -- Tanu