[pulseaudio-discuss] Play audio files of high sample rates without hassle

Erwan JACQ pulseaudio at freeacoustics.com
Sat Nov 26 11:54:34 UTC 2016


I have a sound card Focusrite Scarlett 2i2 USB with a DAC supporting
many sample rates : 44100, 48000, 88200, 96000, 176400, 192000 Hz

However, pulseaudio can only switch at runtime between 2 sample rates,
defined by default-sample-rate and alternate-sample-rate in the daemon
config file.

I don't understand this limitation. 
- It's very painful when you want to play successively audio files of
different sample rates. You have to kill pulseaudio daemon, change its
conf, then restart it.
- It's not efficient quality wise to resample 192000Hz audio to 48kHz.
It's rejecting above average audio uses.
- It's not efficient performance wise to do resampling if this can be
avoided because hardware doesn't need it.
- Pulseaudio can know all the supported sample rates of my sound card
(ie: $cat /proc/asound/card2/stream0) so pulseaudio could dynamically
switch to the proper sample rate.

I tried a little hack in src/pulsecore/sink.c and source.c to let
pulseaudio ask the desired sample rate rather than to be limited to
default-sample-rate and alternate-sample-rate and it seems to work.

Now, if I play audio files successively with a single application, the
sample rate of the hardware is changed  dynamically for each audio file
for each audio file.

Of course if an audio stream is already playing, the sample rate cannot
change (there is a safeguard in the pulseaudio code). But this is
already a limitation already in the actual behavior.

So in the end, it's working the same as now, except that the first audio
stream can use a higher sample rate than the default/alternate sample
rates.

Did I miss something?



More information about the pulseaudio-discuss mailing list