[pulseaudio-discuss] PulseAudio null sink monitor gives distorted audio randomly

Mikael Nousiainen mikaelnousiainen at fastmail.com
Fri Nov 9 21:52:06 UTC 2018

On Thu, Nov 8, 2018, at 20:49, pulseaudio-discuss-request at lists.freedesktop.org wrote:
> Message: 4
> Date: Thu, 8 Nov 2018 21:31:52 +0500
> From: "Alexander E. Patrakov" <patrakov at gmail.com>
> To: General PulseAudio Discussion
> 	<pulseaudio-discuss at lists.freedesktop.org>
> Subject: Re: [pulseaudio-discuss] PulseAudio null sink monitor gives
> 	distorted audio randomly
> Message-ID: <e96e0c84-6a83-78f5-dab3-60a39b6eb9a2 at gmail.com>
> Content-Type: text/plain; charset=utf-8; format=flowed
> [resending to the list, really this time]
> On 11/8/18 7:44 PM, Tanu Kaskinen wrote:
> > The problem is most likely due to this bug regarding monitor sources:
> > https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/304
> > 
> > Whenever the monitored sink has a rewind, a chunk of audio is
> > apparently duplicated in the monitor source. It would be great if
> > someone could figure out what goes wrong in the monitor rewinding code.
> Let me quote the main mistake, from src/pulse/stream.h:
> >  * The latency is stored in \a *r_usec. In case the stream is a
> >  * monitoring stream the result can be negative, i.e. the captured
> >  * samples are not yet played. In this case \a *negative is set to 1.
> I.e., the design mistake is that monitor sources allow one to capture 
> samples that have not yet been played. This is always wrong, as those 
> samples can be overwritten by a rewind, and there is no "uncapture" to 
> compensate. So the fix would be to make sure that monitor sources 
> capture not what was just written to them, but what was actually played 
> and can no longer be overwritten. I.e., change the latency from negative 
> to small positive.
> -- 
> Alexander e. Patrakov

Thanks for digging into this!

Some questions:

1. Is there any workaround for this without a proper bugfix and a new release?
2. Is this a question of buffer underrun / jitter bcause of  CPU usage? What is the cause for "monitor rewinds", why is it needed?
3. Why are the artifacts gone sometimes and sometimes the appear after PulseAudio restart?


More information about the pulseaudio-discuss mailing list