pulse-server: use define for monitor flags

This commit is contained in:
Wim Taymans 2020-11-17 11:28:06 +01:00
parent 242cddd371
commit f818da96fc
2 changed files with 11 additions and 7 deletions

View file

@ -52,6 +52,10 @@
#define SCACHE_ENTRY_SIZE_MAX (1024*1024*16) #define SCACHE_ENTRY_SIZE_MAX (1024*1024*16)
#define INDEX_MASK 0xffffu
#define MONITOR_FLAG (1u << 16)
#define EXTENSION_FLAG (1u << 17)
enum error_code { enum error_code {
ERR_OK = 0, /**< No error */ ERR_OK = 0, /**< No error */
ERR_ACCESS, /**< Access failure */ ERR_ACCESS, /**< Access failure */

View file

@ -624,7 +624,7 @@ static uint32_t get_event_and_id(struct client *client, struct pw_manager_object
else if (client->subscribed & SUBSCRIPTION_MASK_SOURCE && else if (client->subscribed & SUBSCRIPTION_MASK_SOURCE &&
is_source_or_monitor(o)) { is_source_or_monitor(o)) {
if (!is_source(o)) if (!is_source(o))
res_id |= 0x10000U; res_id |= MONITOR_FLAG;
event = SUBSCRIPTION_EVENT_SOURCE; event = SUBSCRIPTION_EVENT_SOURCE;
} }
else if (client->subscribed & SUBSCRIPTION_MASK_SINK_INPUT && else if (client->subscribed & SUBSCRIPTION_MASK_SINK_INPUT &&
@ -1112,7 +1112,7 @@ static int reply_create_record_stream(struct stream *stream)
name = pw_properties_get(peer->props, PW_KEY_NODE_NAME); name = pw_properties_get(peer->props, PW_KEY_NODE_NAME);
if (!is_source(peer)) { if (!is_source(peer)) {
size_t len = (name ? strlen(name) : 5) + 10; size_t len = (name ? strlen(name) : 5) + 10;
peer_id = peer->id | 0x10000u; peer_id = peer->id | MONITOR_FLAG;
peer_name = tmp = alloca(len); peer_name = tmp = alloca(len);
snprintf(tmp, len, "%s.monitor", name ? name : "sink"); snprintf(tmp, len, "%s.monitor", name ? name : "sink");
} else { } else {
@ -1866,8 +1866,8 @@ static int do_create_record_stream(struct client *client, uint32_t command, uint
source_index = id; source_index = id;
} }
if (source_index != SPA_ID_INVALID) { if (source_index != SPA_ID_INVALID) {
if (source_index & 0x10000u) if (source_index & MONITOR_FLAG)
source_index &= 0xffffu; source_index &= INDEX_MASK;
pw_properties_setf(props, pw_properties_setf(props,
PW_KEY_NODE_TARGET, "%u", source_index); PW_KEY_NODE_TARGET, "%u", source_index);
} else if (source_name != NULL) { } else if (source_name != NULL) {
@ -3333,7 +3333,7 @@ static int fill_sink_info(struct client *client, struct message *m,
TAG_U32, module_id, /* module index */ TAG_U32, module_id, /* module index */
TAG_CVOLUME, &dev_info.volume_info.volume, TAG_CVOLUME, &dev_info.volume_info.volume,
TAG_BOOLEAN, dev_info.volume_info.mute, TAG_BOOLEAN, dev_info.volume_info.mute,
TAG_U32, o->id | 0x10000U, /* monitor source */ TAG_U32, o->id | MONITOR_FLAG, /* monitor source */
TAG_STRING, monitor_name, /* monitor source name */ TAG_STRING, monitor_name, /* monitor source name */
TAG_USEC, 0LL, /* latency */ TAG_USEC, 0LL, /* latency */
TAG_STRING, "PipeWire", /* driver */ TAG_STRING, "PipeWire", /* driver */
@ -3454,7 +3454,7 @@ static int fill_source_info(struct client *client, struct message *m,
flags |= SOURCE_HW_MUTE_CTRL; flags |= SOURCE_HW_MUTE_CTRL;
message_put(m, message_put(m,
TAG_U32, is_monitor ? o->id | 0x10000 : o->id, /* source index */ TAG_U32, is_monitor ? o->id | MONITOR_FLAG: o->id, /* source index */
TAG_STRING, is_monitor ? monitor_name : name, TAG_STRING, is_monitor ? monitor_name : name,
TAG_STRING, is_monitor ? monitor_desc : desc, TAG_STRING, is_monitor ? monitor_desc : desc,
TAG_SAMPLE_SPEC, &dev_info.ss, TAG_SAMPLE_SPEC, &dev_info.ss,
@ -3617,7 +3617,7 @@ static int fill_source_output_info(struct client *client, struct message *m,
if (peer && is_source_or_monitor(peer)) { if (peer && is_source_or_monitor(peer)) {
peer_id = peer->id; peer_id = peer->id;
if (!is_source(peer)) if (!is_source(peer))
peer_id |= 0x10000u; peer_id |= MONITOR_FLAG;
} else { } else {
peer_id = SPA_ID_INVALID; peer_id = SPA_ID_INVALID;
} }