From 86a3922bc7d540d26faa4e3bfe7f2f219787793c Mon Sep 17 00:00:00 2001 From: owencreeper Date: Mon, 2 Sep 2024 11:23:34 +0800 Subject: [PATCH 1/2] fix trace bug Signed-off-by: owencreeper --- src/pulsecore/pstream-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pulsecore/pstream-util.c b/src/pulsecore/pstream-util.c index c686b4a8f..624c21772 100644 --- a/src/pulsecore/pstream-util.c +++ b/src/pulsecore/pstream-util.c @@ -45,7 +45,7 @@ static void pa_pstream_send_tagstruct_with_ancil_data(pa_pstream *p, pa_tagstruc uint32_t command; if (ReadCommand(t, &command) == 0) { char t[PA_SNPRINTF_COMMAND_STR_LENGTH] = {0}; - pa_snprintf(t, sizeof(t), "PA_SEND_CMD[%u]", p, command); + pa_snprintf(t, sizeof(t), "PA_SEND_CMD[%u]", command); CallStart(t); CallEnd(); } -- Gitee From 3c7bf1247ef31cfe5e746fc67313dec1b82ec6d6 Mon Sep 17 00:00:00 2001 From: owencreeper Date: Mon, 2 Sep 2024 11:37:31 +0800 Subject: [PATCH 2/2] fix multi peek problem Signed-off-by: owencreeper --- src/pulsecore/sink-input.c | 14 ++++++++++++++ src/pulsecore/sink.c | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index e137db1b1..9e9bcdc16 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -46,6 +46,7 @@ #define MEMBLOCKQ_MAXLENGTH (32*1024*1024) #define CONVERT_BUFFER_LENGTH (pa_page_size()) +#define RESAMPLER_CACHE_SIZE_RATIO 20 PA_DEFINE_PUBLIC_CLASS(pa_sink_input, pa_msgobject); @@ -678,6 +679,11 @@ int pa_sink_input_new( pt); pa_xfree(pt); + if (resampler) { + pa_resampler_prepare( + resampler, i->thread_info.history_memblockq, resampler->o_fz * RESAMPLER_CACHE_SIZE_RATIO); + } + /* Don't forget to call pa_sink_input_put! */ *_i = i; @@ -1738,6 +1744,10 @@ void pa_sink_input_cork(pa_sink_input *i, bool b) { if (b && i->thread_info.resampler) { pa_resampler_reset(i->thread_info.resampler); + if (i->thread_info.resampler) { + pa_resampler_prepare(i->thread_info.resampler, + i->thread_info.history_memblockq, i->thread_info.resampler->o_fz * RESAMPLER_CACHE_SIZE_RATIO); + } } } @@ -2611,6 +2621,10 @@ int pa_sink_input_update_resampler(pa_sink_input *i, bool flush_history) { pa_log_warn("Unsupported resampling operation."); return -PA_ERR_NOTSUPPORTED; } + if (new_resampler) { + pa_resampler_prepare( + new_resampler, i->thread_info.history_memblockq, new_resampler->o_fz * RESAMPLER_CACHE_SIZE_RATIO); + } } else new_resampler = NULL; diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 42d0009a6..c3ec6825c 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -50,6 +50,8 @@ #include "sink.h" +#include "log/audio_log.h" + #define MAX_MIX_CHANNELS 32 #define MIX_BUFFER_LENGTH (pa_page_size()) #define ABSOLUTE_MIN_LATENCY (500) @@ -1606,6 +1608,10 @@ pa_usec_t pa_sink_get_latency(pa_sink *s) { if (!(s->flags & PA_SINK_LATENCY)) return 0; + if (s->asyncmsgq == NULL) { + AUDIO_ERR_LOG("pa_asyncmsgq is NULL"); + return 0; + } pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_GET_LATENCY, &usec, 0, NULL) == 0); /* the return value is unsigned, so check that the offset can be added to usec without -- Gitee