From 78cb2f3f86fe66ede6086dc4955c9f558e56ae45 Mon Sep 17 00:00:00 2001 From: Jaechul Lee Date: Thu, 11 May 2023 10:17:24 +0900 Subject: [PATCH] source-output: Add exception handling Some preprocessors handle a fixed size memblocks. So, if it doesn't have enough size inside to apply audio-effects, it should wait for more blocks. If preprocess returns PROCESSOR_ERR_BUFFERING, the I/O thread would do nothing. And, preprocessor would wait for the next blocks. [Version] 15.0-20 [Issue Type] Update Change-Id: I799c083f23cc2add4e57f5ba0f422c6b1cf9b093 Signed-off-by: Jaechul Lee --- packaging/pulseaudio.spec | 2 +- src/pulsecore/source-output.c | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/packaging/pulseaudio.spec b/packaging/pulseaudio.spec index 37f5427..2b95125 100644 --- a/packaging/pulseaudio.spec +++ b/packaging/pulseaudio.spec @@ -4,7 +4,7 @@ Name: pulseaudio Summary: Improved Linux sound server Version: 15.0 -Release: 19 +Release: 20 Group: Multimedia/Audio License: LGPL-2.1 URL: http://pulseaudio.org diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index 82cacd0..43fe0b4 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -939,9 +939,17 @@ void pa_source_output_push(pa_source_output *o, const pa_memchunk *chunk) { if (!o->thread_info.resampler) { #ifdef TIZEN_AEC - if (o->preprocess && !o->preprocess(o, &qchunk, &ochunk)) - o->push(o, &ochunk); - else + if (o->preprocess) { + int ret = o->preprocess(o, &qchunk, &ochunk); + + /* in case of -2(ERR_BUFFERING), pushing a memblock should be skipped. + * Because the preprocess needs more blocks to apply audio-effects */ + if (ret == 0) + o->push(o, &ochunk); + else if (ret != -2) + o->push(o, &qchunk); + + } else o->push(o, &qchunk); #else o->push(o, &qchunk); @@ -959,9 +967,15 @@ void pa_source_output_push(pa_source_output *o, const pa_memchunk *chunk) { if (rchunk.length > 0) { #ifdef TIZEN_AEC - if (o->preprocess && !o->preprocess(o, &rchunk, &ochunk)) - o->push(o, &ochunk); - else + if (o->preprocess) { + int ret = o->preprocess(o, &rchunk, &ochunk); + + if (ret == 0) + o->push(o, &ochunk); + else if (ret != -2) + o->push(o, &rchunk); + + } else o->push(o, &rchunk); #else o->push(o, &rchunk); -- 2.7.4