mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
Merged revisions 167095 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r167095 | tilghman | 2008-12-31 18:01:22 -0600 (Wed, 31 Dec 2008) | 5 lines Repeat attempts to write when we receive -EAGAIN from the driver, as detailed in the ALSA sample code (see http://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html#a32) Reported by: Jerry Geis (via the -users list) Fixed by: me (license 14) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@168526 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -381,13 +381,17 @@ static int alsa_write(struct ast_channel *chan, struct ast_frame *f)
|
|||||||
state = snd_pcm_state(alsa.ocard);
|
state = snd_pcm_state(alsa.ocard);
|
||||||
if (state == SND_PCM_STATE_XRUN)
|
if (state == SND_PCM_STATE_XRUN)
|
||||||
snd_pcm_prepare(alsa.ocard);
|
snd_pcm_prepare(alsa.ocard);
|
||||||
res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2);
|
while ((res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2)) == -EAGAIN) {
|
||||||
|
usleep(1);
|
||||||
|
}
|
||||||
if (res == -EPIPE) {
|
if (res == -EPIPE) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
ast_debug(1, "XRUN write\n");
|
ast_debug(1, "XRUN write\n");
|
||||||
#endif
|
#endif
|
||||||
snd_pcm_prepare(alsa.ocard);
|
snd_pcm_prepare(alsa.ocard);
|
||||||
res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2);
|
while ((res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2)) == -EAGAIN) {
|
||||||
|
usleep(1);
|
||||||
|
}
|
||||||
if (res != len / 2) {
|
if (res != len / 2) {
|
||||||
ast_log(LOG_ERROR, "Write error: %s\n", snd_strerror(res));
|
ast_log(LOG_ERROR, "Write error: %s\n", snd_strerror(res));
|
||||||
res = -1;
|
res = -1;
|
||||||
|
Reference in New Issue
Block a user