spa: use log topics

This commit is contained in:
Wim Taymans 2021-10-13 10:48:23 +02:00
parent eabd00e012
commit c8c4923fcb
9 changed files with 204 additions and 176 deletions

View file

@ -45,7 +45,9 @@
#include "fmt-ops.h"
#define NAME "splitter"
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT log_topic
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.splitter");
#define DEFAULT_RATE 48000
#define DEFAULT_CHANNELS 2
@ -203,7 +205,7 @@ static int init_port(struct impl *this, enum spa_direction direction,
port->format.media_subtype = SPA_MEDIA_SUBTYPE_dsp;
port->format.info.dsp.format = SPA_AUDIO_FORMAT_DSP_F32;
spa_log_debug(this->log, NAME " %p: init port %d:%d position:%s",
spa_log_debug(this->log, "%p: init port %d:%d position:%s",
this, direction, port_id, port->position);
emit_port_info(this, port, true);
@ -253,7 +255,7 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_log_debug(this->log, NAME " %p: io %d %p/%zd", this, id, data, size);
spa_log_debug(this->log, "%p: io %d %p/%zd", this, id, data, size);
switch (id) {
case SPA_IO_Position:
@ -327,7 +329,7 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
if (this->have_profile && memcmp(&this->format, &info, sizeof(info)) == 0)
return 0;
spa_log_debug(this->log, NAME " %p: port config %d/%d", this,
spa_log_debug(this->log, "%p: port config %d/%d", this,
info.info.raw.rate, info.info.raw.channels);
for (i = 0; i < this->port_count; i++)
@ -600,7 +602,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 %p", this, port);
spa_log_debug(this->log, "%p: clear buffers %p", this, port);
port->n_buffers = 0;
spa_list_init(&port->queue);
}
@ -622,7 +624,7 @@ static int setup_convert(struct impl *this)
src_fmt = informat.info.raw.format;
dst_fmt = SPA_AUDIO_FORMAT_DSP_F32;
spa_log_info(this->log, NAME " %p: %s/%d@%d->%s/%d@%dx%d", this,
spa_log_info(this->log, "%p: %s/%d@%d->%s/%d@%dx%d", this,
spa_debug_type_find_name(spa_type_audio_format, src_fmt),
informat.info.raw.channels,
informat.info.raw.rate,
@ -638,7 +640,7 @@ static int setup_convert(struct impl *this)
continue;
this->src_remap[i] = j;
this->dst_remap[j] = i;
spa_log_debug(this->log, NAME " %p: channel %d -> %d (%s -> %s)", this,
spa_log_debug(this->log, "%p: channel %d -> %d (%s -> %s)", this,
i, j,
spa_debug_type_find_short_name(spa_type_audio_channel,
informat.info.raw.position[i]),
@ -659,7 +661,7 @@ static int setup_convert(struct impl *this)
this->is_passthrough &= this->conv.is_passthrough;
spa_log_debug(this->log, NAME " %p: got converter features %08x:%08x passthrough:%d", this,
spa_log_debug(this->log, "%p: got converter features %08x:%08x passthrough:%d", this,
this->cpu_flags, this->conv.cpu_flags, this->is_passthrough);
return 0;
@ -699,7 +701,7 @@ static int port_set_latency(void *object,
enum spa_direction other = SPA_DIRECTION_REVERSE(direction);
uint32_t i;
spa_log_debug(this->log, NAME " %p: set latency direction:%d", this, direction);
spa_log_debug(this->log, "%p: set latency direction:%d", this, direction);
if (latency == NULL) {
this->latency[other] = SPA_LATENCY_INFO(other);
@ -735,7 +737,7 @@ static int port_set_format(void *object,
port = GET_PORT(this, direction, port_id);
spa_log_debug(this->log, NAME " %p: set format", this);
spa_log_debug(this->log, "%p: set format", this);
if (format == NULL) {
if (port->have_format) {
@ -784,7 +786,7 @@ static int port_set_format(void *object,
port->format = info;
spa_log_debug(this->log, NAME " %p: %d %d %d", this, port_id, port->stride, port->blocks);
spa_log_debug(this->log, "%p: %d %d %d", this, port_id, port->stride, port->blocks);
if (direction == SPA_DIRECTION_INPUT)
if ((res = setup_convert(this)) < 0)
@ -835,7 +837,7 @@ static void queue_buffer(struct impl *this, struct port *port, uint32_t id)
{
struct buffer *b = &port->buffers[id];
spa_log_trace_fp(this->log, NAME " %p: queue buffer %d on port %d %d",
spa_log_trace_fp(this->log, "%p: queue buffer %d on port %d %d",
this, id, port->id, b->flags);
if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_QUEUED))
return;
@ -854,7 +856,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_CLEAR(b->flags, BUFFER_FLAG_QUEUED);
spa_log_trace_fp(this->log, NAME " %p: dequeue buffer %d on port %d %u",
spa_log_trace_fp(this->log, "%p: dequeue buffer %d on port %d %u",
this, b->id, port->id, b->flags);
return b;
@ -879,7 +881,7 @@ impl_node_port_use_buffers(void *object,
spa_return_val_if_fail(port->have_format, -EIO);
spa_log_debug(this->log, NAME " %p: use buffers %d on port %d", this, n_buffers, port_id);
spa_log_debug(this->log, "%p: use buffers %d on port %d", this, n_buffers, port_id);
clear_buffers(this, port);
@ -895,12 +897,12 @@ impl_node_port_use_buffers(void *object,
for (j = 0; j < n_datas; j++) {
if (d[j].data == NULL) {
spa_log_error(this->log, NAME " %p: invalid memory %d on buffer %d %d %p",
spa_log_error(this->log, "%p: invalid memory %d on buffer %d %d %p",
this, j, i, d[j].type, d[j].data);
return -EINVAL;
}
if (!SPA_IS_ALIGNED(d[j].data, MAX_ALIGN)) {
spa_log_warn(this->log, NAME " %p: memory %d on buffer %d not aligned",
spa_log_warn(this->log, "%p: memory %d on buffer %d not aligned",
this, j, i);
}
b->datas[j] = d[j].data;
@ -908,7 +910,7 @@ impl_node_port_use_buffers(void *object,
!SPA_FLAG_IS_SET(d[j].flags, SPA_DATA_FLAG_DYNAMIC))
this->is_passthrough = false;
spa_log_debug(this->log, NAME " %p: buffer %d data %d flags:%08x %p",
spa_log_debug(this->log, "%p: buffer %d data %d flags:%08x %p",
this, i, j, d[j].flags, b->datas[j]);
}
@ -977,7 +979,7 @@ static int impl_node_process(void *object)
spa_return_val_if_fail(inio != NULL, -EIO);
spa_return_val_if_fail(this->conv.process != NULL, -EIO);
spa_log_trace_fp(this->log, NAME " %p: status %p %d %d", this,
spa_log_trace_fp(this->log, "%p: status %p %d %d", this,
inio, inio->status, inio->buffer_id);
if (SPA_UNLIKELY(inio->status != SPA_STATUS_HAVE_DATA))
@ -1012,7 +1014,7 @@ static int impl_node_process(void *object)
if (SPA_UNLIKELY((outio = outport->io) == NULL))
goto empty;
spa_log_trace_fp(this->log, NAME " %p: %d %p %d %d %d", this, i,
spa_log_trace_fp(this->log, "%p: %d %p %d %d %d", this, i,
outio, outio->status, outio->buffer_id, outport->stride);
if (SPA_UNLIKELY(outio->status == SPA_STATUS_HAVE_DATA))
@ -1026,7 +1028,7 @@ static int impl_node_process(void *object)
if (SPA_UNLIKELY((dbuf = dequeue_buffer(this, outport)) == NULL)) {
outio->status = -EPIPE;
empty:
spa_log_trace_fp(this->log, NAME" %p: %d skip output", this, i);
spa_log_trace_fp(this->log, "%p: %d skip output", this, i);
dst_datas[dst_remap] = SPA_PTR_ALIGN(this->empty, MAX_ALIGN, void);
continue;
}
@ -1048,7 +1050,7 @@ static int impl_node_process(void *object)
outio->buffer_id = dbuf->id;
}
spa_log_trace_fp(this->log, NAME " %p: n_src:%d n_dst:%d n_samples:%d max:%d stride:%d p:%d", this,
spa_log_trace_fp(this->log, "%p: n_src:%d n_dst:%d n_samples:%d max:%d stride:%d p:%d", this,
n_src_datas, n_dst_datas, n_samples, maxsize, inport->stride,
this->is_passthrough);
@ -1128,8 +1130,9 @@ impl_init(const struct spa_handle_factory *factory,
this = (struct impl *) handle;
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
this->cpu = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_CPU);
spa_log_topic_init(this->log, log_topic);
this->cpu = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_CPU);
if (this->cpu)
this->cpu_flags = spa_cpu_get_flags(this->cpu);