diff --git a/src/pulsecore/pstream-util.c b/src/pulsecore/pstream-util.c index c686b4a8f1513ad2584d8e71d09eeb864bac0134..624c21772d5767b8cdc533abcbab9ab061862676 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(); } diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index e137db1b12012842c0f17039cb2d78a8aedd9340..9e9bcdc162f01ddefb901d36b7c061161f4a6dc3 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 42d0009a69b66b578fce1c12d377fcd5f6777f31..c3ec6825c14db354d8b4785d32fb1a6f8390c471 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