aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_mp3.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/app_mp3.c')
-rwxr-xr-xapps/app_mp3.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/apps/app_mp3.c b/apps/app_mp3.c
index aee04795f..7432d90d0 100755
--- a/apps/app_mp3.c
+++ b/apps/app_mp3.c
@@ -84,11 +84,10 @@ static int mp3play(char *filename, int fd)
static int timed_read(int fd, void *data, int datalen)
{
int res;
- fd_set fds;
- struct timeval tv = { 2, 0 }; /* Wait no more than 2 seconds */
- FD_ZERO(&fds);
- FD_SET(fd, &fds);
- res = ast_select(fd + 1, &fds, NULL, NULL, &tv);
+ struct pollfd fds[1];
+ fds[0].fd = fd;
+ fds[0].events = POLLIN;
+ res = poll(fds, 1, 2000);
if (res < 1) {
ast_log(LOG_NOTICE, "Selected timed out/errored out with %d\n", res);
return -1;
@@ -146,7 +145,7 @@ static int mp3_exec(struct ast_channel *chan, void *data)
res = -1;
break;
}
- if (ms) {
+ if (ms > 40) {
f = ast_read(chan);
if (!f) {
ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
@@ -161,6 +160,15 @@ static int mp3_exec(struct ast_channel *chan, void *data)
}
ast_frfree(f);
} else {
+#if 0
+ {
+ static struct timeval last;
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ printf("Since last: %ld\n", (tv.tv_sec - last.tv_sec) * 1000 + (tv.tv_usec - last.tv_usec) / 1000);
+ last = tv;
+ }
+#endif
res = timed_read(fds[0], myf.frdata, sizeof(myf.frdata));
if (res > 0) {
myf.f.frametype = AST_FRAME_VOICE;
@@ -182,7 +190,10 @@ static int mp3_exec(struct ast_channel *chan, void *data)
res = 0;
break;
}
- ms = res / 16;
+ ms += res / 16;
+#if 0
+ printf("Next: %d\n", ms);
+#endif
}
}
}