[MPlayer-dev-eng] [PATCH] ALSA: get rid of potentially endless loop

Clemens Ladisch cladisch at fastmail.net
Tue Sep 29 15:12:01 CEST 2009


Reimar Döffinger wrote:
> 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.

snd_pcm_writei will return 0 only in non-blocking mode.  If the
device does not advance at all, ALSA will eventually return an error.

As far as I can see, mplayer never calls play with a bigger amount of
data than previously returned by get_space, so snd_pcm_writei will
actually never return 0.

The (only) purpose of the loop is to retry writing immediately if error
recovery has been necessary.

> 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.

Those functions never return > 0.


Best regards,
Clemens



More information about the MPlayer-dev-eng mailing list