Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

ALSA Underrun

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
HyperHacker
Posts: 24
Joined: 2010-01-29 05:19

ALSA Underrun

#1 Post by HyperHacker »

When I play sound in any application, it skips/stutters and a message such as "ALSA underrun" is displayed in the terminal. (Exact message depends on the program, but all say this.) Some songs skip more than others.
MPD was stuttering really badly, until I added a line to the audio_output section of .mpdconf:

Code: Select all

        use_nmpa        "yes"
With that, it still isn't perfect, but at least goes a few minutes as opposed to a few seconds without glitching.

Google shows all sorts of people having this problem with older versions of everything, but not the latest. MPD is version 15.8, kernel is 2.6.32-trunk-686 (squeeze), ALSA version 1.0.21.

HyperHacker
Posts: 24
Joined: 2010-01-29 05:19

Re: ALSA Underrun

#2 Post by HyperHacker »

Well it's now skipping every few seconds, which makes trying to actually enjoy music an exercise in futility. Is there really nobody out there who also has this problem and/or knows what to do about it?

HyperHacker
Posts: 24
Joined: 2010-01-29 05:19

Re: ALSA Underrun

#3 Post by HyperHacker »

Well, I've switched MPD to use OSS, and even it skips on occasion. Rare enough not to be much of a bother, but still odd. What could cause OSS, ALSA and Pulse to all skip random different amounts in different songs?

User avatar
BioTube
Posts: 7520
Joined: 2007-06-01 04:34

Re: ALSA Underrun

#4 Post by BioTube »

Well, OSS on Linux is just a compatibility layer for ALSA(hence the lack of change); I'm not sure how Pulse interacts with the sound system. What bitrate of audio are you trying to play and how fast is your computer? A preemtable kernel might be what you need.
Image
Ludwig von Mises wrote:The elite should be supreme by virtue of persuasion, not by the assistance of firing squads.

HyperHacker
Posts: 24
Joined: 2010-01-29 05:19

Re: ALSA Underrun

#5 Post by HyperHacker »

CPU speed is around 1600mhz, single core AMD Sempron.

Was there a change in the kernel recently? I had the same problem on Xubuntu before switching to Debian, and trying older kernels didn't help.

Strangely, today, it seems to have improved a lot. There's still the odd skip, but it's not accompanied by an error message. Only change I can think of is turning off another computer... difference in network traffic? O.o mpd still skips badly on ALSA, with the underrun message, but mplayer works much better (skip maybe every couple minutes).
It does skip a lot worse on FLACs (bitrate in the range of 1152kb/s), so I would guess there's some relation there. Maybe mpd's process priority is too low? My client doesn't display bitrate information, so I can't tell, but I suspect VBR MP3s would skip in the more complex parts. That's what the FLACs seem to be doing as well. Nearly all songs are 44khz stereo (some might be 48khz, a few maybe 22khz).
OGG skips badly as well, so I'm starting to think the decoder is not getting enough CPU time.

I believe Pulse installs some "dummy" ALSA libraries that redirect to it, but I don't know for sure how it works. I've completely removed it (apt-get purge), and the problems existed before installing it. I will want to try to make it work later, but first things first.

User avatar
aspnair
Posts: 1247
Joined: 2009-06-18 12:27
Location: Twitter: @anand_sivaram

Re: ALSA Underrun

#6 Post by aspnair »

The problem could very well be related to the soundcard/codec hardware of your system.
Try to play any wave file using aplay

aplay -v some_file.wav

Currently alsa is the only hardware driver supported in kernel.
Every other sound system including oss, jack, pulseaudio etc. uses alsa driver

Some hardware may not play audio other than its native speed very well. Normally sound cards have a native speed of either 44100Hz or 48000Hz stereo. So try to play either of the two.
I'm not sure how Pulse interacts with the sound system.
There is a nice flow chart on wikipedia.
http://en.wikipedia.org/wiki/PulseAudio
Compressed Air Energy Storage, Entropy and Efficiency
http://saurorja.org/2012/06/18/compress ... fficiency/

HyperHacker
Posts: 24
Joined: 2010-01-29 05:19

Re: ALSA Underrun

#7 Post by HyperHacker »

I don't think there's anything wrong with the hardware as it worked fine on Xubuntu 9.04. aplay shows:

Code: Select all

Playing WAVE 'madcow.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
Plug PCM: Rate conversion PCM (48000, sformat=U8)
Converter: libspeex (builtin)
Protocol version: 10002
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : U8
  subformat    : STD
  channels     : 1
  rate         : 8000
  exact rate   : 8000 (8000/1)
  msbits       : 8
  buffer_size  : 2730
  period_size  : 170
  period_time  : 21333
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 170
  period_event : 0
  start_threshold  : 2730
  stop_threshold   : 2730
  silence_threshold: 0
  silence_size : 0
  boundary     : 178913280
Slave: Route conversion PCM (sformat=S16_LE)
  Transformation table:
    0 <- 0
    1 <- 0
Its setup is:
  stream       : PLAYBACK
  access       : MMAP_INTERLEAVED
  format       : U8
  subformat    : STD
  channels     : 1
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 8
  buffer_size  : 16384
  period_size  : 1024
  period_time  : 21333
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 1024
  period_event : 0
  start_threshold  : 16384
  stop_threshold   : 16384
  silence_threshold: 0
  silence_size : 0
  boundary     : 1073741824
Slave: Direct Stream Mixing PCM
Its setup is:
  stream       : PLAYBACK
  access       : MMAP_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 2
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 16
  buffer_size  : 16384
  period_size  : 1024
  period_time  : 21333
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 1024
  period_event : 0
  start_threshold  : 16384
  stop_threshold   : 16384
  silence_threshold: 0
  silence_size : 0
  boundary     : 1073741824
Hardware PCM card 0 'C-Media CMI8738' device 0 subdevice 0
Its setup is:
  stream       : PLAYBACK
  access       : MMAP_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 2
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 16
  buffer_size  : 16384
  period_size  : 1024
  period_time  : 21333
  tstamp_mode  : ENABLE
  period_step  : 1
  avail_min    : 1024
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 1073741824
  silence_threshold: 0
  silence_size : 1073741824
  boundary     : 1073741824
  appl_ptr     : 0
  hw_ptr       : 0
which doesn't really tell me anything.

User avatar
aspnair
Posts: 1247
Joined: 2009-06-18 12:27
Location: Twitter: @anand_sivaram

Re: ALSA Underrun

#8 Post by aspnair »

Are you getting the same underrun with aplay also?
Compressed Air Energy Storage, Entropy and Efficiency
http://saurorja.org/2012/06/18/compress ... fficiency/

HyperHacker
Posts: 24
Joined: 2010-01-29 05:19

Re: ALSA Underrun

#9 Post by HyperHacker »

For the most part, `play` and `aplay` play WAV files OK, but under heavy CPU load, they too skip and display an underrun message. (aplay claims "at least 1763646400.046 ms long", which I'd have to say is wrong...)

HyperHacker
Posts: 24
Joined: 2010-01-29 05:19

Re: ALSA Underrun

#10 Post by HyperHacker »

Nobody knows? With mpd using OSS, nothing else can play sound at the same time, so it's a real pain. :(

HyperHacker
Posts: 24
Joined: 2010-01-29 05:19

Re: ALSA Underrun

#11 Post by HyperHacker »

I found today that with the above changes, mplayer plays video flawlessly. However, something I hadn't tried before: streaming music in MPD plays fine for 4 minutes, then starts skipping as badly as before. Since it can't actually skip ahead in a stream, it basically just cuts out and repeats a lot. I haven't yet tried streams in other players.

Post Reply