[mythtv-users] Audio drops every few seconds with "WriteAudio: buffer underrun" (PulseAudio problem?)

Jeffrey J. Kosowsky mythtv-users at kosowsky.org
Thu Dec 4 16:01:46 UTC 2008


No matter how I seem to configure video or audio playback, whenever I
watch mpeg2 HD video streams, my audio seems to temporarily drop every
2-5 seconds for about half a second. The console gives the error message:
		WriteAudio: buffer underrun

Watching mpeg2 HD streams is unbearable though the problem seems a
little worse with LiveTV than with playback, though with playback I
also sometimes get:
	 	NVP: prebuffering pause errors

When I watch "old-fashioned" analog TV, I very rarely get such errors
and I never seem to get them when watching mpeg4 transcoded streams
(even at 2200 bps encoding).

I originally thought this was a video problem due to my CPU/graphics
card being too slow, but I upgraded my graphics card and tried it
with/without XvMC and the problem persists even when the CPU is not
fully utilized.  Also, live TV and playback work perfectly fine with
mplayer (though without XvMC I get some frame dropping).

So, I'm thinking it may be more of a mythtv audio problem -- perhaps related
to Pulseaudio?

Anyway, the console shows the following audio info and "errors":
	TV: Attempting to change from None to WatchingPreRecorded
	DPMS Deactivated 
	AFD: Opened codec 0xa2dd550, id(MPEG2VIDEO) type(Video)
	AFD: codec AC3 has 2 channels
	AFD: Opened codec 0x9fcb2d0, id(AC3) type(Audio)
	AFD: codec AC3 has 2 channels
	AFD: Opened codec 0x9f0b760, id(AC3) type(Audio)
	AFD: Opened codec 0x9295760, id(MPEG2VIDEO) type(Video)
	AFD: codec AC3 has 2 channels
	AFD: Opened codec 0xa328ef0, id(AC3) type(Audio)
	AFD: codec AC3 has 2 channels
	AFD: Opened codec 0x90b7f10, id(AC3) type(Audio)
	Opening audio device 'default'. ch 2(2) sr 48000
	Opening ALSA audio device 'default'.
	ALSA, Warning: mmap not available, attempting to fall back to slow writes.

In the 'General' mythfrontend setup section, I tried setting:
   Audio output device: ALSA:default (or ALSA:pulse)
   Passthrough output device: Default (or ALSA:iec958:{AES0 0x02} )
which all give the same above behavior (note: I am running Fedora 8
which uses PulseAudio).
I also set Max Audio Channels=Stereo and Upmix=Passive.

- Adding "Aggressive Sound card Buffering" didn't make any difference.

- Changing the Audio output device to /dev/dsp (OSS) made the sound
  worse (it became completely choppy). Changing to ALSA:analog or
  ALSA:digital lost sound completely

- Interestingly, if I look at the playback tabe under pavucontrol
 (PulseAudio Volume Control), the mythtv stream seems to momentarily
 flicker off in synch with the lost audio -- almost as if the stream
 was being dropped and restarted.

- Other applications (e.g., mplayer, xine, totem) all seem to work
  fine with PulseAudio

- I have tried using both the 'Normal' playback profile which uses
  ffmpeg & XVideo and my own 'XvMC' playback profile using 'Standard
  XvMC' with xvmc-blit

Again, I originally, thought this was just a slow CPU/slow video card
problem but I upgraded from an old nVidia GeForce 4 4600 128MB card to
a new GeForce 6200 with 256MB card and the sound problems didn't
improve though my X cpu usage went down (especially with XvMC).

 As you can see below, while the CPU usage is high, it is not 100%
(nothing else is running) so, I don't think this is just due to slow
CPU (Pentium 4 2.8GHz, single core, no hyperthreading).

                         XvMC                        XV Video
                  ______________________      _______________________________
                  LiveTV      HD Playback     LiveTV          HD Playback
Mythfrontend      40-45%      50-65%          40-45%              40-45%
Mythbackend       14-17%      0%			  12-15%              0%
X                 6-8%        11-15%		  18-22%			  23-26%
PulseAudio        6-9%        9-13%			  5-8%				  8-10%


Note that the actual CPU usage improved from my old G4 4600 card where
X was taking up about 30% and leaving no free CPU -- however the
overall quality (especially the jerky sound) is really unchanged.

The  motherboard is an ASUSP4PE with embedded AD1980 6-channel audio
chip. 

My HD tuner is a PCHDTV5500 board. I don't have any problem recording
HD streams so I believe the audio (and video) IN is fine.

I really can't disable PulseAudio completely since I need it for other apps.


More information about the mythtv-users mailing list