Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
c59142e2
Commit
c59142e2
authored
6 years ago
by
Jenkins2
Committed by
Gerrit Code Review
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge "app_mp3: remove 10 seconds of silence after mp3 playback"
parents
c857c713
4c7ab734
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/app_mp3.c
+25
-7
25 additions, 7 deletions
apps/app_mp3.c
with
25 additions
and
7 deletions
apps/app_mp3.c
+
25
−
7
View file @
c59142e2
...
...
@@ -35,6 +35,7 @@
#include
"asterisk.h"
#include
<sys/time.h>
#include
<sys/types.h>
#include
<signal.h>
#include
"asterisk/lock.h"
...
...
@@ -136,17 +137,34 @@ static int mp3play(const char *filename, unsigned int sampling_rate, int fd)
_exit
(
0
);
}
static
int
timed_read
(
int
fd
,
void
*
data
,
int
datalen
,
int
timeout
)
static
int
timed_read
(
int
fd
,
void
*
data
,
int
datalen
,
int
timeout
,
int
pid
)
{
int
res
;
int
i
;
struct
pollfd
fds
[
1
];
fds
[
0
].
fd
=
fd
;
fds
[
0
].
events
=
POLLIN
;
res
=
ast_poll
(
fds
,
1
,
timeout
);
if
(
res
<
1
)
{
ast_log
(
LOG_NOTICE
,
"Poll timed out/errored out with %d
\n
"
,
res
);
for
(
i
=
0
;
i
<
timeout
;
i
++
)
{
res
=
ast_poll
(
fds
,
1
,
1000
);
if
(
res
>
0
)
{
break
;
}
else
if
(
res
==
0
)
{
/* is mpg123 still running? */
kill
(
pid
,
0
);
if
(
errno
==
ESRCH
)
{
return
-
1
;
}
}
else
{
ast_log
(
LOG_NOTICE
,
"error polling mpg123: %s
\n
"
,
strerror
(
errno
));
return
-
1
;
}
}
if
(
i
==
timeout
)
{
ast_log
(
LOG_NOTICE
,
"Poll timed out.
\n
"
);
return
-
1
;
}
return
read
(
fd
,
data
,
datalen
);
}
...
...
@@ -158,7 +176,7 @@ static int mp3_exec(struct ast_channel *chan, const char *data)
int
ms
=
-
1
;
int
pid
=
-
1
;
RAII_VAR
(
struct
ast_format
*
,
owriteformat
,
NULL
,
ao2_cleanup
);
int
timeout
=
2
000
;
int
timeout
=
2
;
struct
timeval
next
;
struct
ast_frame
*
f
;
struct
myframe
{
...
...
@@ -206,7 +224,7 @@ static int mp3_exec(struct ast_channel *chan, const char *data)
res
=
mp3play
(
data
,
sampling_rate
,
fds
[
1
]);
if
(
!
strncasecmp
(
data
,
"http://"
,
7
))
{
timeout
=
10
000
;
timeout
=
10
;
}
/* Wait 1000 ms first */
next
=
ast_tvnow
();
...
...
@@ -218,7 +236,7 @@ static int mp3_exec(struct ast_channel *chan, const char *data)
for
(;;)
{
ms
=
ast_tvdiff_ms
(
next
,
ast_tvnow
());
if
(
ms
<=
0
)
{
res
=
timed_read
(
fds
[
0
],
myf
.
frdata
,
sizeof
(
myf
.
frdata
),
timeout
);
res
=
timed_read
(
fds
[
0
],
myf
.
frdata
,
sizeof
(
myf
.
frdata
),
timeout
,
pid
);
if
(
res
>
0
)
{
myf
.
f
.
datalen
=
res
;
myf
.
f
.
samples
=
res
/
2
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment