[mythtv] [Patch] Fix for choppy audio using ALSA
Billy Macdonald
whmac33 at comcast.net
Sun Dec 28 16:51:49 EST 2003
Hi,
This fixed the choppy audio I was getting using ALSA on my nforce2
chipset. Fixed the choppy audio for Analog and SPDIF.
Billy
-------------- next part --------------
? mypatch.diff
Index: audiooutputalsa.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/audiooutputalsa.cpp,v
retrieving revision 1.2
diff -u -w -r1.2 audiooutputalsa.cpp
--- audiooutputalsa.cpp 17 Jun 2003 00:51:23 -0000 1.2
+++ audiooutputalsa.cpp 26 Dec 2003 05:14:26 -0000
@@ -229,10 +229,14 @@
return;
// printf("Trying to write %d i frames to soundbuffer\n", frames);
+ while (frames > 0) {
err = snd_pcm_mmap_writei(pcm_handle, buffer, frames);
- if (err == -EAGAIN || (err >= 0 && err != frames))
- printf("Audio buffer overflow, audio data lost!\n");
- else if (err < 0) {
+ if (err >= 0) {
+ buffer += err * audio_bytes_per_sample;
+ frames -= err;
+ } else if (err == -EAGAIN) {
+ snd_pcm_wait(pcm_handle, 10);
+ } else if (err < 0) {
if (xrun_recovery(pcm_handle, err) < 0) {
printf("Write error: %s\n", snd_strerror(err));
printf("Disabling sound output.\n");
@@ -241,6 +245,7 @@
}
goto retry;
}
+ }
if(timecode < 0)
timecode = audbuf_timecode; // add to current timecode
More information about the mythtv-dev
mailing list