Originally posted by finalzone
View Post
i have 44.1, 48 and 96kHz music
thing is almost all sound cards can output at only one sampling rate at a time,
meaning that all sound has to be resampled to that frequency before being sent to the card (and bit-depth)
if that direct .asoundrc causes a failure, then something is wrong
probably it is PA holding the sound card open so the player can't change the rate or format
you can check that with "cat /proc/asound/card0/pcm0p/sub0/hw_params" (should be closed)
as for why i didn't
well, i don't like the idea of a sound server as it introduces a minimum delay (the size of the app-server ringbuffer + other stuff)
and there was already JACK, that did it properly
it just had/has a UI aimed at professionals, that is too much data for new people
anyway; i went and tested all that
i used sox to play a 44100kHz, 16bit, stereo flac file
i have a 3.5kHz cpu using performance... mode and without turbo-boost
sox using the direct method uses less then 0.5%
Code:
bash-4.2# cat /proc/asound/card0/pcm0p/sub0/hw_params access: RW_INTERLEAVED format: S16_LE subformat: STD channels: 2 rate: 44100 (44100/1) period_size: 2048 buffer_size: 16384
jack with default settings uses around 0.5% cpu
sox then uses ~1.4%
since the default sampling rate for jack is 48kHz, changing it to 44.1kHz lowered sox cpu usage to 0.5%
Code:
bash-4.2# cat /proc/asound/card0/pcm0p/sub0/hw_params access: MMAP_INTERLEAVED format: S32_LE subformat: STD channels: 8 rate: 48000 (48000/1) period_size: 1024 buffer_size: 2048
bdw, "access: MMAP_INTERLEAVED" means "zero-copy" in alsa speak
PA uses ~0.6% cpu
sox with it uses the same as with [email protected]
PA default is 44.1kHz so that's expected
Code:
bash-4.2# cat /proc/asound/card0/pcm0p/sub0/hw_params access: MMAP_INTERLEAVED format: S16_LE subformat: STD channels: 2 rate: 44100 (44100/1) period_size: 88200 buffer_size: 88200
i don't even understand where it got that value from
it's not divisible by 1024 nor 44100
in order to figure it out i went to change the daemon.conf
what i found there was two settings that i guess are used to calculate the period size and number
Code:
; default-fragments = 4 ; default-fragment-size-msec = 25
default is 4, i guess periods (JACK's is 2)
size is 25ms that gives 1102.5 frames, so it is... imprecise and not aligned to a page in memory
(page is 4k so a period of 1024 frames using 16bit stereo would fit exactly in it)
i guess in order to get actual data that confirms the settings would require asking it over dbus or something
around that point is when i gave up trying to configure PA to test other use cases
as for the actual minimum software latency introduced by those 2 servers
i can not calculate it since PA uses weird ring buffer size
(i guess it plays with the alsa's internal pointer to effectively make a ring buffer in that memory)
but i guess by the period count (and calculated size) that it is about little more then 2X of JACK, if they are bout left at default
as a reference 1024 frames = ~ 23.2 ms, this is happily pointed out by qjackctl when setting it (qjackctl actually gives 46.4, the whole buffer latency)
and am too lazy to dig around for an old microphone cable to cut (or to hack my simple player to be a test)
PS players can also try to use mmaped alsa interface
they won't get it all the time, and it will be resampled then
Comment