modules: handle stream trigger errors

When we get a process callback from the capture stream but we can't
trigger the playback stream, simply consume the buffers from the capture
stream.

This can happen when the playback stream is not ready yet, for example.
If we don't consume the buffers that are ready, the converter might run
out of buffers and complain.
This commit is contained in:
Wim Taymans 2024-11-05 15:59:01 +01:00
parent bc57b9ec86
commit 79baeb8d18
3 changed files with 28 additions and 3 deletions

View file

@ -161,7 +161,15 @@ static void capture_destroy(void *d)
static void capture_process(void *d)
{
struct impl *impl = d;
pw_stream_trigger_process(impl->playback);
int res;
if ((res = pw_stream_trigger_process(impl->playback)) < 0) {
while (true) {
struct pw_buffer *t;
if ((t = pw_stream_dequeue_buffer(impl->capture)) == NULL)
break;
pw_stream_queue_buffer(impl->capture, t);
}
}
}
static void playback_process(void *d)

View file

@ -896,7 +896,16 @@ static void capture_destroy(void *d)
static void capture_process(void *d)
{
struct impl *impl = d;
pw_stream_trigger_process(impl->playback);
int res;
if ((res = pw_stream_trigger_process(impl->playback)) < 0) {
pw_log_debug("playback trigger error: %s", spa_strerror(res));
while (true) {
struct pw_buffer *t;
if ((t = pw_stream_dequeue_buffer(impl->capture)) == NULL)
break;
pw_stream_queue_buffer(impl->capture, t);
}
}
}
static void playback_process(void *d)

View file

@ -310,7 +310,15 @@ static void recalculate_delay(struct impl *impl)
static void capture_process(void *d)
{
struct impl *impl = d;
pw_stream_trigger_process(impl->playback);
int res;
if ((res = pw_stream_trigger_process(impl->playback)) < 0) {
while (true) {
struct pw_buffer *t;
if ((t = pw_stream_dequeue_buffer(impl->capture)) == NULL)
break;
pw_stream_queue_buffer(impl->capture, t);
}
}
}
static void playback_process(void *d)