On Wed, 2017-01-25 at 14:06 +0500, Dmitry Vinokurov wrote:
> Hi,
> 
> I've faced strange PulseAudio monitor device (i.e. audio input device which
> plays sound sent to speaker) behaviour on Ubuntu 16.04. I've reduced code
> from my real project to simple example based on code from PulseAudio docs
> https://freedesktop.org/software/pulseaudio/doxygen/
> parec-simple_8c-example.html, I've only added time limit and read bytes
> counting. It works for example 30 seconds and prints read bytes count.
> Problem is that bytes count vastly differs if something is played during
> program run. I've executed this program and in parallel executed bash for
> loop consisting aplay with short tada.wav file. Difference is 9%. To test
> it more, I tried to run 4 such loops in parallel with PulseAudio example
> and difference is even more - 34%. But if instead of several aplay with
> short wav I run mplayer with long mp3 file - there is no such difference,
> bytes count is similar to case when no sound is played.
> 
> Such behaviour causes failure of sound processing code in my real project,
> so if somebody could suggest how to solve it - I'll be very grateful.

You're probably hitting a known bug we have with rewind handling in
monitor sources ("known" means in this case that the symptoms are
known, but not the exact cause). When a stream starts to play to the
monitored sink, the sink will rewrite its playback buffer contents
(this is called "rewinding"), and this causes a glitch in the monitor
source (some extra audio apparently gets pushed to the recording
stream, judging from your experiments). I hope to fix this some day,
but it doesn't look like I'll have time for it in the near future. If
you have the time and motivation to investigate and fix the bug, that
would be awesome.

As a workaround, you can probably reduce the magnitude of the error by
reducing the playback buffer size. To do that, pass
tsched_buffer_size=X to module-udev-detect in /etc/pulse/default.pa
(replace X with the buffer size in bytes).

-- 
Tanu

https://www.patreon.com/tanuk
_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss

Reply via email to