mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-07-21 10:16:14 +00:00
pulse-server: message: use union to store event data
Store subscription event data in a union instead of just an array for better readability.
This commit is contained in:
parent
d467f6fdc6
commit
46e4a33f27
|
@ -310,11 +310,11 @@ static bool client_prune_subscribe_events(struct client *client, uint32_t event,
|
|||
|
||||
/* NOTE: reverse iteration */
|
||||
spa_list_for_each_safe_reverse(m, t, &client->out_messages, link) {
|
||||
if (m->extra[0] != COMMAND_SUBSCRIBE_EVENT)
|
||||
if (m->type != MESSAGE_TYPE_SUBSCRIPTION_EVENT)
|
||||
continue;
|
||||
if ((m->extra[1] ^ event) & SUBSCRIPTION_EVENT_FACILITY_MASK)
|
||||
if ((m->u.subscription_event.event ^ event) & SUBSCRIPTION_EVENT_FACILITY_MASK)
|
||||
continue;
|
||||
if (m->extra[2] != index)
|
||||
if (m->u.subscription_event.index != index)
|
||||
continue;
|
||||
|
||||
if ((event & SUBSCRIPTION_EVENT_TYPE_MASK) == SUBSCRIPTION_EVENT_REMOVE) {
|
||||
|
@ -322,7 +322,7 @@ static bool client_prune_subscribe_events(struct client *client, uint32_t event,
|
|||
* point in keeping the old events regarding
|
||||
* entry in the queue. */
|
||||
|
||||
bool is_new = (m->extra[1] & SUBSCRIPTION_EVENT_TYPE_MASK) == SUBSCRIPTION_EVENT_NEW;
|
||||
bool is_new = (m->u.subscription_event.event & SUBSCRIPTION_EVENT_TYPE_MASK) == SUBSCRIPTION_EVENT_NEW;
|
||||
|
||||
if (drop_from_out_queue(client, m)) {
|
||||
pw_log_debug("client %p: dropped redundant event due to remove event for object %u",
|
||||
|
@ -371,9 +371,9 @@ int client_queue_subscribe_event(struct client *client, uint32_t mask, uint32_t
|
|||
if (!reply)
|
||||
return -errno;
|
||||
|
||||
reply->extra[0] = COMMAND_SUBSCRIBE_EVENT;
|
||||
reply->extra[1] = event;
|
||||
reply->extra[2] = index;
|
||||
reply->type = MESSAGE_TYPE_SUBSCRIPTION_EVENT;
|
||||
reply->u.subscription_event.event = event;
|
||||
reply->u.subscription_event.index = index;
|
||||
|
||||
message_put(reply,
|
||||
TAG_U32, COMMAND_SUBSCRIBE_EVENT,
|
||||
|
|
|
@ -847,7 +847,7 @@ struct message *message_alloc(struct impl *impl, uint32_t channel, uint32_t size
|
|||
return NULL;
|
||||
}
|
||||
|
||||
spa_zero(msg->extra);
|
||||
msg->type = MESSAGE_TYPE_UNSPECIFIED;
|
||||
msg->channel = channel;
|
||||
msg->offset = 0;
|
||||
msg->length = size;
|
||||
|
|
|
@ -13,15 +13,27 @@
|
|||
|
||||
struct impl;
|
||||
|
||||
enum message_type {
|
||||
MESSAGE_TYPE_UNSPECIFIED,
|
||||
MESSAGE_TYPE_SUBSCRIPTION_EVENT,
|
||||
};
|
||||
|
||||
struct message {
|
||||
struct spa_list link;
|
||||
struct impl *impl;
|
||||
uint32_t extra[4];
|
||||
uint32_t channel;
|
||||
uint32_t allocated;
|
||||
uint32_t length;
|
||||
uint32_t offset;
|
||||
uint8_t *data;
|
||||
|
||||
enum message_type type;
|
||||
union {
|
||||
struct {
|
||||
uint32_t event;
|
||||
uint32_t index;
|
||||
} subscription_event;
|
||||
} u;
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
Loading…
Reference in a new issue