diff --git a/spa/plugins/avb/avb-pcm-source.c b/spa/plugins/avb/avb-pcm-source.c index 619dd53f7..f4ee0f826 100644 --- a/spa/plugins/avb/avb-pcm-source.c +++ b/spa/plugins/avb/avb-pcm-source.c @@ -712,8 +712,8 @@ static int impl_node_process(void *object) io = port->io; spa_return_val_if_fail(io != NULL, -EIO); - spa_log_trace_fp(this->log, "%p: process %d %d/%d", this, io->status, - io->buffer_id, port->n_buffers); + spa_log_trace_fp(this->log, "%p: process %d %d/%d %d", this, io->status, + io->buffer_id, port->n_buffers, this->following); if (io->status == SPA_STATUS_HAVE_DATA) return SPA_STATUS_HAVE_DATA; @@ -724,6 +724,7 @@ static int impl_node_process(void *object) } if (spa_list_is_empty(&port->ready) && this->following) { + spa_avb_read(this); } if (spa_list_is_empty(&port->ready) || !this->following) return SPA_STATUS_OK; diff --git a/spa/plugins/avb/avb-pcm.c b/spa/plugins/avb/avb-pcm.c index 49e934b1c..1117f6915 100644 --- a/spa/plugins/avb/avb-pcm.c +++ b/spa/plugins/avb/avb-pcm.c @@ -945,20 +945,22 @@ done: return 0; } -static int handle_capture(struct state *state, uint64_t current_time) +int spa_avb_read(struct state *state) { int32_t avail, wanted; uint32_t index; struct port *port = &state->ports[0]; - struct spa_io_buffers *io; struct buffer *b; + if (state->position) + state->duration = state->position->clock.duration; + avail = spa_ringbuffer_get_read_index(&state->ring, &index); wanted = state->duration * state->stride; if (avail < wanted) { spa_log_warn(state->log, "capture underrun %d < %d", avail, wanted); - goto done; + return 0; } while (avail >= wanted) { struct spa_data *d; @@ -990,6 +992,16 @@ static int handle_capture(struct state *state, uint64_t current_time) avail -= n_bytes; spa_ringbuffer_read_update(&state->ring, index); } + return 0; +} + +static int handle_capture(struct state *state, uint64_t current_time) +{ + struct port *port = &state->ports[0]; + struct spa_io_buffers *io; + struct buffer *b; + + spa_avb_read(state); if (spa_list_is_empty(&port->ready)) return 0; @@ -1009,7 +1021,6 @@ static int handle_capture(struct state *state, uint64_t current_time) spa_log_trace_fp(state->log, "%p: output buffer:%d", state, b->id); } spa_node_call_ready(&state->callbacks, SPA_STATUS_HAVE_DATA); -done: return 0; } @@ -1133,6 +1144,8 @@ int spa_avb_start(struct state *state) spa_dll_init(&state->dll); state->max_error = (256.0 * state->rate) / state->rate_denom; + state->following = is_following(state); + state->timer_source.func = avb_on_timeout_event; state->timer_source.data = state; state->timer_source.fd = state->timerfd;