Add FASTPATH trace log

Add a trace_fp that can be optimized away when FASTPATH is defined.
This commit is contained in:
Wim Taymans 2019-03-21 11:31:53 +01:00
parent 036ca89c0e
commit 5a2ccee1ff
17 changed files with 98 additions and 87 deletions

View file

@ -115,6 +115,12 @@ struct spa_log {
#define spa_log_debug(l,...) spa_log_log(l,SPA_LOG_LEVEL_DEBUG,__FILE__,__LINE__,__func__,__VA_ARGS__)
#define spa_log_trace(l,...) spa_log_log(l,SPA_LOG_LEVEL_TRACE,__FILE__,__LINE__,__func__,__VA_ARGS__)
#ifndef FASTPATH
#define spa_log_trace_fp(l,...) spa_log_log(l,SPA_LOG_LEVEL_TRACE,__FILE__,__LINE__,__func__,__VA_ARGS__)
#else
#define spa_log_trace_fp(l,...)
#endif
#else
#define SPA_LOG_FUNC(name,lev) \
@ -134,6 +140,12 @@ SPA_LOG_FUNC(info, SPA_LOG_LEVEL_INFO)
SPA_LOG_FUNC(debug, SPA_LOG_LEVEL_DEBUG)
SPA_LOG_FUNC(trace, SPA_LOG_LEVEL_TRACE)
#ifndef FASTPATH
SPA_LOG_FUNC(trace_fp, SPA_LOG_LEVEL_TRACE)
#else
static inline void spa_log_trace_fp (struct spa_log *l, const char *format, ...) { }
#endif
#endif
#ifdef __cplusplus
} /* extern "C" */

View file

@ -619,7 +619,7 @@ static int impl_node_process(struct spa_node *node)
input = this->io;
spa_return_val_if_fail(input != NULL, -EIO);
spa_log_trace(this->log, NAME " %p: process %d %d/%d", this, input->status,
spa_log_trace_fp(this->log, NAME " %p: process %d %d/%d", this, input->status,
input->buffer_id,
this->n_buffers);
@ -633,7 +633,7 @@ static int impl_node_process(struct spa_node *node)
input->status = -EINVAL;
return -EINVAL;
}
spa_log_trace(this->log, NAME " %p: queue buffer %u", this, input->buffer_id);
spa_log_trace_fp(this->log, NAME " %p: queue buffer %u", this, input->buffer_id);
spa_list_append(&this->ready, &b->link);
SPA_FLAG_UNSET(b->flags, BUFFER_FLAG_OUT);
input->buffer_id = SPA_ID_INVALID;

View file

@ -313,7 +313,7 @@ static void recycle_buffer(struct state *this, uint32_t buffer_id)
struct buffer *b = &this->buffers[buffer_id];
if (SPA_FLAG_CHECK(b->flags, BUFFER_FLAG_OUT)) {
spa_log_trace(this->log, NAME " %p: recycle buffer %u", this, buffer_id);
spa_log_trace_fp(this->log, NAME " %p: recycle buffer %u", this, buffer_id);
spa_list_append(&this->free, &b->link);
SPA_FLAG_UNSET(b->flags, BUFFER_FLAG_OUT);
}
@ -653,7 +653,7 @@ static int impl_node_process(struct spa_node *node)
b = spa_list_first(&this->ready, struct buffer, link);
spa_list_remove(&b->link);
spa_log_trace(this->log, NAME " %p: dequeue buffer %d", node, b->id);
spa_log_trace_fp(this->log, NAME " %p: dequeue buffer %d", node, b->id);
io->buffer_id = b->id;
io->status = SPA_STATUS_HAVE_BUFFER;

View file

@ -634,7 +634,7 @@ static int update_time(struct state *state, uint64_t nsec, snd_pcm_sframes_t del
}
#endif
spa_log_trace(state->log, "%"PRIu64" %f %"PRIi64" %"PRIi64" %"PRIi64" %d %"PRIu64" %f %f", nsec,
spa_log_trace_fp(state->log, "%"PRIu64" %f %"PRIi64" %"PRIi64" %"PRIi64" %d %"PRIu64" %f %f", nsec,
state->old_dt, delay, elapsed, (int64_t)(nsec - state->last_time),
state->threshold, state->next_time, tw, extra);
@ -666,7 +666,7 @@ int spa_alsa_write(struct state *state, snd_pcm_uframes_t silence, bool start)
if ((res = update_time(state, nsec, delay, true)) < 0)
return res;
spa_log_trace(state->log, "slave %f %"PRIi64" %"PRIu64" %d",
spa_log_trace_fp(state->log, "slave %f %"PRIi64" %"PRIu64" %d",
state->dll.dt, nsec, delay, state->rate);
if (delay > state->threshold * 2) {
@ -682,7 +682,7 @@ again:
spa_log_error(state->log, "snd_pcm_mmap_begin error: %s", snd_strerror(res));
return res;
}
spa_log_trace(state->log, "begin %ld %ld %d", offset, frames, state->threshold);
spa_log_trace_fp(state->log, "begin %ld %ld %d", offset, frames, state->threshold);
silence = SPA_MIN(silence, frames);
to_write = frames;
@ -726,7 +726,7 @@ again:
spa_list_remove(&b->link);
SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUT);
state->io->buffer_id = b->id;
spa_log_trace(state->log, "alsa-util %p: reuse buffer %u", state, b->id);
spa_log_trace_fp(state->log, "alsa-util %p: reuse buffer %u", state, b->id);
state->callbacks->reuse_buffer(state->callbacks_data, 0, b->id);
state->ready_offset = 0;
}
@ -740,12 +740,12 @@ again:
}
if (silence > 0) {
spa_log_trace(state->log, "silence %ld", silence);
spa_log_trace_fp(state->log, "silence %ld", silence);
snd_pcm_areas_silence(my_areas, off, state->channels, silence, state->format);
written += silence;
}
spa_log_trace(state->log, "commit %ld %ld %"PRIi64, offset, written, state->sample_count);
spa_log_trace_fp(state->log, "commit %ld %ld %"PRIi64, offset, written, state->sample_count);
total_written += written;
if ((res = snd_pcm_mmap_commit(hndl, offset, written)) < 0) {
@ -840,7 +840,6 @@ static int handle_play(struct state *state)
int res;
snd_pcm_sframes_t delay;
uint64_t nsec;
int64_t jitter;
if (state->position && state->threshold != state->position->size)
state->threshold = state->position->size;
@ -850,9 +849,9 @@ static int handle_play(struct state *state)
return 0;
nsec = SPA_TIMESPEC_TO_NSEC(&state->now);
jitter = nsec - state->next_time;
spa_log_trace(state->log, "timeout %ld %"PRIu64" %"PRIu64" %"PRIi64" %d %ld", delay,
nsec, state->next_time, jitter, state->threshold, state->sample_count);
spa_log_trace_fp(state->log, "timeout %ld %"PRIu64" %"PRIu64" %"PRIi64" %d %ld", delay,
nsec, state->next_time, nsec - state->next_time,
state->threshold, state->sample_count);
if (delay >= state->threshold * 2) {
spa_log_trace(state->log, "early wakeup %ld %d", delay, state->threshold);
@ -866,7 +865,7 @@ static int handle_play(struct state *state)
if (spa_list_is_empty(&state->ready)) {
struct spa_io_buffers *io = state->io;
spa_log_trace(state->log, "alsa-util %p: %d", state, io->status);
spa_log_trace_fp(state->log, "alsa-util %p: %d", state, io->status);
io->status = SPA_STATUS_NEED_BUFFER;
if (state->range) {
@ -904,7 +903,6 @@ static void alsa_on_capture_timeout_event(struct spa_source *source)
snd_pcm_sframes_t delay;
snd_pcm_uframes_t total_read = 0, to_read;
const snd_pcm_channel_area_t *my_areas;
int64_t jitter;
if (state->started && read(state->timerfd, &expire, sizeof(uint64_t)) != sizeof(uint64_t))
spa_log_warn(state->log, "error reading timerfd: %s", strerror(errno));
@ -917,9 +915,9 @@ static void alsa_on_capture_timeout_event(struct spa_source *source)
return;
nsec = SPA_TIMESPEC_TO_NSEC(&state->now);
jitter = nsec - state->next_time;
spa_log_trace(state->log, "timeout %ld %"PRIu64" %"PRIu64" %"PRIi64" %d %ld", delay,
nsec, state->next_time, jitter, state->threshold, state->sample_count);
spa_log_trace_fp(state->log, "timeout %ld %"PRIu64" %"PRIu64" %"PRIi64" %d %ld", delay,
nsec, state->next_time, nsec - state->next_time,
state->threshold, state->sample_count);
if (delay < state->threshold) {
spa_log_trace(state->log, "early wakeup %ld %d", delay, state->threshold);
@ -936,7 +934,7 @@ static void alsa_on_capture_timeout_event(struct spa_source *source)
snd_pcm_uframes_t read, frames, offset;
frames = to_read - total_read;
spa_log_trace(state->log, "begin %ld %ld %ld %ld", offset, frames, to_read, total_read);
spa_log_trace_fp(state->log, "begin %ld %ld %ld %ld", offset, frames, to_read, total_read);
if ((res = snd_pcm_mmap_begin(hndl, &my_areas, &offset, &frames)) < 0) {
spa_log_error(state->log, "snd_pcm_mmap_begin error: %s", snd_strerror(res));
return;
@ -946,7 +944,7 @@ static void alsa_on_capture_timeout_event(struct spa_source *source)
if (read < frames)
to_read = 0;
spa_log_trace(state->log, "commit %ld %ld", offset, read);
spa_log_trace_fp(state->log, "commit %ld %ld", offset, read);
if ((res = snd_pcm_mmap_commit(hndl, offset, read)) < 0) {
spa_log_error(state->log, "snd_pcm_mmap_commit error: %s", snd_strerror(res));
if (res != -EPIPE && res != -ESTRPIPE)

View file

@ -870,14 +870,14 @@ static int impl_node_process(struct spa_node *node)
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_log_trace(this->log, NAME " %p: process %d", this, this->n_links);
spa_log_trace_fp(this->log, NAME " %p: process %d", this, this->n_links);
while (1) {
res = SPA_STATUS_OK;
ready = 0;
for (i = 0; i < this->n_nodes; i++) {
r = spa_node_process(this->nodes[i]);
spa_log_trace(this->log, NAME " %p: process %d %d", this, i, r);
spa_log_trace_fp(this->log, NAME " %p: process %d %d", this, i, r);
if (r < 0)
return r;
@ -896,7 +896,7 @@ static int impl_node_process(struct spa_node *node)
break;
}
spa_log_trace(this->log, NAME " %p: process result: %d", this, res);
spa_log_trace_fp(this->log, NAME " %p: process result: %d", this, res);
return res;
}

View file

@ -1028,7 +1028,7 @@ static void recycle_buffer(struct impl *this, uint32_t id)
if (SPA_FLAG_CHECK(b->flags, BUFFER_FLAG_OUT)) {
spa_list_append(&port->queue, &b->link);
SPA_FLAG_UNSET(b->flags, BUFFER_FLAG_OUT);
spa_log_trace(this->log, NAME " %p: recycle buffer %d", this, id);
spa_log_trace_fp(this->log, NAME " %p: recycle buffer %d", this, id);
}
}
@ -1098,7 +1098,7 @@ static int impl_node_process(struct spa_node *node)
spa_return_val_if_fail(outio != NULL, -EIO);
spa_return_val_if_fail(inio != NULL, -EIO);
spa_log_trace(this->log, NAME " %p: status %d %d", this, inio->status, outio->status);
spa_log_trace_fp(this->log, NAME " %p: status %d %d", this, inio->status, outio->status);
if (outport->control)
process_control(this, outport, &outport->control->sequence);

View file

@ -758,7 +758,7 @@ static void recycle_buffer(struct impl *this, struct port *port, uint32_t id)
if (SPA_FLAG_CHECK(b->flags, BUFFER_FLAG_OUT)) {
spa_list_append(&port->queue, &b->link);
SPA_FLAG_UNSET(b->flags, BUFFER_FLAG_OUT);
spa_log_trace(this->log, NAME " %p: recycle buffer %d", this, id);
spa_log_trace_fp(this->log, NAME " %p: recycle buffer %d", this, id);
}
}
@ -817,7 +817,7 @@ static int impl_node_process(struct spa_node *node)
inio = inport->io;
spa_return_val_if_fail(inio != NULL, -EIO);
spa_log_trace(this->log, NAME " %p: status %p %d %d -> %p %d %d", this,
spa_log_trace_fp(this->log, NAME " %p: status %p %d %d -> %p %d %d", this,
inio, inio->status, inio->buffer_id,
outio, outio->status, outio->buffer_id);
@ -860,7 +860,7 @@ static int impl_node_process(struct spa_node *node)
maxsize = SPA_MIN(outport->ctrl->max_size, maxsize);
n_samples = SPA_MIN(n_samples, maxsize / outport->stride);
spa_log_trace(this->log, NAME " %p: n_src:%d n_dst:%d size:%d maxsize:%d n_samples:%d",
spa_log_trace_fp(this->log, NAME " %p: n_src:%d n_dst:%d size:%d maxsize:%d n_samples:%d",
this, n_src_datas, n_dst_datas, size, maxsize, n_samples);
n_datas = SPA_MAX(n_src_datas, n_dst_datas);

View file

@ -714,7 +714,7 @@ static void queue_buffer(struct impl *this, struct port *port, uint32_t id)
{
struct buffer *b = &port->buffers[id];
spa_log_trace(this->log, NAME " %p: queue buffer %d on port %d %d",
spa_log_trace_fp(this->log, NAME " %p: queue buffer %d on port %d %d",
this, id, port->id, b->flags);
if (SPA_FLAG_CHECK(b->flags, BUFFER_FLAG_QUEUED))
return;
@ -733,7 +733,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_log_trace(this->log, NAME " %p: dequeue buffer %d on port %d %u",
spa_log_trace_fp(this->log, NAME " %p: dequeue buffer %d on port %d %u",
this, b->id, port->id, b->flags);
return b;
@ -872,7 +872,7 @@ static inline int get_in_buffer(struct impl *this, struct port *port, struct buf
if ((io = port->io) == NULL ||
io->status != SPA_STATUS_HAVE_BUFFER ||
io->buffer_id >= port->n_buffers) {
spa_log_trace(this->log, NAME " %p: empty port %d %p %d %d %d",
spa_log_trace_fp(this->log, NAME " %p: empty port %d %p %d %d %d",
this, port->id, io, io->status, io->buffer_id,
port->n_buffers);
return -EPIPE;
@ -944,7 +944,7 @@ static int impl_node_process(struct spa_node *node)
spa_return_val_if_fail(outio != NULL, -EIO);
spa_return_val_if_fail(this->convert != NULL, -EIO);
spa_log_trace(this->log, NAME " %p: status %d %d", this, outio->status, outio->buffer_id);
spa_log_trace_fp(this->log, NAME " %p: status %d %d", this, outio->status, outio->buffer_id);
if ((res = get_out_buffer(this, outport, &dbuf)) != 0)
return res;
@ -977,7 +977,7 @@ static int impl_node_process(struct spa_node *node)
n_samples = SPA_MIN(n_samples, sd->chunk->size / inport->stride);
spa_log_trace(this->log, NAME " %p: %d %d %d %p", this,
spa_log_trace_fp(this->log, NAME " %p: %d %d %d %p", this,
sd->chunk->size, maxsize, n_samples, src_datas[i]);
SPA_FLAG_SET(res, SPA_STATUS_NEED_BUFFER);
@ -991,7 +991,7 @@ static int impl_node_process(struct spa_node *node)
dbuf->buf->datas[i].data = dst_datas[i];
dbuf->buf->datas[i].chunk->offset = 0;
dbuf->buf->datas[i].chunk->size = n_samples * outport->stride;
spa_log_trace(this->log, NAME " %p %p %d", this, dst_datas[i],
spa_log_trace_fp(this->log, NAME " %p %p %d", this, dst_datas[i],
n_samples * outport->stride);
}
if (!this->is_passthrough)

View file

@ -669,7 +669,7 @@ static void recycle_buffer(struct impl *this, uint32_t id)
if (SPA_FLAG_CHECK(b->flags, BUFFER_FLAG_OUT)) {
spa_list_append(&port->queue, &b->link);
SPA_FLAG_UNSET(b->flags, BUFFER_FLAG_OUT);
spa_log_trace(this->log, NAME " %p: recycle buffer %d", this, id);
spa_log_trace_fp(this->log, NAME " %p: recycle buffer %d", this, id);
}
}
@ -744,7 +744,8 @@ static int impl_node_process(struct spa_node *node)
spa_return_val_if_fail(outio != NULL, -EIO);
spa_return_val_if_fail(inio != NULL, -EIO);
spa_log_trace(this->log, NAME " %p: status %d %d %p", this, inio->status, outio->status, outport->io_control);
spa_log_trace_fp(this->log, NAME " %p: status %d %d %p",
this, inio->status, outio->status, outport->io_control);
if (outport->io_control)
process_control(this, outport, &outport->io_control->sequence);
@ -791,7 +792,7 @@ static int impl_node_process(struct spa_node *node)
resample_process(&this->resample, i, src, &in_len, dst, &out_len);
spa_log_trace(this->log, NAME " %p: in %d/%d %ld %d out %d/%d %ld %d",
spa_log_trace_fp(this->log, NAME " %p: in %d/%d %ld %d out %d/%d %ld %d",
this, pin_len, in_len, size / sizeof(float), inport->offset,
pout_len, out_len, maxsize / sizeof(float), outport->offset);

View file

@ -683,7 +683,7 @@ static void queue_buffer(struct impl *this, struct port *port, uint32_t id)
{
struct buffer *b = &port->buffers[id];
spa_log_trace(this->log, NAME " %p: queue buffer %d on port %d %d",
spa_log_trace_fp(this->log, NAME " %p: queue buffer %d on port %d %d",
this, id, port->id, b->flags);
if (SPA_FLAG_CHECK(b->flags, BUFFER_FLAG_QUEUED))
return;
@ -702,7 +702,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_log_trace(this->log, NAME " %p: dequeue buffer %d on port %d %u",
spa_log_trace_fp(this->log, NAME " %p: dequeue buffer %d on port %d %u",
this, b->id, port->id, b->flags);
return b;
@ -848,7 +848,7 @@ static int impl_node_process(struct spa_node *node)
spa_return_val_if_fail(inio != NULL, -EIO);
spa_return_val_if_fail(this->convert != NULL, -EIO);
spa_log_trace(this->log, NAME " %p: status %p %d %d", this,
spa_log_trace_fp(this->log, NAME " %p: status %p %d %d", this,
inio, inio->status, inio->buffer_id);
if (inio->status != SPA_STATUS_HAVE_BUFFER)
@ -880,7 +880,7 @@ static int impl_node_process(struct spa_node *node)
if ((outio = outport->io) == NULL)
goto empty;
spa_log_trace(this->log, NAME " %p: %d %p %d %d %d", this, i,
spa_log_trace_fp(this->log, NAME " %p: %d %p %d %d %d", this, i,
outio, outio->status, outio->buffer_id, outport->stride);
if (outio->status == SPA_STATUS_HAVE_BUFFER) {
@ -920,7 +920,7 @@ static int impl_node_process(struct spa_node *node)
res |= SPA_STATUS_HAVE_BUFFER;
}
spa_log_trace(this->log, NAME " %p: %d %d %d %d %d", this,
spa_log_trace_fp(this->log, NAME " %p: %d %d %d %d %d", this,
n_src_datas, n_dst_datas, n_samples, maxsize, inport->stride);
if (!this->is_passthrough)