[MPlayer-dev-eng] [PATCH] ALSA: get rid of potentially endless loop
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Tue Sep 29 14:46:18 CEST 2009
Hello,
Since MPlayer will try writing audio again sooner or later if the play
function returns 0, I don't see much value in that loop, particularly
since if for some reason a broken snd_pcm_writei returns 0 all the time
it will be an endless loop and MPlayer will be stuck completely.
I have to add I do not like the overall code at all, if snd_pcm_resume
or snd_pcm_prepare ever return something > 0 total chaos will result.
Index: libao2/ao_alsa.c
===================================================================
--- libao2/ao_alsa.c (revision 29732)
+++ libao2/ao_alsa.c (working copy)
@@ -776,7 +781,6 @@
if (num_frames == 0)
return 0;
- do {
res = snd_pcm_writei(alsa_handler, data, num_frames);
if (res == -EINTR) {
@@ -794,10 +798,8 @@
if ((res = snd_pcm_prepare(alsa_handler)) < 0) {
mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PcmPrepareError, snd_strerror(res));
return 0;
- break;
}
}
- } while (res == 0);
return res < 0 ? res : res * bytes_per_sample;
}
More information about the MPlayer-dev-eng
mailing list