spa: use log topics everywhere

Use log topics properly everywhere, convert from "#define NAME".
This commit is contained in:
Pauli Virtanen 2024-03-10 17:32:56 +02:00
parent c963ca47c1
commit e784de3933
27 changed files with 170 additions and 102 deletions

View file

@ -22,7 +22,9 @@
#include <spa/pod/parser.h>
#include <spa/pod/filter.h>
#define NAME "fakesink"
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT &log_topic
SPA_LOG_TOPIC_DEFINE_STATIC(log_topic, "spa.fakesink");
struct props {
bool live;
@ -205,7 +207,7 @@ static inline int read_timer(struct impl *this)
if ((res = spa_system_timerfd_read(this->data_system,
this->timer_source.fd, &expirations)) < 0) {
if (res != -EAGAIN)
spa_log_error(this->log, NAME " %p: timerfd error: %s",
spa_log_error(this->log, "%p: timerfd error: %s",
this, spa_strerror(res));
}
}
@ -231,7 +233,7 @@ static int consume_buffer(struct impl *this)
spa_node_call_ready(&this->callbacks, SPA_STATUS_NEED_DATA);
}
if (spa_list_is_empty(&port->ready)) {
spa_log_error(this->log, NAME " %p: no buffers", this);
spa_log_error(this->log, "%p: no buffers", this);
return -EPIPE;
}
@ -240,7 +242,7 @@ static int consume_buffer(struct impl *this)
n_bytes = b->outbuf->datas[0].maxsize;
spa_log_trace(this->log, NAME " %p: dequeue buffer %d", this, b->id);
spa_log_trace(this->log, "%p: dequeue buffer %d", this, b->id);
render_buffer(this, b);
@ -505,7 +507,7 @@ impl_node_port_enum_params(void *object, int seq,
static int clear_buffers(struct impl *this, struct port *port)
{
if (port->n_buffers > 0) {
spa_log_debug(this->log, NAME " %p: clear buffers", this);
spa_log_debug(this->log, "%p: clear buffers", this);
port->n_buffers = 0;
spa_list_init(&port->ready);
this->started = false;
@ -583,7 +585,7 @@ impl_node_port_use_buffers(void *object,
b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h));
if (d[0].data == NULL) {
spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this,
spa_log_error(this->log, "%p: invalid memory on buffer %p", this,
buffers[i]);
}
}
@ -635,13 +637,13 @@ static int impl_node_process(void *object)
struct buffer *b = &port->buffers[io->buffer_id];
if (!b->outstanding) {
spa_log_warn(this->log, NAME " %p: buffer %u in use", this,
spa_log_warn(this->log, "%p: buffer %u in use", this,
io->buffer_id);
io->status = -EINVAL;
return -EINVAL;
}
spa_log_trace(this->log, NAME " %p: queue buffer %u", this, io->buffer_id);
spa_log_trace(this->log, "%p: queue buffer %u", this, io->buffer_id);
spa_list_append(&port->ready, &b->link);
b->outstanding = false;
@ -818,7 +820,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_fakesink_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
"fakesink",
NULL,
impl_get_size,
impl_init,

View file

@ -22,7 +22,9 @@
#include <spa/pod/parser.h>
#include <spa/pod/filter.h>
#define NAME "fakesrc"
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT &log_topic
SPA_LOG_TOPIC_DEFINE_STATIC(log_topic, "spa.fakesrc");
struct props {
bool live;
@ -220,7 +222,7 @@ static inline int read_timer(struct impl *this)
if ((res = spa_system_timerfd_read(this->data_system,
this->timer_source.fd, &expirations)) < 0) {
if (res != -EAGAIN)
spa_log_error(this->log, NAME " %p: timerfd error: %s",
spa_log_error(this->log, "%p: timerfd error: %s",
this, spa_strerror(res));
}
}
@ -240,7 +242,7 @@ static int make_buffer(struct impl *this)
if (spa_list_is_empty(&port->empty)) {
set_timer(this, false);
this->underrun = true;
spa_log_error(this->log, NAME " %p: out of buffers", this);
spa_log_error(this->log, "%p: out of buffers", this);
return -EPIPE;
}
b = spa_list_first(&port->empty, struct buffer, link);
@ -249,7 +251,7 @@ static int make_buffer(struct impl *this)
n_bytes = b->outbuf->datas[0].maxsize;
spa_log_trace(this->log, NAME " %p: dequeue buffer %d", this, b->id);
spa_log_trace(this->log, "%p: dequeue buffer %d", this, b->id);
fill_buffer(this, b);
@ -518,7 +520,7 @@ impl_node_port_enum_params(void *object, int seq,
static int clear_buffers(struct impl *this, struct port *port)
{
if (port->n_buffers > 0) {
spa_log_debug(this->log, NAME " %p: clear buffers", this);
spa_log_debug(this->log, "%p: clear buffers", this);
port->n_buffers = 0;
spa_list_init(&port->empty);
this->started = false;
@ -595,7 +597,7 @@ impl_node_port_use_buffers(void *object,
b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h));
if (d[0].data == NULL) {
spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this,
spa_log_error(this->log, "%p: invalid memory on buffer %p", this,
buffers[i]);
}
spa_list_append(&port->empty, &b->link);
@ -633,7 +635,7 @@ static inline void reuse_buffer(struct impl *this, struct port *port, uint32_t i
struct buffer *b = &port->buffers[id];
spa_return_if_fail(b->outstanding);
spa_log_trace(this->log, NAME " %p: reuse buffer %d", this, id);
spa_log_trace(this->log, "%p: reuse buffer %d", this, id);
b->outstanding = false;
spa_list_append(&port->empty, &b->link);
@ -848,7 +850,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_fakesrc_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
"fakesrc",
NULL,
impl_get_size,
impl_init,

View file

@ -5,10 +5,13 @@
#include <errno.h>
#include <spa/support/plugin.h>
#include <spa/support/log.h>
extern const struct spa_handle_factory spa_fakesrc_factory;
extern const struct spa_handle_factory spa_fakesink_factory;
SPA_LOG_TOPIC_ENUM_DEFINE_REGISTERED;
SPA_EXPORT
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
{