[Asterisk-code-review] app_mp3: Throw warning on nonexistent stream (asterisk[19])

Joshua Colp asteriskteam at digium.com
Wed Jan 5 10:55:53 CST 2022


Joshua Colp has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/17811 )

Change subject: app_mp3: Throw warning on nonexistent stream
......................................................................

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
---
M apps/app_mp3.c
1 file changed, 5 insertions(+), 0 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
  George Joseph: Looks good to me, approved



diff --git a/apps/app_mp3.c b/apps/app_mp3.c
index 888f21a..5d2fc88 100644
--- a/apps/app_mp3.c
+++ b/apps/app_mp3.c
@@ -179,6 +179,7 @@
 	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 @@
 				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;
 				}

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/17811
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 19
Gerrit-Change-Id: I53a0bf1ed1740166655eb66fe7675f6f808bf535
Gerrit-Change-Number: 17811
Gerrit-PatchSet: 2
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220105/da85825b/attachment-0001.html>


More information about the asterisk-code-review mailing list