mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 19:52:48 +00:00
Version 0.1.9 from FTP
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@340 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -47,12 +47,17 @@ LOCAL_USER_DECL;
|
|||||||
static int mp3play(char *filename, int fd)
|
static int mp3play(char *filename, int fd)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
int x;
|
||||||
res = fork();
|
res = fork();
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
ast_log(LOG_WARNING, "Fork failed\n");
|
ast_log(LOG_WARNING, "Fork failed\n");
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
dup2(fd, STDOUT_FILENO);
|
dup2(fd, STDOUT_FILENO);
|
||||||
|
for (x=0;x<256;x++) {
|
||||||
|
if (x != STDOUT_FILENO)
|
||||||
|
close(x);
|
||||||
|
}
|
||||||
/* Execute mpg123, but buffer if it's a net connection */
|
/* Execute mpg123, but buffer if it's a net connection */
|
||||||
if (strncmp(filename, "http://", 7))
|
if (strncmp(filename, "http://", 7))
|
||||||
execl(MPG_123, MPG_123, "-q", "-s", "-b", "1024", "--mono", "-r", "8000", filename, NULL);
|
execl(MPG_123, MPG_123, "-q", "-s", "-b", "1024", "--mono", "-r", "8000", filename, NULL);
|
||||||
@@ -69,7 +74,7 @@ static int mp3_exec(struct ast_channel *chan, void *data)
|
|||||||
int fds[2];
|
int fds[2];
|
||||||
int rfds[1 + AST_MAX_FDS];
|
int rfds[1 + AST_MAX_FDS];
|
||||||
int ms = -1;
|
int ms = -1;
|
||||||
int pid;
|
int pid = -1;
|
||||||
int us;
|
int us;
|
||||||
int exception;
|
int exception;
|
||||||
int owriteformat;
|
int owriteformat;
|
||||||
@@ -107,11 +112,11 @@ static int mp3_exec(struct ast_channel *chan, void *data)
|
|||||||
pid = res;
|
pid = res;
|
||||||
/* Order is important -- there's almost always going to be mp3... we want to prioritize the
|
/* Order is important -- there's almost always going to be mp3... we want to prioritize the
|
||||||
user */
|
user */
|
||||||
for (x=0;x<AST_MAX_FDS;x++)
|
rfds[AST_MAX_FDS] = fds[0];
|
||||||
rfds[x] = chan->fds[x];
|
|
||||||
rfds[x] = fds[0];
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
CHECK_BLOCKING(chan);
|
CHECK_BLOCKING(chan);
|
||||||
|
for (x=0;x<AST_MAX_FDS;x++)
|
||||||
|
rfds[x] = chan->fds[x];
|
||||||
res = ast_waitfor_n_fd(rfds, AST_MAX_FDS+1, &ms, &exception);
|
res = ast_waitfor_n_fd(rfds, AST_MAX_FDS+1, &ms, &exception);
|
||||||
chan->blocking = 0;
|
chan->blocking = 0;
|
||||||
if (res < 1) {
|
if (res < 1) {
|
||||||
@@ -177,12 +182,13 @@ static int mp3_exec(struct ast_channel *chan, void *data)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
kill(pid, SIGTERM);
|
|
||||||
}
|
}
|
||||||
close(fds[0]);
|
close(fds[0]);
|
||||||
close(fds[1]);
|
close(fds[1]);
|
||||||
LOCAL_USER_REMOVE(u);
|
LOCAL_USER_REMOVE(u);
|
||||||
if (!res)
|
if (pid > -1)
|
||||||
|
kill(pid, SIGKILL);
|
||||||
|
if (!res && owriteformat)
|
||||||
ast_set_write_format(chan, owriteformat);
|
ast_set_write_format(chan, owriteformat);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user