Bug#663239: mplayer opens audio device in 48000 Hz for 44100 source material
Kurt Roeckx
kurt at roeckx.be
Fri Mar 9 18:25:01 UTC 2012
Package: mplayer2, libasound2
Hi,
When I'm playing music with mplayer2, when the music is with a
samplerate of 44100, mplayer opens the device in 48000 mode.
Which means that mplayer needs to resample from 44100 to 48000,
while there is no need for this, and only wastes cpu time, and
distorts the sound. As far as I can see it defaults to an
accurate resample algorithm, but it's using multiple times the
amount of CPU it should be using.
I have those devices:
$ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
pulse
PulseAudio Sound Server
default:CARD=PCH
HDA Intel PCH, ALC892 Analog
Default Audio Device
sysdefault:CARD=PCH
HDA Intel PCH, ALC892 Analog
Default Audio Device
front:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
Front speakers
surround40:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Digital
IEC958 (S/PDIF) Digital Audio Output
hdmi:CARD=PCH,DEV=0
HDA Intel PCH, HDMI 0
HDMI Audio Output
hdmi:CARD=PCH,DEV=1
HDA Intel PCH, HDMI 1
HDMI Audio Output
Looking at the samplerates those support, I get:
default / sysdefault: 4000-4294967295
hw:0 44100 48000 96000 192000
front: 44100 48000 96000 192000
surround*: 44100 48000 96000 192000
iec958: 32000 44100 48000 88200 96000 192000
hdmi: 32000 44100 48000 88200 96000 176400 192000
So there really is no reason I shouldn't be able to play at 44100.
The problem now is that mplayer does this in libao2/ao_alsa.c:
/* workaround for buggy rate plugin (should be fixed in ALSA 1.0.11)
prefer our own resampler, since that allows users to choose the resampler,
even per file if desired */
#if SND_LIB_VERSION >= 0x010009
if ((err = snd_pcm_hw_params_set_rate_resample(alsa_handler, alsa_hwparams,
0)) < 0)
{
mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to disable resampling: %s\n",
snd_strerror(err));
return 0;
}
#endif
The results in default's rate to be changed from 4000-4294967295 to 48000. That is
"defaults.pcm.dmix.rate 48000" in the config file as far as I know.
The next thing mplayer does is requesting the samplerate using
snd_pcm_hw_params_set_rate_near(), asking for 44100, but getting
48000 instead.
Using an other device than default/sysdefault does get me the
44100.
Kurt
More information about the pkg-multimedia-maintainers
mailing list