Need to obtain PA's sample rate
Submitted by Jörg Höhle
Assigned to pul..@..op.org
Description
Hi,
PA resamples everything, which is fine.
However there should be a means to find out the rate that PA itself uses to drive the underlying device.
By contrast, plug:dmix resamples everything too. Yet when I use snd_pcm_open("plug:dmix",0 , SND_PCM_NO_AUTO_RESAMPLE | SND_PCM_NO_AUTO_CHANNELS | SND_PCM_NO_AUTO_FORMAT) it becomes trivial to find out using e.g. snd_pcm_hw_params_get_rate that it is mixing at 48000 and solely accepts S32_LE.
Currently, Wine does not manage to find out PA's rate. PA accepts each and every format despite the above flags. As a result, Wine uses 48000 which PA accepts and publishes this rate via the MMDevAPI interface. What then happens is that MS apps resample all their sounds to 48000 for mmdevapi, which passes that to ALSA->PA which resamples down to 44100 to drive the ALSA HW. That is a gratuitous waste of the HW owner's resources.
Of course Wine could hard code 44100 when it detects "pulse", but that is a hack. Any user could launch PA at a different rate AFAIK.
IMHO the alsa_plugins for PA should obey SND_PCM_NO_AUTO_* but I'm open for suggestions. How to detect PA's rate from the ALSA side?
Thank you, Jörg Höhle