[vlc-devel] ALSA problems

Rémi Denis-Courmont remi at remlab.net
Sat Jul 24 19:55:41 CEST 2010


Le mercredi 21 juillet 2010 14:41:18 Grigori Goronzy, vous avez écrit :
> On 07/21/2010 01:15 PM, Rémi Denis-Courmont wrote:
> > For several years, there have been reports that VLC outputs choppy sound
> > with ALSA. Last week end, I managed to reliably trigger the problem. I
> > simply had to select an explicit ALSA device as output (i.e. vlc
> > --alsa-audio-device hw:0,0), and the audio sample rate is 44100 Hz.
> > Interestingly, if I leave the default, the sound is fine. Also, if I
> > force the output to 48kHz with --aout-rate 48000, the sound is fine. I
> > get the same problem with both "hw:0,0" and "plughw:0,0".
> Much of audio hardware does not support arbitrary sample rates and lots
> of (older) integrated chipsets only support a sample rate of 48 KHz in
> hardware. So, software resampling is needed for all other sample rates.
> I'm sure the problem is somehow related to that.
> VLC should warn if they requested sample rate cannot be used, though...
> Have you tried explicitely enabling resampling? This can be done with
> snd_pcm_hw_params_set_rate_resample().

ALSA does enable resampling by default (according to the documentation). And 
indeed, if I explicitly enable it, it makes absolutely no differences.

I tried disabling resampling. Now I'm starting to suspect the ALSA developers 
have consumed too much toxics. hw and plughw till happily accept 44100Hz with 
..._set_rate_near(). In other words, it makes no difference either. But that 
is not all, with resampling disabled, the default (userspace) device starts 
rejecting 44100Hz, even though that rates works fine, and does return 48kHz 

I tried to play with ...set_rate_min(). That does in fact select 48kHz for 
44.1kHz inputs. But it also selects 96kHz for 48kHz inputs, which is, err, a 
bit silly.

> Anyway, IIRC using a hw: or plughw: device will always bypass automatic
> resampling, so you're pretty much SOL.

Sure. But how do you get the nearest larger or equal supported rate then?

Rémi Denis-Courmont

More information about the vlc-devel mailing list