[pulseaudio-discuss] Toslink capture looback latency problem

Georg Chini georg at chini.tk
Tue Jan 30 09:42:22 UTC 2018


On 30.01.2018 08:13, Georg Chini wrote:
> On 30.01.2018 03:08, NicoHood wrote:
>> On 01/29/2018 07:48 PM, Georg Chini wrote:
>>> On 29.01.2018 19:39, NicoHood wrote:
>>>> On 01/29/2018 07:19 PM, Georg Chini wrote:
>>>>> On 29.01.2018 18:46, Nico wrote:
>>>>>> On 01/29/2018 03:52 PM, NicoHood wrote:
>>>>>>> On 01/29/2018 03:29 PM, Georg Chini wrote:
>>>>>>>> On 29.01.2018 14:44, NicoHood wrote:
>>>>>>>>> On 01/29/2018 01:39 PM, Georg Chini wrote:
>>>>>>>>>> On 29.01.2018 12:52, Nico wrote:
>>>>
>>> If the sound card supports it, PA will always use either the default
>>> or the alternative sample rate, whatever fits the current stream
>>> better, unless there is already a stream running on the card.
>>>
>>> So it should be enough to run module-loopback with rate=48000.
>>> Don't forget to change the values in daemon.conf back to their
>>> original values before you try it.
>>>
>>>
>> Setting the rate for the loopback module does not give a positive
>> result. Setting the sample rate with pacat for the SINK works fine
>> though. This is the command I used:
>>
>> pacat -r --latency-msec=100 -d alsa_input.pci-0000_01_00.0.iec958-stereo
>> | pacat -p --latency-msec=100 -d
>> alsa_output.usb-M-AUDIO_M-Track_Hub-00.analog-stereo --rate=48000
>>
>> Is this a general bug? Is there a way to change the sample rate for the
>> sink itself within the loopback module? I am still wondering why this
>> happens, as I can capture any other input without changing the sink
>> sample rate.
>>
>> If i set the source to 48000 and the sink to 44100 it does not work. I
>> have no idea why. Any ideas?
>
> Did you check what sample rates are really set for the sink/source
> with "pactl list sinks" and "pactl list sources"? What you are setting
> on the command line are in fact sample rates for the streams, not
> for sink/source itself. There are several places where re-samplers
> are used within PA, so that the rate of the stream need not match
> the actual sample rate of the device.
> Also, if the sink/source is busy (RUNNING or IDLE), PA will refuse to
> change the sample rate. So ensure the source is SUSPENDED before
> trying to set it to 48kHz.
> I don't see a bug yet, apart from the fact that the TOS link apparently
> passes on the sample rate of the connected device and ignores the
> rate set for the source in PA. But because there is no easy way to
> determine the rate of an incoming stream, I cannot see how this
> could be fixed in PA.
>
> In general (because of re-sampling) it should work if the source is
> set to 48kHz and the sink is at 44.1kHz. In your pacat example
> however you are connecting two independent streams, so if the
> first stream is running on 48kHz and you tell the second stream
> to interpret the data as being 44.1kHz, it cannot work.

The first (recording) stream always uses 48kHz regardless what you
specify because it takes the samples from the TOS link "as is", so if
you tell the second stream (playback) to interpret the data as 48kHz
it will work. This is why you have to set the sink side to 48kHz in your
pacat example.

The problem is not what the source is receiving - we know now it
is always 48kHz - but to tell PA the right sample rate. As long as PA
thinks the source is at 44.1kHz while samples are coming in at 48kHz,
things will break.

What you could do is just swap the alternate and default sample rates.
This allows that 44.1kHz content can still be played without re-sampling,
while the default is 48kHz.


More information about the pulseaudio-discuss mailing list