[Asterisk-code-review] app mp3: use correct buffer size for streams (asterisk[14])

Michael Kuron asteriskteam at digium.com
Sat Aug 27 04:18:50 CDT 2016


Michael Kuron has uploaded a new change for review.

  https://gerrit.asterisk.org/3741

Change subject: app_mp3: use correct buffer size for streams
......................................................................

app_mp3: use correct buffer size for streams

Previously, app_mp3 called mpg123 with a very large buffer size. For http
streams, this buffer can take minutes to fill up, so audio is never played.
This patch reduces the buffer size.

Change-Id: Id1ee274733cd804a0edecf7450329b72f1235af0
---
M apps/app_mp3.c
1 file changed, 12 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/41/3741/1

diff --git a/apps/app_mp3.c b/apps/app_mp3.c
index 5712cfe..5d1a9e3 100644
--- a/apps/app_mp3.c
+++ b/apps/app_mp3.c
@@ -94,13 +94,21 @@
 	ast_close_fds_above_n(STDERR_FILENO);
 
 	/* Execute mpg123, but buffer if it's a net connection */
-	if (!strncasecmp(filename, "http://", 7)) {
+	if (!strncasecmp(filename, "http://", 7) && strstr(filename, ".m3u")) {
 		/* Most commonly installed in /usr/local/bin */
-	    execl(LOCAL_MPG_123, "mpg123", "-q", "-s", "-b", "1024", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
+	    execl(LOCAL_MPG_123, "mpg123", "-q", "-s", "-b", "1", "-f", "8192", "--mono", "-r", "8000", "-@", filename, (char *)NULL);
 		/* But many places has it in /usr/bin */
-	    execl(MPG_123, "mpg123", "-q", "-s", "-b", "1024","-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
+	    execl(MPG_123, "mpg123", "-q", "-s", "-b", "1", "-f", "8192", "--mono", "-r", "8000", "-@", filename, (char *)NULL);
 		/* As a last-ditch effort, try to use PATH */
-	    execlp("mpg123", "mpg123", "-q", "-s", "-b", "1024",  "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
+	    execlp("mpg123", "mpg123", "-q", "-s", "-b", "1", "-f", "8192", "--mono", "-r", "8000", "-@", filename, (char *)NULL);
+	}
+	else if (!strncasecmp(filename, "http://", 7)) {
+		/* Most commonly installed in /usr/local/bin */
+	    execl(LOCAL_MPG_123, "mpg123", "-q", "-s", "-b", "1", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
+		/* But many places has it in /usr/bin */
+	    execl(MPG_123, "mpg123", "-q", "-s", "-b", "1", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
+		/* As a last-ditch effort, try to use PATH */
+	    execlp("mpg123", "mpg123", "-q", "-s", "-b", "1", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
 	}
 	else if (strstr(filename, ".m3u")) {
 		/* Most commonly installed in /usr/local/bin */

-- 
To view, visit https://gerrit.asterisk.org/3741
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id1ee274733cd804a0edecf7450329b72f1235af0
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Michael Kuron <m.kuron at gmx.de>



More information about the asterisk-code-review mailing list