MPD causes buffer underruns

Need help with MPD?
Post Reply
hachures
Posts: 4
Joined: February 18th, 2016, 9:49 am

MPD causes buffer underruns

Post by hachures »

Hi everybody

I have an issue that's driving me crazy.
If I play music through MPD, I hear a lot of skipping and scratching sounds.
This happens without differences with an ALSA output and with a Pulseaudio output. It also seems to be unaffected by the format (I tried mp3 and wave).

I verified that the skips are due to ALSA buffer underruns. With verbose MPD logging enabled and using the alsa_output, I get the message:

Code: Select all

alsa_output: Underrun on ALSA device "hw:1,0"
and if I enable xrun debugging for the ALSA device:

Code: Select all

 echo 1 >  /proc/asound/card1/pcm0p/xrun_debug
,
I get in the kernel log a lot of

Code: Select all

Feb 17 00:52:23 wohnzimmer-H97N-WIFI kernel: [ 9202.100280] PCM: Lost interrupts? [Q] (stream=0, delta=4104, new_hw_ptr=79881, old_hw_ptr=75777)
and

Code: Select all

XRUN: pcmC1D0p:0

With the xruns happening whenever an underrun is reported in the MPD log.


Now, the point is that this is NOT related to either alsa or pulseaudio. Playback is perfect with

Code: Select all

mplayer -vo null -ao alsa:device=hw=1.0 '/home/wohnzimmer/Desktop/07-aqua-doctor_jones.mp3' 
similar with "-ao pulse", and i don't see any lost interrupts and xruns in the kernel log.

My layman diagnosis was that MPD is too slow to produce output, misses some of the hw interrupts when the sound card asks for data, and eventually this leads to hw buffer underruns. So i tried, always to no avail:
  • * increasing buffer_before_play (up to 50%)
    * increasing audio_buffer_size
    * increasing the period_size in the alsa output (only a few combinations)
    * toggling use_mmap
    * various combinations of auto_resample, auto_channels and auto_format in the alsa output
    * disabling "mad" and "mpg123" (so that ffmpeg is used, in order to factor out an issue related with a specific decoder)
* the computer is completely idle apart from MPD, a client, and a couple of remote sessions, and top shows me a low CPU rate.
* there are no IRQ conflicts

Do you have any ideas of what else I could try, or what could be the cause?

Would tweaking the values related to the ringbuffer in the configuration of the driver help? (but why do other applications play well?)
Would installing propretary driver for the realtek chipset driver help? (but why to other applications play well?)

Thanks in advance for any help

TECHNICAL DATA:
The system is Mint, Linux 3.13.0-24-generic x86_64
MPD version is 0.18.7
The motherboard is a Gigabyte H97N-WIFI

Code: Select all

cat /proc/asound/cards
 0 [HDMI           ]: HDA-Intel - HDA Intel HDMI
                      HDA Intel HDMI at 0xf7e34000 irq 48
 1 [Intel          ]: HDA-Intel - HDA Intel
                      HDA Intel at 0xf7e30000 irq 49
 2 [CinemaTM       ]: USB-Audio - Microsoft\Uffffffff LifeCam Cinema(TM)
                      Microsoft Microsoft\Uffffffff LifeCam Cinema(TM) at usb-0000:00:14.0-7, high speed
I'm playing through the analog subdevice of card 1:

Code: Select all

at /proc/asound/card1/pcm0p/info 
card: 1
device: 0
subdevice: 0
stream: PLAYBACK
id: ALC892 Analog
name: ALC892 Analog
subname: subdevice #0
class: 0
subclass: 0
subdevices_count: 1
subdevices_avail: 1

max
Forum team
Posts: 1024
Joined: January 15th, 2013, 3:43 pm

Re: MPD causes buffer underruns

Post by max »


tortuga_Bob
Posts: 8
Joined: December 7th, 2015, 11:26 pm

Re: MPD causes buffer underruns

Post by tortuga_Bob »

Maybe update mpd to 0.19.12 for a start?

hachures
Posts: 4
Joined: February 18th, 2016, 9:49 am

Re: MPD causes buffer underruns

Post by hachures »

Hi,
I pasted a verbose log snippet, config file and output of MPD --version at

http://paste.debian.net/400002

As mentioned, the version of MPD is old, 0.18.7, but that is the most recent I can install with apt-get on my (mint) system. I tried installing the latest stable version using the deb packages and that fails because of unsatisfiable dependencies, so I'm stuck with this version for now.

Thanks

max
Forum team
Posts: 1024
Joined: January 15th, 2013, 3:43 pm

Re: MPD causes buffer underruns

Post by max »

There is no obvious problem in your log; it shows that your sound chip can play the file as-is, without resampling or any other kind of conversion. I.e. there is only negligible CPU load. Everything looks perfect, except for the xruns. What you could do is upgrade to MPD 0.19.12 - every major MPD release has lots of optimizations. In 0.19, there were lots of latency optimizations, and your problem is probably caused by latency.

hachures
Posts: 4
Joined: February 18th, 2016, 9:49 am

Re: MPD causes buffer underruns

Post by hachures »

Thank you for taking the time to go through the logs and thanks for the advice!

I upgraded my system to the latest version available, and tried again installing the latest stable version of MPD using the Debian binaries, but I always hit unsatisfiable dependencies. This would likely happen as well if I tried to compile it from source.
So I have to give up until Ubuntu/Mint include that version.

Shall I mark the topic SOLVED (or anything else?)

skidoo
Posts: 194
Joined: April 28th, 2013, 10:06 pm
Location: Western Germany

Re: MPD causes buffer underruns

Post by skidoo »

Try a Lubuntu Live CD. Lubuntu is a lightweight Ubuntu flavour without Pulseaudio. Install MPD on live environment and check if error persists.

hachures
Posts: 4
Joined: February 18th, 2016, 9:49 am

Re: MPD causes buffer underruns

Post by hachures »

Hi skidoo

thanks for the advice. Could you please explain what exactly the purpose of the test would be? Do you suspect that pulse is causing the bug even though I'm not playing through it, and even if ALSA works properly with other players?

Would killing the Pulseaudio daemon not be sufficient for the purpose of the test?

thanks

skidoo
Posts: 194
Joined: April 28th, 2013, 10:06 pm
Location: Western Germany

Re: MPD causes buffer underruns

Post by skidoo »

Follow max advice and give MPD release 0.19 a try.

Post Reply