Skip to content
Snippets Groups Projects
Commit 80766059 authored by Naveen Albert's avatar Naveen Albert Committed by Joshua Colp
Browse files

app_mp3: Throw warning on nonexistent stream

Currently, the MP3Player application doesn't
emit a warning if attempting to play a stream
which no longer exists. This can be a common
scenario as many mp3 streams are valid at some
point but can disappear at any time.

Now a warning is thrown if attempting to play
a nonexistent MP3 stream, instead of silently
exiting.

ASTERISK-29829 #close

Change-Id: I53a0bf1ed1740166655eb66fe7675f6f808bf535
parent 70bc0ff9
No related branches found
No related tags found
3 merge requests!138Merge branch asterisk-20.3.0 into devel properly,!123Merge asterisk '20.3.0' into devel,!118Draft: manager: AOC-S support for AOCMessage
......@@ -179,6 +179,7 @@ static int mp3_exec(struct ast_channel *chan, const char *data)
int pid = -1;
RAII_VAR(struct ast_format *, owriteformat, NULL, ao2_cleanup);
int timeout = 2;
int startedmp3 = 0;
struct timeval next;
struct ast_frame *f;
struct myframe {
......@@ -242,12 +243,16 @@ static int mp3_exec(struct ast_channel *chan, const char *data)
if (res > 0) {
myf.f.datalen = res;
myf.f.samples = res / 2;
startedmp3 = 1;
if (ast_write(chan, &myf.f) < 0) {
res = -1;
break;
}
} else {
ast_debug(1, "No more mp3\n");
if (!startedmp3) { /* we couldn't do anything, which means this stream doesn't work */
ast_log(LOG_WARNING, "MP3 stream '%s' is broken or nonexistent\n", data);
}
res = 0;
break;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment