[pulseaudio-discuss] Merging soxr

Andrey Semashev andrey.semashev at gmail.com
Tue Jan 6 13:36:18 PST 2015


On Tue, Jan 6, 2015 at 10:55 PM, Alexander E. Patrakov
<patrakov at gmail.com> wrote:
> 06.01.2015 19:17, Andrey Semashev wrote:
>>
>> As far as I understand the code, the loop is already there in
>> pa_sink_input_peek() (see sink-input.c:924, "while (tchunk.length > 0)").
>> The
>> outer loop (sink-input.c:893, "while (!pa_memblockq_is_readable(i-
>>>
>>> thread_info.render_memblockq))") will end when either render_memblockq is
>>> not
>>
>> empty or the sink input is drained; in the latter case render_memblockq
>> can be
>> empty.
>
> The "while (tchunk.length > 0)" loop calls the resampler until it eats all
> of the available samples in tchunk. This looks insufficient, because the
> testcase quoted above relies on the condition that the resampler eats all of
> the available samples in tchunk (thus ending the loop), but produces
> nothing.
>
>> However, render_memblockq is initialized with a silence chunk in
>> pa_sink_input_new(), which means that when the queue is empty it should
>> return
>> silence. This means that pa_memblockq_peek() in sink-input.c:993 and the
>> following asserts should never fail. Same for the asserts in
>> fill_mix_info(),
>> the loop should be cut short by pa_memblock_is_silence(). "pa_assert(info-
>>>
>>> chunk.memblock);" could be moved upper though, but it it doesn't matter
>>> for
>>
>> the case in point.
>
> So, instead of an assertion failure that I predicted, we get a chunk of
> silence regularly inserted into the middle of the low-latency stream being
> resampled. Still bad. Thanks for correcting my logic, though.

Yes, but it's not regularly as you say. In practice I've never heard
anything like that (it would sound like audio cracking or something
like that). I assume, soxr does produce audio for any practical amount
of input samples (or there are other PA-specific factors in play). The
silence would be generated while the resampler is filling, and during
this period silence is exactly what is needed.

If no further modifications are needed to the surrounding code, are my
patches sufficient or do I have to rebase or modify them?


More information about the pulseaudio-discuss mailing list