echo-cancel: drop if playback is not streaming

capture and sink streams may start before playback stream so process()
may fail to dequeue a playback buffer. In that case advance the read
pointers to avoid building up latency in the ringbuffers.
This commit is contained in:
Jonas Holmberg 2025-07-03 16:51:21 +02:00 committed by Wim Taymans
parent 019b53ace8
commit a0beb30ba8

View file

@ -309,11 +309,6 @@ static void process(struct impl *impl)
uint32_t i, size;
uint32_t rindex, pindex, oindex, pdindex, avail;
if (impl->playback != NULL && (pout = pw_stream_dequeue_buffer(impl->playback)) == NULL) {
pw_log_debug("out of playback buffers: %m");
goto done;
}
size = impl->aec_blocksize;
/* First read a block from the playback and capture ring buffers */
@ -338,6 +333,16 @@ static void process(struct impl *impl)
spa_ringbuffer_get_read_index(&impl->play_ring, &pindex);
spa_ringbuffer_get_read_index(&impl->play_delayed_ring, &pdindex);
if (impl->playback != NULL && (pout = pw_stream_dequeue_buffer(impl->playback)) == NULL) {
pw_log_debug("out of playback buffers: %m");
/* playback stream may not yet be in streaming state, drop play
* data to avoid introducing additional playback latency */
spa_ringbuffer_read_update(&impl->play_ring, pindex + size);
spa_ringbuffer_read_update(&impl->play_delayed_ring, pdindex + size);
goto done;
}
for (i = 0; i < impl->play_info.channels; i++) {
/* echo from sink */
play[i] = &play_buf[i][0];