aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_alsa.c
diff options
context:
space:
mode:
authorqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-09 20:06:31 +0000
committerqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-09 20:06:31 +0000
commitbbdc6cafb5a4c952b565135ee3470200673b310f (patch)
treebf8e77f6e4f2525aaca5cf79d01143c9973cdbd2 /channels/chan_alsa.c
parent994debde3c3d78011509a53fc68dd6ae27a6024e (diff)
Transmit silence when reading DTMF in ast_readstring.
Otherwise, you could get issues with DTMF timeouts causing hangups. (closes issue #17370) Reported by: makoto Patches: channel-readstring-silence-generator.patch uploaded by makoto (license 38) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@285742 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_alsa.c')
-rw-r--r--channels/chan_alsa.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index 3a9a47208..a68c031b1 100644
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -277,34 +277,25 @@ static int send_sound(void)
static void *sound_thread(void *unused)
{
- fd_set rfds;
- fd_set wfds;
- int max, res;
+ struct pollfd pfd[3] = { { .fd = sndcmd[0], .events = POLLIN }, { .fd = writedev }, { .fd = readdev } };
+ int res, x;
for (;;) {
- FD_ZERO(&rfds);
- FD_ZERO(&wfds);
- max = sndcmd[0];
- FD_SET(sndcmd[0], &rfds);
- if (cursound > -1) {
- FD_SET(writedev, &wfds);
- if (writedev > max)
- max = writedev;
+ for (x = 0; x < 3; x++) {
+ pfd[x].revents = 0;
}
+
+ pfd[1].events = cursound > -1 ? POLLOUT : 0;
#ifdef ALSA_MONITOR
- if (!alsa.owner) {
- FD_SET(readdev, &rfds);
- if (readdev > max)
- max = readdev;
- }
+ pfd[2].events = !alsa.owner ? POLLIN : 0;
#endif
- res = ast_select(max + 1, &rfds, &wfds, NULL, NULL);
+ res = ast_poll(pfd, 3, -1);
if (res < 1) {
- ast_log(LOG_WARNING, "select failed: %s\n", strerror(errno));
+ ast_log(LOG_WARNING, "poll() failed: %s\n", strerror(errno));
continue;
}
#ifdef ALSA_MONITOR
- if (FD_ISSET(readdev, &rfds)) {
+ if (pfd[2].revents & POLLIN) {
/* Keep the pipe going with read audio */
snd_pcm_state_t state;
short buf[FRAME_SIZE];
@@ -329,7 +320,7 @@ static void *sound_thread(void *unused)
alsa_monitor_read((char *) buf, r * 2);
}
#endif
- if (FD_ISSET(sndcmd[0], &rfds)) {
+ if (pfd[0].revents & POLLIN) {
if (read(sndcmd[0], &cursound, sizeof(cursound)) < 0) {
ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
}
@@ -337,9 +328,11 @@ static void *sound_thread(void *unused)
offset = 0;
sampsent = 0;
}
- if (FD_ISSET(writedev, &wfds))
- if (send_sound())
+ if (pfd[1].revents & POLLOUT) {
+ if (send_sound()) {
ast_log(LOG_WARNING, "Failed to write sound\n");
+ }
+ }
}
/* Never reached */
return NULL;