[Asterisk-cvs] asterisk/apps app_mp3.c,1.19,1.20
markster at lists.digium.com
markster at lists.digium.com
Sat Sep 11 09:29:09 CDT 2004
Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv20463/apps
Modified Files:
app_mp3.c
Log Message:
Use longer timeout if using http (bug #2418)
Index: app_mp3.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_mp3.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- app_mp3.c 22 Jun 2004 19:32:52 -0000 1.19
+++ app_mp3.c 11 Sep 2004 13:31:04 -0000 1.20
@@ -60,7 +60,7 @@
close(x);
}
/* Execute mpg123, but buffer if it's a net connection */
- if (!strncmp(filename, "http://", 7)) {
+ if (!strncasecmp(filename, "http://", 7)) {
/* Most commonly installed in /usr/local/bin */
execl(LOCAL_MPG_123, "mpg123", "-q", "-s", "-b", "1024", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
/* But many places has it in /usr/bin */
@@ -80,15 +80,15 @@
return -1;
}
-static int timed_read(int fd, void *data, int datalen)
+static int timed_read(int fd, void *data, int datalen, int timeout)
{
int res;
struct pollfd fds[1];
fds[0].fd = fd;
fds[0].events = POLLIN;
- res = poll(fds, 1, 2000);
+ res = poll(fds, 1, timeout);
if (res < 1) {
- ast_log(LOG_NOTICE, "Selected timed out/errored out with %d\n", res);
+ ast_log(LOG_NOTICE, "Poll timed out/errored out with %d\n", res);
return -1;
}
return read(fd, data, datalen);
@@ -103,6 +103,7 @@
int ms = -1;
int pid = -1;
int owriteformat;
+ int timeout = 2000;
struct timeval now, next;
struct ast_frame *f;
struct myframe {
@@ -110,7 +111,6 @@
char offset[AST_FRIENDLY_OFFSET];
short frdata[160];
} myf;
-
if (!data) {
ast_log(LOG_WARNING, "MP3 Playback requires an argument (filename)\n");
return -1;
@@ -131,6 +131,9 @@
gettimeofday(&now, NULL);
res = mp3play((char *)data, fds[1]);
+ if (!strncasecmp((char *)data, "http://", 7)) {
+ timeout = 10000;
+ }
/* Wait 1000 ms first */
next = now;
next.tv_sec += 1;
@@ -155,7 +158,7 @@
last = tv;
}
#endif
- res = timed_read(fds[0], myf.frdata, sizeof(myf.frdata));
+ res = timed_read(fds[0], myf.frdata, sizeof(myf.frdata), timeout);
if (res > 0) {
myf.f.frametype = AST_FRAME_VOICE;
myf.f.subclass = AST_FORMAT_SLINEAR;
More information about the svn-commits
mailing list