I think PA_STREAM_ADJUST_LATENCY can cause buffer underruns when changing sinks
on a stream. I'm using v0.9.22.
When the sink input stream is created or moving sinks,
fix_playback_buffer_attr() is called to adjust the buffer latency "tlength":
...
else if (s->adjust_latency) {
...
if (tlength_usec > minreq_usec*2)
sink_usec = (tlength_usec - minreq_usec*2)/2;
else
sink_usec = 0;
pa_log_debug("Adjust latency mode enabled, configuring sink latency to
half of overall latency.");
}
...
s->configured_sink_latency = pa_sink_input_set_requested_latency(s->sink_input,
sink_usec);
...
if (tlength_usec < s->configured_sink_latency + 2*minreq_usec)
tlength_usec = s->configured_sink_latency + 2*minreq_usec;
So if the calculated sink latency "sink_usec" falls into the range of the sink
(usually when input stream is created) or the sink does not exist (when moving
sinks) , s->configured_sink_latency is same as "sink_usec ", and thus "tlength"
of PA buffer will become about 1/2 of that requested by application.
As a result, when a sink input stream is created, buffer latency will become
1/2 of the APP request.
Moving sinks for the 1st time, it becomes 1/4. Next moving, 1/8 ... until the
latency is too small and buffer underruns.
How to solve this problem?
I have sink input's buffer underruns afters changing sinks for a *live* stream:
"a VOIP sink input's current latency become "0" after moving to a new
sink?"http://lists.freedesktop.org/archives/pulseaudio-discuss/2011-June/010121.html
In my case, VOIP input stream requested 200ms latency and got 110ms (minreq
10ms). When moving sinks, latency became 45ms, but my BT HSP sink need 128 ms
latency and PA buffer keeps underrun. I'm walking around to set minimum 128ms
latency for a "phone" stream.
And someone else got the same problem as me: "Underruns when changing sinks on
a 'live stream":
http://lists.freedesktop.org/archives/pulseaudio-discuss/2011-June/010139.html
> > 1) using only 'paplay my_file.wav': I couldn't see progressive
> > audio-degradation or a progressive increase of Underruns, but after
> > several profile switches I hit a state where the audio is only noise.
> > Subsequent playbacks are all noisy. Only after setting a again a new
> > profile audio was rendered properly,
It seems that finally the latency "tlength" became too small and the buffer
underruns happened.
Thanks
Amanda
_______________________________________________
pulseaudio-discuss mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss