aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_mp3.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2001-04-10 20:52:03 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2001-04-10 20:52:03 +0000
commita6879656bc45edd9243238c5d518074f8d02db24 (patch)
treed68ad4358dac81748ed01e047c67a711bceb5298 /apps/app_mp3.c
parent1ab2e9f4be0b381e9c28b476204c0e5b1429c57f (diff)
Version 0.1.8 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@270 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_mp3.c')
-rwxr-xr-xapps/app_mp3.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/apps/app_mp3.c b/apps/app_mp3.c
index 7b49dc172..0013fe8b4 100755
--- a/apps/app_mp3.c
+++ b/apps/app_mp3.c
@@ -33,6 +33,13 @@ static char *tdesc = "Silly MP3 Application";
static char *app = "MP3Player";
+static char *synopsis = "Play an MP3 file or stream";
+
+static char *descrip =
+" MP3Player(location) Executes mpg123 to play the given location\n"
+" which typically would be a filename or a URL. Returns -1 on\n"
+" hangup or 0 otherwise. User can exit by pressing any key\n.";
+
STANDARD_LOCAL_USER;
LOCAL_USER_DECL;
@@ -60,7 +67,7 @@ static int mp3_exec(struct ast_channel *chan, void *data)
int res=0;
struct localuser *u;
int fds[2];
- int rfds[2];
+ int rfds[1 + AST_MAX_FDS];
int ms = -1;
int pid;
int us;
@@ -69,6 +76,7 @@ static int mp3_exec(struct ast_channel *chan, void *data)
struct timeval tv;
struct timeval last;
struct ast_frame *f;
+ int x;
struct myframe {
struct ast_frame f;
char offset[AST_FRIENDLY_OFFSET];
@@ -99,17 +107,23 @@ static int mp3_exec(struct ast_channel *chan, void *data)
pid = res;
/* Order is important -- there's almost always going to be mp3... we want to prioritize the
user */
- rfds[0] = chan->fd;
- rfds[1] = fds[0];
+ for (x=0;x<AST_MAX_FDS;x++)
+ rfds[x] = chan->fds[x];
+ rfds[x] = fds[0];
for (;;) {
CHECK_BLOCKING(chan);
- res = ast_waitfor_n_fd(rfds, 2, &ms, &exception);
+ res = ast_waitfor_n_fd(rfds, AST_MAX_FDS+1, &ms, &exception);
chan->blocking = 0;
if (res < 1) {
ast_log(LOG_DEBUG, "Hangup detected\n");
res = -1;
break;
- } else if (res == chan->fd) {
+ }
+ for(x=0;x<AST_MAX_FDS;x++)
+ if (res == chan->fds[x])
+ break;
+
+ if (x < AST_MAX_FDS) {
if (exception)
chan->exception = 1;
f = ast_read(chan);
@@ -181,7 +195,7 @@ int unload_module(void)
int load_module(void)
{
- return ast_register_application(app, mp3_exec);
+ return ast_register_application(app, mp3_exec, synopsis, descrip);
}
char *description(void)