Hi, Tanu,

There is about 0.5s constant delay between tunnel sink and local sink and these 
two sinks are never in-sync no matter how long I play. I also tried different 
values for module-combine-sink adjust_time parameter and it doesn't help. 

Then, I tried another setup by replacing tunnel sink PC-2 using another 
embedded audio device. The symptom is different. The tunnel sink (embedded 
audio device) lags local sink (PC-1) at the beginning. Then after playing a 
while, these two sinks can be in-sync eventually. The period from un-sync to 
sync differs when different adjust_time is applied. The shortest time is 1.5s, 
when adjust_time is set to 1. I traced the logs, and found that during this 
period, either the latency of one of the sinks is too much different from the 
other or adjusted rate of one of the sinks jumps back and forth around the 
target sample rate.   

I looked at the source code of module-combine-sink.c. The adjust_rates() 
function seems to try to reduce sample rate of the sink with smaller latency 
through resampling module, in order to increase that sink's latency and 
eventually make the latency of both sinks same. This algorithm chooses to stop 
doing rate adjustment when the difference between sinks are too much different 
(more than  ~0.2*adjust_time seconds). And also the new adjusted rate can not 
exceed 0.2% of the current rate. All these logics seem telling me that this 
rate adjustment algorithm is designed to provide synchronizations between sinks 
with only minor latency difference, which are mainly caused by Audio DAC 
sampling clock deviation on different sink devices, not for devices with major 
latency difference, which could be caused by network or buffering in audio S/W 
stack. 

For synchronized playback with major latency difference, a common timestamp 
(e.g. PTS in AV sync) should be used. This timestamp is sent to all sinks 
before real playback starts. All sinks can only buffer audio sample data, but 
can not start playback until the local time matches timestamp. The local timer 
synchronization can be achieved by either NTP or PTP protocol. Does pulseaudio 
include such or similar scheme for combined sink devices' synchronization 
playback? 

Thanks!

BR
Xiaodong


-----Original Message-----
From: Tanu Kaskinen [mailto:[email protected]] 
Sent: Sunday, October 14, 2012 10:20 AM
To: Sun, Xiaodong
Cc: [email protected]
Subject: Re: [pulseaudio-discuss] a question about audio synchronization 
between local sink and tunnel sink

On Wed, 2012-10-10 at 20:45 +0000, Sun, Xiaodong wrote:
> Hi,
> 
> I have a pulseaudio daemon running on one PC (with my music songs 
> stored and played on this PC, let's call it PC-1). And then I setup 
> another PC (let's call it PC-2) running pulseaudio daemon on it and 
> enabled native TCP protocol. Then I configured (by using pacmd) PC-1 
> pulseaudio to load a tunnel sink pointing to PC-2, and then loaded a 
> combine sink which combines PC-2 tunnel sink and PC-1 local analog 
> audio sink. Now I can hear audio from both PC-1 and PC-2 at the same 
> time. But the audio playing are not synchronized between PC-1 and 
> PC-2. There is a delay on PC-2 comparing with PC-1.
> 
> Now my question is, is pulseaudio designed for synchronized playback 
> between local sink and tunnel sink? If yes, what kinds of parameters 
> should I tune?

I had a look, and it seems like module-tunnel is tries to report pretty 
accurate latency, and module-combine-sink in turn is supposed to synchronize 
the outputs if they provide valid latency information. So it looks like this 
should work, without any parameter tuning.
Unfortunately, if it doesn't work, I don't have much ideas for making it work. 
How big is the delay between the two outputs? If you let it play for a while, 
does it get better?

--
Tanu

_______________________________________________
pulseaudio-discuss mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss

Reply via email to