flags: change flag macros

SPA_FLAG_CHECK -> SPA_FLAG_IS_SET
SPA_FLAG_UNSET -> SPA_FLAG_CLEAR
Add SPA_FLAG_UPDATE
This commit is contained in:
Wim Taymans 2019-10-02 17:58:04 +02:00
parent cc8e992cd1
commit 6e0ffb0c47
33 changed files with 91 additions and 92 deletions

View file

@ -366,7 +366,7 @@ static int add_port_update(struct pw_proxy *proxy, struct pw_port *port, uint32_
pi.flags = port->spa_flags;
pi.rate = SPA_FRACTION(0, 1);
pi.props = &port->properties->dict;
SPA_FLAG_UNSET(pi.flags, SPA_PORT_FLAG_DYNAMIC_DATA);
SPA_FLAG_CLEAR(pi.flags, SPA_PORT_FLAG_DYNAMIC_DATA);
pi.n_params = port->info.n_params;
pi.params = port->info.params;
}

View file

@ -204,10 +204,7 @@ client_busy_changed(void *data, bool busy)
c->busy = busy;
if (busy)
SPA_FLAG_UNSET(mask, SPA_IO_IN);
else
SPA_FLAG_SET(mask, SPA_IO_IN);
SPA_FLAG_UPDATE(mask, SPA_IO_IN, !busy);
pw_log_debug(NAME" %p: busy changed %d", client->protocol, busy);
pw_loop_update_io(client->core->main_loop, c->source, mask);
@ -238,7 +235,7 @@ connection_data(void *data, int fd, uint32_t mask)
res = pw_protocol_native_connection_flush(this->connection);
if (res >= 0) {
int mask = this->source->mask;
SPA_FLAG_UNSET(mask, SPA_IO_OUT);
SPA_FLAG_CLEAR(mask, SPA_IO_OUT);
pw_loop_update_io(client->protocol->core->main_loop,
this->source, mask);
} else if (res != EAGAIN) {
@ -540,7 +537,7 @@ on_remote_data(void *data, int fd, uint32_t mask)
res = pw_protocol_native_connection_flush(conn);
if (res >= 0) {
int mask = impl->source->mask;
SPA_FLAG_UNSET(mask, SPA_IO_OUT);
SPA_FLAG_CLEAR(mask, SPA_IO_OUT);
pw_loop_update_io(core->main_loop,
impl->source, mask);
impl->flushing = false;

View file

@ -100,7 +100,7 @@ pw_spa_device_new(struct pw_core *core,
pw_device_add_listener(this, &impl->device_listener, &device_events, impl);
pw_device_set_implementation(this, impl->device);
if (!SPA_FLAG_CHECK(impl->flags, PW_SPA_DEVICE_FLAG_NO_REGISTER)) {
if (!SPA_FLAG_IS_SET(impl->flags, PW_SPA_DEVICE_FLAG_NO_REGISTER)) {
if ((res = pw_device_register(this, NULL)) < 0)
goto error_register;
}

View file

@ -79,10 +79,10 @@ static void complete_init(struct impl *impl)
impl->init_pending = SPA_ID_INVALID;
if (SPA_FLAG_CHECK(impl->flags, PW_SPA_NODE_FLAG_ACTIVATE))
if (SPA_FLAG_IS_SET(impl->flags, PW_SPA_NODE_FLAG_ACTIVATE))
pw_node_set_active(this, true);
if (!SPA_FLAG_CHECK(impl->flags, PW_SPA_NODE_FLAG_NO_REGISTER))
if (!SPA_FLAG_IS_SET(impl->flags, PW_SPA_NODE_FLAG_NO_REGISTER))
pw_node_register(this, NULL);
else
pw_node_initialized(this);

View file

@ -436,7 +436,7 @@ static int clear_buffers(struct impl *this, struct port *port)
static int queue_buffer(struct impl *this, struct port *port, struct buffer *b)
{
if (SPA_FLAG_CHECK(b->flags, BUFFER_FLAG_QUEUED))
if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_QUEUED))
return -EINVAL;
spa_list_append(&port->queue, &b->link);
@ -454,7 +454,7 @@ static struct buffer *dequeue_buffer(struct impl *this, struct port *port)
b = spa_list_first(&port->queue, struct buffer, link);
spa_list_remove(&b->link);
SPA_FLAG_UNSET(b->flags, BUFFER_FLAG_QUEUED);
SPA_FLAG_CLEAR(b->flags, BUFFER_FLAG_QUEUED);
spa_log_trace_fp(this->log, NAME " %p: dequeue buffer %d", this, b->id);
return b;
}
@ -730,7 +730,8 @@ static int impl_node_process(void *object)
(inio = inport->io) == NULL ||
inio->buffer_id >= inport->n_buffers ||
inio->status != SPA_STATUS_HAVE_DATA) {
spa_log_trace_fp(this->log, NAME " %p: skip input %d %d %p %d %d %d", this,
spa_log_trace_fp(this->log, NAME " %p: skip input idx:%d valid:%d "
"io:%p status:%d buf_id:%d n_buffers:%d", this,
i, inport->valid, inio,
inio ? inio->status : -1,
inio ? inio->buffer_id : SPA_ID_INVALID,

View file

@ -1637,7 +1637,7 @@ pw_node_find_port(struct pw_node *node, enum pw_direction direction, uint32_t po
break;
}
/* We can use this port if it can multiplex */
if (SPA_FLAG_CHECK(p->mix_flags, PW_PORT_MIX_FLAG_MULTI))
if (SPA_FLAG_IS_SET(p->mix_flags, PW_PORT_MIX_FLAG_MULTI))
port = p;
}
}
@ -1659,12 +1659,12 @@ uint32_t pw_node_get_free_port_id(struct pw_node *node, enum pw_direction direct
max_ports = node->info.max_input_ports;
n_ports = node->info.n_input_ports;
portmap = &node->input_port_map;
dynamic = SPA_FLAG_CHECK(node->spa_flags, SPA_NODE_FLAG_IN_DYNAMIC_PORTS);
dynamic = SPA_FLAG_IS_SET(node->spa_flags, SPA_NODE_FLAG_IN_DYNAMIC_PORTS);
} else {
max_ports = node->info.max_output_ports;
n_ports = node->info.n_output_ports;
portmap = &node->output_port_map;
dynamic = SPA_FLAG_CHECK(node->spa_flags, SPA_NODE_FLAG_OUT_DYNAMIC_PORTS);
dynamic = SPA_FLAG_IS_SET(node->spa_flags, SPA_NODE_FLAG_OUT_DYNAMIC_PORTS);
}
pw_log_debug(NAME" %p: direction %s n_ports:%u max_ports:%u",
node, pw_direction_as_string(direction), n_ports, max_ports);

View file

@ -384,9 +384,9 @@ struct pw_port *pw_port_new(enum pw_direction direction,
}
if (info) {
if (SPA_FLAG_CHECK(info->flags, SPA_PORT_FLAG_PHYSICAL))
if (SPA_FLAG_IS_SET(info->flags, SPA_PORT_FLAG_PHYSICAL))
pw_properties_set(properties, PW_KEY_PORT_PHYSICAL, "1");
if (SPA_FLAG_CHECK(info->flags, SPA_PORT_FLAG_TERMINAL))
if (SPA_FLAG_IS_SET(info->flags, SPA_PORT_FLAG_TERMINAL))
pw_properties_set(properties, PW_KEY_PORT_TERMINAL, "1");
this->spa_flags = info->flags;
}
@ -850,7 +850,7 @@ static void pw_port_remove(struct pw_port *port)
pw_loop_invoke(port->node->data_loop, do_remove_port,
SPA_ID_INVALID, NULL, 0, true, port);
if (SPA_FLAG_CHECK(port->flags, PW_PORT_FLAG_TO_REMOVE)) {
if (SPA_FLAG_IS_SET(port->flags, PW_PORT_FLAG_TO_REMOVE)) {
if ((res = spa_node_remove_port(node->node, port->direction, port->port_id)) < 0)
pw_log_warn(NAME" %p: can't remove: %s", port, spa_strerror(res));
}

View file

@ -222,7 +222,7 @@ static inline int push_queue(struct stream *stream, struct queue *queue, struct
{
uint32_t index;
if (SPA_FLAG_CHECK(buffer->flags, BUFFER_FLAG_QUEUED))
if (SPA_FLAG_IS_SET(buffer->flags, BUFFER_FLAG_QUEUED))
return -EINVAL;
SPA_FLAG_SET(buffer->flags, BUFFER_FLAG_QUEUED);
@ -251,7 +251,7 @@ static inline struct buffer *pop_queue(struct stream *stream, struct queue *queu
buffer = &stream->buffers[id];
queue->outcount += buffer->this.size;
SPA_FLAG_UNSET(buffer->flags, BUFFER_FLAG_QUEUED);
SPA_FLAG_CLEAR(buffer->flags, BUFFER_FLAG_QUEUED);
return buffer;
}
@ -304,7 +304,7 @@ do_call_process(struct spa_loop *loop,
static void call_process(struct stream *impl)
{
pw_log_trace(NAME" %p: call process", impl);
if (SPA_FLAG_CHECK(impl->flags, PW_STREAM_FLAG_RT_PROCESS)) {
if (SPA_FLAG_IS_SET(impl->flags, PW_STREAM_FLAG_RT_PROCESS)) {
do_call_process(NULL, false, 1, NULL, 0, impl);
}
else {
@ -624,7 +624,7 @@ static void clear_buffers(struct pw_stream *stream)
pw_stream_emit_remove_buffer(stream, &b->this);
if (SPA_FLAG_CHECK(b->flags, BUFFER_FLAG_MAPPED)) {
if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_MAPPED)) {
for (j = 0; j < b->this.buffer->n_datas; j++) {
struct spa_data *d = &b->this.buffer->datas[j];
pw_log_debug(NAME" %p: clear buffer %d mem",
@ -663,7 +663,7 @@ static int impl_port_use_buffers(void *object,
b->flags = 0;
b->id = i;
if (SPA_FLAG_CHECK(impl_flags, PW_STREAM_FLAG_MAP_BUFFERS)) {
if (SPA_FLAG_IS_SET(impl_flags, PW_STREAM_FLAG_MAP_BUFFERS)) {
for (j = 0; j < buffers[i]->n_datas; j++) {
struct spa_data *d = &buffers[i]->datas[j];
if (d->type == SPA_DATA_MemFd ||
@ -814,7 +814,7 @@ again:
}
}
if (!impl->draining && !SPA_FLAG_CHECK(impl->flags, PW_STREAM_FLAG_DRIVER)) {
if (!impl->draining && !SPA_FLAG_IS_SET(impl->flags, PW_STREAM_FLAG_DRIVER)) {
call_process(impl);
if (spa_ringbuffer_get_read_index(&impl->queued.ring, &index) >= MIN_QUEUED &&
io->status == SPA_STATUS_NEED_DATA)
@ -1056,7 +1056,7 @@ static int handle_connect(struct pw_stream *stream)
pw_node_set_implementation(slave, &impl->impl_node);
if (!SPA_FLAG_CHECK(impl->flags, PW_STREAM_FLAG_INACTIVE))
if (!SPA_FLAG_IS_SET(impl->flags, PW_STREAM_FLAG_INACTIVE))
pw_node_set_active(slave, true);
if (impl->media_type == SPA_MEDIA_TYPE_audio &&
@ -1486,7 +1486,7 @@ pw_stream_connect(struct pw_stream *stream,
if (flags & PW_STREAM_FLAG_DONT_RECONNECT)
pw_properties_set(stream->properties, PW_KEY_NODE_DONT_RECONNECT, "1");
impl->alloc_buffers = SPA_FLAG_CHECK(flags, PW_STREAM_FLAG_ALLOC_BUFFERS);
impl->alloc_buffers = SPA_FLAG_IS_SET(flags, PW_STREAM_FLAG_ALLOC_BUFFERS);
pw_properties_setf(stream->properties, PW_KEY_MEDIA_CLASS, "Stream/%s/%s",
direction == PW_DIRECTION_INPUT ? "Input" : "Output",
@ -1669,7 +1669,7 @@ do_process(struct spa_loop *loop,
static inline int call_trigger(struct stream *impl)
{
int res = 0;
if (SPA_FLAG_CHECK(impl->flags, PW_STREAM_FLAG_DRIVER)) {
if (SPA_FLAG_IS_SET(impl->flags, PW_STREAM_FLAG_DRIVER)) {
res = pw_loop_invoke(impl->core->data_loop,
do_process, 1, NULL, 0, false, impl);
}

View file

@ -289,7 +289,7 @@ static void node_event_info(void *object, const struct pw_node_info *info)
if (old != NULL && info->params[i].flags == old->params[i].flags)
continue;
remove_params(data, info->params[i].id, 0);
if (!SPA_FLAG_CHECK(info->params[i].flags, SPA_PARAM_INFO_READ))
if (!SPA_FLAG_IS_SET(info->params[i].flags, SPA_PARAM_INFO_READ))
continue;
pw_node_proxy_enum_params((struct pw_node_proxy*)data->proxy,
0, info->params[i].id, 0, 0, NULL);
@ -349,7 +349,7 @@ static void port_event_info(void *object, const struct pw_port_info *info)
if (old != NULL && info->params[i].flags == old->params[i].flags)
continue;
remove_params(data, info->params[i].id, 0);
if (!SPA_FLAG_CHECK(info->params[i].flags, SPA_PARAM_INFO_READ))
if (!SPA_FLAG_IS_SET(info->params[i].flags, SPA_PARAM_INFO_READ))
continue;
pw_port_proxy_enum_params((struct pw_port_proxy*)data->proxy,
0, info->params[i].id, 0, 0, NULL);
@ -528,7 +528,7 @@ static void device_event_info(void *object, const struct pw_device_info *info)
if (old != NULL && info->params[i].flags == old->params[i].flags)
continue;
remove_params(data, info->params[i].id, 0);
if (!SPA_FLAG_CHECK(info->params[i].flags, SPA_PARAM_INFO_READ))
if (!SPA_FLAG_IS_SET(info->params[i].flags, SPA_PARAM_INFO_READ))
continue;
pw_device_proxy_enum_params((struct pw_device_proxy*)data->proxy,
0, info->params[i].id, 0, 0, NULL);