tagstruct: Distinguish pa_tagstruct_new() use cases

pa_tagstruct_new() is called either with no data, i.e. (NULL, 0)
to create a dynamic tagstruct or with a pointer to fixed data

introduce a new function pa_tagstruct_new_fixed() for the latter case

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
This commit is contained in:
Peter Meerwald 2014-10-23 16:09:45 +02:00 committed by Peter Meerwald
parent 7c223a6565
commit 037fdf485f
11 changed files with 70 additions and 57 deletions

View file

@ -195,7 +195,7 @@ static bool entry_write(struct userdata *u, const char *name, const struct entry
pa_assert(name);
pa_assert(e);
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu8(t, e->version);
pa_tagstruct_puts(t, e->profile);
pa_tagstruct_putu32(t, pa_hashmap_size(e->ports));
@ -273,7 +273,7 @@ static struct entry* entry_read(struct userdata *u, const char *name) {
return NULL;
}
t = pa_tagstruct_new(data.data, data.size);
t = pa_tagstruct_new_fixed(data.data, data.size);
e = entry_new();
if (pa_tagstruct_getu8(t, &e->version) < 0 ||

View file

@ -207,7 +207,7 @@ static bool entry_write(struct userdata *u, const char *name, const struct entry
pa_assert(name);
pa_assert(e);
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu8(t, e->version);
pa_tagstruct_puts(t, e->description);
pa_tagstruct_put_boolean(t, e->user_set_description);
@ -295,7 +295,7 @@ static struct entry* entry_read(struct userdata *u, const char *name) {
if (!pa_database_get(u->database, &key, &data))
goto fail;
t = pa_tagstruct_new(data.data, data.size);
t = pa_tagstruct_new_fixed(data.data, data.size);
e = entry_new();
if (pa_tagstruct_getu8(t, &e->version) < 0 ||
@ -449,7 +449,7 @@ static void notify_subscribers(struct userdata *u) {
PA_IDXSET_FOREACH(c, u->subscribed, idx) {
pa_tagstruct *t;
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu32(t, PA_COMMAND_EXTENSION);
pa_tagstruct_putu32(t, 0);
pa_tagstruct_putu32(t, u->module->index);
@ -1130,7 +1130,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
if (pa_tagstruct_getu32(t, &command) < 0)
goto fail;
reply = pa_tagstruct_new(NULL, 0);
reply = pa_tagstruct_new();
pa_tagstruct_putu32(reply, PA_COMMAND_REPLY);
pa_tagstruct_putu32(reply, tag);

View file

@ -151,7 +151,7 @@ static void trigger_save(struct userdata *u, pa_device_type_t type, uint32_t sin
PA_IDXSET_FOREACH(c, u->subscribed, idx) {
pa_tagstruct *t;
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu32(t, PA_COMMAND_EXTENSION);
pa_tagstruct_putu32(t, 0);
pa_tagstruct_putu32(t, u->module->index);
@ -200,7 +200,7 @@ static bool entry_write(struct userdata *u, const char *name, const struct entry
pa_assert(name);
pa_assert(e);
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu8(t, e->version);
pa_tagstruct_put_boolean(t, e->port_valid);
pa_tagstruct_puts(t, e->port);
@ -236,7 +236,7 @@ static struct entry* entry_read(struct userdata *u, const char *name) {
return NULL;
}
t = pa_tagstruct_new(data.data, data.size);
t = pa_tagstruct_new_fixed(data.data, data.size);
e = entry_new();
if (pa_tagstruct_getu8(t, &e->version) < 0 ||
@ -371,7 +371,7 @@ static bool perportentry_write(struct userdata *u, const char *basekeyname, cons
n_formats = pa_idxset_size(e->formats);
pa_assert(n_formats > 0);
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu8(t, e->version);
pa_tagstruct_put_boolean(t, e->volume_valid);
pa_tagstruct_put_channel_map(t, &e->channel_map);
@ -417,7 +417,7 @@ static struct perportentry* perportentry_read(struct userdata *u, const char *ba
if (!pa_database_get(u->database, &key, &data))
goto fail;
t = pa_tagstruct_new(data.data, data.size);
t = pa_tagstruct_new_fixed(data.data, data.size);
e = perportentry_new(false);
if (pa_tagstruct_getu8(t, &e->version) < 0 ||
@ -1041,7 +1041,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
if (pa_tagstruct_getu32(t, &command) < 0)
goto fail;
reply = pa_tagstruct_new(NULL, 0);
reply = pa_tagstruct_new();
pa_tagstruct_putu32(reply, PA_COMMAND_REPLY);
pa_tagstruct_putu32(reply, tag);

View file

@ -992,7 +992,7 @@ static bool entry_write(struct userdata *u, const char *name, const struct entry
pa_assert(name);
pa_assert(e);
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu8(t, e->version);
pa_tagstruct_put_boolean(t, e->volume_valid);
pa_tagstruct_put_channel_map(t, &e->channel_map);
@ -1124,7 +1124,7 @@ static struct entry *entry_read(struct userdata *u, const char *name) {
if (!pa_database_get(u->database, &key, &data))
goto fail;
t = pa_tagstruct_new(data.data, data.size);
t = pa_tagstruct_new_fixed(data.data, data.size);
e = entry_new();
if (pa_tagstruct_getu8(t, &e->version) < 0 ||
@ -1201,7 +1201,7 @@ static void trigger_save(struct userdata *u) {
PA_IDXSET_FOREACH(c, u->subscribed, idx) {
pa_tagstruct *t;
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu32(t, PA_COMMAND_EXTENSION);
pa_tagstruct_putu32(t, 0);
pa_tagstruct_putu32(t, u->module->index);
@ -2016,7 +2016,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
if (pa_tagstruct_getu32(t, &command) < 0)
goto fail;
reply = pa_tagstruct_new(NULL, 0);
reply = pa_tagstruct_new();
pa_tagstruct_putu32(reply, PA_COMMAND_REPLY);
pa_tagstruct_putu32(reply, tag);

View file

@ -447,7 +447,7 @@ static void stream_cork(struct userdata *u, bool cork) {
if (!u->pstream)
return;
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
#ifdef TUNNEL_SINK
pa_tagstruct_putu32(t, PA_COMMAND_CORK_PLAYBACK_STREAM);
#else
@ -880,7 +880,7 @@ static void request_latency(struct userdata *u) {
uint32_t tag;
pa_assert(u);
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
#ifdef TUNNEL_SINK
pa_tagstruct_putu32(t, PA_COMMAND_GET_PLAYBACK_LATENCY);
#else
@ -942,7 +942,7 @@ static void update_description(struct userdata *u) {
pa_get_user_name(un, sizeof(un)),
pa_get_host_name(hn, sizeof(hn)));
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
#ifdef TUNNEL_SINK
pa_tagstruct_putu32(t, PA_COMMAND_SET_PLAYBACK_STREAM_NAME);
#else
@ -1362,14 +1362,14 @@ static void request_info(struct userdata *u) {
uint32_t tag;
pa_assert(u);
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu32(t, PA_COMMAND_GET_SERVER_INFO);
pa_tagstruct_putu32(t, tag = u->ctag++);
pa_pstream_send_tagstruct(u->pstream, t);
pa_pdispatch_register_reply(u->pdispatch, tag, DEFAULT_TIMEOUT, server_info_cb, u, NULL);
#ifdef TUNNEL_SINK
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu32(t, PA_COMMAND_GET_SINK_INPUT_INFO);
pa_tagstruct_putu32(t, tag = u->ctag++);
pa_tagstruct_putu32(t, u->device_index);
@ -1377,7 +1377,7 @@ static void request_info(struct userdata *u) {
pa_pdispatch_register_reply(u->pdispatch, tag, DEFAULT_TIMEOUT, sink_input_info_cb, u, NULL);
if (u->sink_name) {
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu32(t, PA_COMMAND_GET_SINK_INFO);
pa_tagstruct_putu32(t, tag = u->ctag++);
pa_tagstruct_putu32(t, PA_INVALID_INDEX);
@ -1387,7 +1387,7 @@ static void request_info(struct userdata *u) {
}
#else
if (u->source_name) {
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu32(t, PA_COMMAND_GET_SOURCE_INFO);
pa_tagstruct_putu32(t, tag = u->ctag++);
pa_tagstruct_putu32(t, PA_INVALID_INDEX);
@ -1434,7 +1434,7 @@ static void start_subscribe(struct userdata *u) {
pa_tagstruct *t;
pa_assert(u);
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu32(t, PA_COMMAND_SUBSCRIBE);
pa_tagstruct_putu32(t, u->ctag++);
pa_tagstruct_putu32(t, PA_SUBSCRIPTION_MASK_SERVER|
@ -1619,7 +1619,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
pa_get_host_name(hn, sizeof(hn)));
#endif
reply = pa_tagstruct_new(NULL, 0);
reply = pa_tagstruct_new();
pa_tagstruct_putu32(reply, PA_COMMAND_SET_CLIENT_NAME);
pa_tagstruct_putu32(reply, u->ctag++);
@ -1637,7 +1637,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
pa_pstream_send_tagstruct(u->pstream, reply);
/* We ignore the server's reply here */
reply = pa_tagstruct_new(NULL, 0);
reply = pa_tagstruct_new();
if (u->version < 13)
/* Only for older PA versions we need to fill in the maxlength */
@ -1841,7 +1841,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
pa_pstream_set_receive_memblock_callback(u->pstream, pstream_memblock_callback, u);
#endif
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu32(t, PA_COMMAND_AUTH);
pa_tagstruct_putu32(t, tag = u->ctag++);
pa_tagstruct_putu32(t, PA_PROTOCOL_VERSION);
@ -1880,7 +1880,7 @@ static void sink_set_volume(pa_sink *sink) {
u = sink->userdata;
pa_assert(u);
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu32(t, PA_COMMAND_SET_SINK_INPUT_VOLUME);
pa_tagstruct_putu32(t, u->ctag++);
pa_tagstruct_putu32(t, u->device_index);
@ -1900,7 +1900,7 @@ static void sink_set_mute(pa_sink *sink) {
if (u->version < 11)
return;
t = pa_tagstruct_new(NULL, 0);
t = pa_tagstruct_new();
pa_tagstruct_putu32(t, PA_COMMAND_SET_SINK_INPUT_MUTE);
pa_tagstruct_putu32(t, u->ctag++);
pa_tagstruct_putu32(t, u->device_index);