[asterisk-commits] russell: branch russell/jack r96691 - /team/russell/jack/apps/app_jack.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jan 5 10:40:01 CST 2008


Author: russell
Date: Sat Jan  5 10:40:01 2008
New Revision: 96691

URL: http://svn.digium.com/view/asterisk?view=rev&rev=96691
Log:
Add an option for specify the jack server name to connect to

Modified:
    team/russell/jack/apps/app_jack.c

Modified: team/russell/jack/apps/app_jack.c
URL: http://svn.digium.com/view/asterisk/team/russell/jack/apps/app_jack.c?view=diff&rev=96691&r1=96690&r2=96691
==============================================================================
--- team/russell/jack/apps/app_jack.c (original)
+++ team/russell/jack/apps/app_jack.c Sat Jan  5 10:40:01 2008
@@ -56,6 +56,7 @@
 #include "asterisk/strings.h"
 #include "asterisk/lock.h"
 #include "asterisk/libresample.h"
+#include "asterisk/app.h"
 
 #define RESAMPLE_QUALITY 0
 
@@ -65,10 +66,12 @@
 static char *jack_synopsis = 
 "JACK (Jack Audio Connection Kit) Application";
 static char *jack_desc = 
-"Jack()\n"
-"  This application takes no arguments.  When executed, two jack ports will\n"
-"get created; one input and one output.  Other applications can be hooked up\n"
-"to these ports to access the audio coming from, or being sent to the channel.\n"
+"Jack([options])\n"
+"  When this application is executed, two jack ports will be created; one input\n"
+"and one output.  Other applications can be hooked up to these ports to access\n"
+"the audio coming from, or being sent to the channel.\n"
+"  Valid options:\n"
+"    s(<name>) - Connect to the specified jack server name.\n"
 "";
 
 struct jack_data {
@@ -77,6 +80,7 @@
 	jack_port_t *output_port;
 	jack_ringbuffer_t *input_rb;
 	jack_ringbuffer_t *output_rb;
+	const char *server_name;
 	void *output_resampler;
 	double output_resample_factor;
 	void *input_resampler;
@@ -341,7 +345,13 @@
 		return -1;
 	}
 
-	jack_data->client = jack_client_open(chan_name, 0, &status);
+	if (!ast_strlen_zero(jack_data->server_name)) {
+		jack_data->client = jack_client_open(chan_name, JackServerName, &status,
+			jack_data->server_name);
+	} else {
+		jack_data->client = jack_client_open(chan_name, JackNullOption, &status);
+	}
+
 	if (status)
 		log_jack_status("Client Open Status", status);
 
@@ -488,10 +498,41 @@
 	}
 }
 
+enum {
+	OPT_SERVERNAME = (1 << 0),
+};
+
+enum {
+	OPT_ARG_SERVERNAME,
+	/* Must be the last element */
+	OPT_ARG_ARRAY_SIZE,
+};
+
+AST_APP_OPTIONS(jack_exec_options, BEGIN_OPTIONS
+	AST_APP_OPTION_ARG('s', OPT_SERVERNAME, OPT_ARG_SERVERNAME),
+END_OPTIONS );
+
 static int jack_exec(struct ast_channel *chan, void *data)
 {
 	int res = 0;
 	struct jack_data jack_data = { NULL, };
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(options);
+	);
+	struct ast_flags options = { 0, };
+	char *option_args[OPT_ARG_ARRAY_SIZE];
+
+	args.options = data;
+
+	if (!ast_strlen_zero(args.options)) {
+		ast_app_parse_options(jack_exec_options, &options, option_args, args.options);
+		if (ast_test_flag(&options, OPT_SERVERNAME)) {
+			if (!ast_strlen_zero(option_args[OPT_ARG_SERVERNAME]))
+				jack_data.server_name = option_args[OPT_ARG_SERVERNAME];
+			else
+				ast_log(LOG_ERROR, "A server name must be provided with the s() option\n");
+		}
+	}
 
 	if (init_jack_data(chan, &jack_data)) {
 		destroy_jack_data(&jack_data);




More information about the asterisk-commits mailing list