small cleanups

This commit is contained in:
Wim Taymans 2018-05-17 17:26:09 +02:00
parent 65e00631da
commit c61d579d99
9 changed files with 34 additions and 19 deletions

View file

@ -601,7 +601,8 @@ static int impl_node_process(struct spa_node *node)
spa_list_append(&this->ready, &b->link); spa_list_append(&this->ready, &b->link);
SPA_FLAG_UNSET(b->flags, BUFFER_FLAG_OUT); SPA_FLAG_UNSET(b->flags, BUFFER_FLAG_OUT);
this->threshold = b->buf->datas[0].chunk->size / this->frame_size; this->threshold = SPA_MIN(b->buf->datas[0].chunk->size / this->frame_size,
this->props.max_latency);
spa_alsa_write(this, 0); spa_alsa_write(this, 0);

View file

@ -47,7 +47,7 @@ int spa_alsa_close(struct state *state)
if (!state->opened) if (!state->opened)
return 0; return 0;
spa_log_info(state->log, "Device closing"); spa_log_info(state->log, "Device '%s' closing", state->props.device);
CHECK(snd_pcm_close(state->hndl), "close failed"); CHECK(snd_pcm_close(state->hndl), "close failed");
close(state->timerfd); close(state->timerfd);

View file

@ -372,12 +372,14 @@ static int negotiate_link_buffers(struct impl *this, struct link *link)
spa_pod_fixate(param); spa_pod_fixate(param);
if (link->in_info) if (link->in_info)
in_alloc = SPA_FLAG_CHECK(link->in_info->flags, SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS); in_alloc = SPA_FLAG_CHECK(link->in_info->flags,
SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS);
else else
in_alloc = false; in_alloc = false;
if (link->out_info) if (link->out_info)
out_alloc = SPA_FLAG_CHECK(link->out_info->flags, SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS); out_alloc = SPA_FLAG_CHECK(link->out_info->flags,
SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS);
else else
out_alloc = false; out_alloc = false;

View file

@ -721,8 +721,11 @@ impl_node_port_set_io(struct spa_node *node,
port = GET_PORT(this, direction, port_id); port = GET_PORT(this, direction, port_id);
if (id == t->io.Buffers) if (id == t->io.Buffers) {
spa_log_trace(this->log, NAME " %p: port %d update buffer io %p",
this, port_id, data);
port->io = data; port->io = data;
}
else else
return -ENOENT; return -ENOENT;
@ -801,7 +804,8 @@ static int impl_node_process(struct spa_node *node)
spa_return_val_if_fail(outio != NULL, -EIO); spa_return_val_if_fail(outio != NULL, -EIO);
spa_return_val_if_fail(inio != 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(this->log, NAME " %p: status %p %d %p %d", this,
inio, inio->status, outio, outio->status);
if (outio->status != SPA_STATUS_NEED_BUFFER) if (outio->status != SPA_STATUS_NEED_BUFFER)
return outio->status; return outio->status;

View file

@ -54,7 +54,7 @@ struct props {
#define MAX_BUFFERS 32 #define MAX_BUFFERS 32
struct buffer { struct buffer {
struct spa_buffer *outbuf; struct spa_buffer *buf;
struct spa_meta_header *h; struct spa_meta_header *h;
bool outstanding; bool outstanding;
struct spa_list link; struct spa_list link;
@ -182,7 +182,7 @@ struct impl {
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) == 0) #define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) == 0)
static const uint32_t default_min_latency = 1024; static const uint32_t default_min_latency = 128;
static const uint32_t default_max_latency = 1024; static const uint32_t default_max_latency = 1024;
static void reset_props(struct props *props) static void reset_props(struct props *props)
@ -502,7 +502,7 @@ static int flush_data(struct impl *this, uint64_t now_time)
uint32_t index, offs, avail, l0, l1; uint32_t index, offs, avail, l0, l1;
b = spa_list_first(&this->ready, struct buffer, link); b = spa_list_first(&this->ready, struct buffer, link);
d = b->outbuf->datas; d = b->buf->datas;
src = d[0].data; src = d[0].data;
@ -530,8 +530,8 @@ static int flush_data(struct impl *this, uint64_t now_time)
if (this->ready_offset >= d[0].chunk->size) { if (this->ready_offset >= d[0].chunk->size) {
spa_list_remove(&b->link); spa_list_remove(&b->link);
b->outstanding = true; b->outstanding = true;
spa_log_trace(this->log, "a2dp-sink %p: reuse buffer %u", this, b->outbuf->id); spa_log_trace(this->log, "a2dp-sink %p: reuse buffer %u", this, b->buf->id);
this->callbacks->reuse_buffer(this->callbacks_data, 0, b->outbuf->id); this->callbacks->reuse_buffer(this->callbacks_data, 0, b->buf->id);
this->ready_offset = 0; this->ready_offset = 0;
} }
total_frames += n_frames; total_frames += n_frames;
@ -1174,10 +1174,10 @@ impl_node_port_use_buffers(struct spa_node *node,
struct buffer *b = &this->buffers[i]; struct buffer *b = &this->buffers[i];
uint32_t type; uint32_t type;
b->outbuf = buffers[i]; b->buf = buffers[i];
b->outstanding = true; b->outstanding = true;
b->h = spa_buffer_find_meta(b->outbuf, this->type.meta.Header); b->h = spa_buffer_find_meta(b->buf, this->type.meta.Header);
type = buffers[i]->datas[0].type; type = buffers[i]->datas[0].type;
if ((type == this->type.data.MemFd || if ((type == this->type.data.MemFd ||
@ -1186,6 +1186,7 @@ impl_node_port_use_buffers(struct spa_node *node,
spa_log_error(this->log, NAME " %p: need mapped memory", this); spa_log_error(this->log, NAME " %p: need mapped memory", this);
return -EINVAL; return -EINVAL;
} }
this->threshold = buffers[i]->datas[0].maxsize / this->frame_size;
} }
this->n_buffers = n_buffers; this->n_buffers = n_buffers;
@ -1281,6 +1282,9 @@ static int impl_node_process(struct spa_node *node)
spa_list_append(&this->ready, &b->link); spa_list_append(&this->ready, &b->link);
b->outstanding = false; b->outstanding = false;
this->threshold = SPA_MIN(b->buf->datas[0].chunk->size / this->frame_size,
this->props.max_latency);
clock_gettime(CLOCK_MONOTONIC, &this->now); clock_gettime(CLOCK_MONOTONIC, &this->now);
now_time = this->now.tv_sec * SPA_NSEC_PER_SEC + this->now.tv_nsec; now_time = this->now.tv_sec * SPA_NSEC_PER_SEC + this->now.tv_nsec;

View file

@ -333,6 +333,8 @@ static int link_session_dsp(struct session *session)
struct pw_port *op, *ip; struct pw_port *op, *ip;
char *error = NULL; char *error = NULL;
pw_log_debug("module %p: link session dsp '%d'", impl, session->id);
if (session->direction == PW_DIRECTION_OUTPUT) { if (session->direction == PW_DIRECTION_OUTPUT) {
op = session->dsp_port; op = session->dsp_port;
ip = session->node_port; ip = session->node_port;

View file

@ -226,7 +226,7 @@ process_messages(struct client_data *data)
goto invalid_message; goto invalid_message;
if (debug_messages) { if (debug_messages) {
printf("<<<<<<<<< in: %d %d %d\n", id, opcode, size); fprintf(stderr, "<<<<<<<<< in: %d %d %d\n", id, opcode, size);
spa_debug_pod((struct spa_pod *)message, 0); spa_debug_pod((struct spa_pod *)message, 0);
} }
if (demarshal[opcode].func(resource, message, size) < 0) if (demarshal[opcode].func(resource, message, size) < 0)
@ -560,7 +560,7 @@ on_remote_data(void *data, int fd, enum spa_io mask)
} }
} }
if (debug_messages) { if (debug_messages) {
printf("<<<<<<<<< in: %d %d %d\n", id, opcode, size); fprintf(stderr, "<<<<<<<<< in: %d %d %d\n", id, opcode, size);
spa_debug_pod((struct spa_pod *)message, 0); spa_debug_pod((struct spa_pod *)message, 0);
} }
if (demarshal[opcode].func(proxy, message, size) < 0) { if (demarshal[opcode].func(proxy, message, size) < 0) {

View file

@ -431,10 +431,11 @@ pw_protocol_native_connection_end(struct pw_protocol_native_connection *conn,
buf->buffer_size += 8 + size; buf->buffer_size += 8 + size;
if (debug_messages) { if (debug_messages) {
printf(">>>>>>>>> out: %d %d %d\n", impl->dest_id, impl->opcode, size); fprintf(stderr, ">>>>>>>>> out: %d %d %d\n", impl->dest_id, impl->opcode, size);
spa_debug_pod((struct spa_pod *)p, 0); spa_debug_pod((struct spa_pod *)p, 0);
} }
spa_hook_list_call(&conn->listener_list, struct pw_protocol_native_connection_events, need_flush); spa_hook_list_call(&conn->listener_list,
struct pw_protocol_native_connection_events, need_flush);
} }
/** Flush the connection object /** Flush the connection object

View file

@ -224,6 +224,7 @@ static int configure_converter(struct stream *impl)
return -ENOTSUP; return -ENOTSUP;
if (impl->io != &impl->conv_io) { if (impl->io != &impl->conv_io) {
pw_log_debug("stream %p: update io %p %p", impl, impl->io, &impl->conv_io);
res = spa_node_port_set_io(impl->convert, res = spa_node_port_set_io(impl->convert,
impl->direction, 0, impl->direction, 0,
t->io.Buffers, t->io.Buffers,
@ -751,11 +752,11 @@ static int impl_node_process_output(struct spa_node *node)
if ((b = pop_queue(impl, &impl->queued)) != NULL) { if ((b = pop_queue(impl, &impl->queued)) != NULL) {
io->buffer_id = b->id; io->buffer_id = b->id;
io->status = SPA_STATUS_HAVE_BUFFER; io->status = SPA_STATUS_HAVE_BUFFER;
pw_log_trace("stream %p: pop %d", stream, b->id); pw_log_trace("stream %p: pop %d %p", stream, b->id, io);
} else { } else {
io->buffer_id = SPA_ID_INVALID; io->buffer_id = SPA_ID_INVALID;
io->status = SPA_STATUS_NEED_BUFFER; io->status = SPA_STATUS_NEED_BUFFER;
pw_log_trace("stream %p: no more buffers", stream); pw_log_trace("stream %p: no more buffers %p", stream, io);
} }
} }
if (io->status == SPA_STATUS_HAVE_BUFFER && impl->use_converter) { if (io->status == SPA_STATUS_HAVE_BUFFER && impl->use_converter) {