[pulseaudio-discuss] How does automatic output resampling in Pulseaudio work?

Lennart Poettering lennart at poettering.net
Wed Mar 26 16:02:43 PDT 2008

On Mon, 18.02.08 23:39, Tanu Kaskinen (tanuk at iki.fi) wrote:

> On Mon, Feb 18, 2008 at 10:37:09PM +0200, Tanu Kaskinen wrote:
> > If I understood you correctly, then the answer is that there
> > is no "final hardware matching stage". In your example the
> > sound card reports that it uses sampling rate of 48000 Hz,
> > and pulseaudio trusts that it's correct information. If it's
> > not, then the sound is played slightly too fast or too
> > slowly. The small deviation is taken into account only when
> > there are multiple clocks, for example two sound cards, and
> > even then the correction is not based on actual time, but
> > just the observed difference in the clocks.
> > 
> > So resampling is always done only once (afaik).
> I take back what I said about multiple clocks. Firstly, in
> that case resampling seems to happen twice, and secondly I'm
> not so sure what module-combine keeps as the reference
> clock. All streams created by it have a fluctuating sample
> rate...

In module-combine all sound cards a synced to the sink with the largest
latency. That we can make sure that output happens at the same time
although the latencies of the combined devices might differ.

However, please note that it is impossible to actually get an atomic
snapshot of the playback times of all connected sinks. By the time we
query the second device in our combined set the time of the first
device might already be out-of-date. Then, many sound cards only
update the timing information after each fragment -- i.e. it might
happen that PA thinks that the clocks of the sound cards are way off
while they actaully are not. In short: module-combine goes into
reasonable efforts to get things done properly and keep the sinks in
sync -- but this might still be pretty bad at some times and on some hw.


Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net         ICQ# 11060553
http://0pointer.net/lennart/           GnuPG 0x1A015CC4

More information about the pulseaudio-discuss mailing list