From 2991a814cde35c37b5583fd78b716fb930bca26f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 7 Jul 2020 13:42:56 +0200 Subject: [PATCH] pulse: wait for READY before calling callbacks --- pipewire-pulseaudio/src/internal.h | 4 ++-- pipewire-pulseaudio/src/stream.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pipewire-pulseaudio/src/internal.h b/pipewire-pulseaudio/src/internal.h index 7565ea9c0..17bbab67c 100644 --- a/pipewire-pulseaudio/src/internal.h +++ b/pipewire-pulseaudio/src/internal.h @@ -139,7 +139,7 @@ void pa_context_fail(PA_CONST pa_context *c, int error); #define PA_CHECK_VALIDITY(context, expression, error) \ do { \ if (!(expression)) { \ - pw_log_trace("'%s' failed at %s:%u %s()", \ + pw_log_debug("'%s' failed at %s:%u %s()", \ #expression, __FILE__, __LINE__, __func__); \ return -pa_context_set_error((context), (error)); \ } \ @@ -148,7 +148,7 @@ do { \ #define PA_CHECK_VALIDITY_RETURN_ANY(context, expression, error, value) \ do { \ if (!(expression)) { \ - pw_log_trace("'%s' failed at %s:%u %s()", \ + pw_log_debug("'%s' failed at %s:%u %s()", \ #expression, __FILE__, __LINE__, __func__); \ pa_context_set_error((context), (error)); \ return value; \ diff --git a/pipewire-pulseaudio/src/stream.c b/pipewire-pulseaudio/src/stream.c index 1c1ce5f7c..5be254a59 100644 --- a/pipewire-pulseaudio/src/stream.c +++ b/pipewire-pulseaudio/src/stream.c @@ -554,13 +554,13 @@ static void stream_process(void *data) if (s->direction == PA_STREAM_PLAYBACK) { queue_output(s); - if (s->write_callback) + if (s->write_callback && s->state == PA_STREAM_READY) s->write_callback(s, s->maxblock, s->write_userdata); } else { pull_input(s); - if (s->read_callback && s->ready_bytes > 0) + if (s->read_callback && s->ready_bytes > 0 && s->state == PA_STREAM_READY) s->read_callback(s, s->ready_bytes, s->read_userdata); } }