[svn-commits] russell: branch russell/chan_console r49031 - /team/russell/chan_console/chan...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Dec 28 13:35:34 MST 2006


Author: russell
Date: Thu Dec 28 14:35:34 2006
New Revision: 49031

URL: http://svn.digium.com/view/asterisk?view=rev&rev=49031
Log:
Add a CLI command, "console list devices", which will list all available
audio devices, as well as which one is the default input device and which
is the default output device.

Modified:
    team/russell/chan_console/channels/chan_console.c

Modified: team/russell/chan_console/channels/chan_console.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/channels/chan_console.c?view=diff&rev=49031&r1=49030&r2=49031
==============================================================================
--- team/russell/chan_console/channels/chan_console.c (original)
+++ team/russell/chan_console/channels/chan_console.c Thu Dec 28 14:35:34 2006
@@ -492,9 +492,49 @@
 	return CLI_SUCCESS;
 }
 
+static char *cli_list_devices(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	PaDeviceIndex index, num, def_input, def_output;
+
+	if (cmd == CLI_INIT) {
+		e->command = "console list devices";
+		e->usage =
+			"Usage: console list devices\n"
+			"       List all available devices.\n";
+		return NULL;
+	} else if (cmd == CLI_GENERATE)
+		return NULL;
+
+	if (a->argc != e->args)
+		return CLI_SHOWUSAGE;
+
+	ast_cli(a->fd, "Available Devices:\n---------------------------------\n");
+
+	num = Pa_GetDeviceCount();
+	if (!num) {
+		ast_cli(a->fd, "(None)\n");
+		return CLI_SUCCESS;
+	}
+	def_input = Pa_GetDefaultInputDevice();
+	def_output = Pa_GetDefaultOutputDevice();
+	for (index = 0; index < num; index++) {
+		const PaDeviceInfo *dev = Pa_GetDeviceInfo(index);
+		if (!dev)
+			continue;
+		ast_cli(a->fd, "Device Name: %s\n", dev->name);
+		if (index == def_input)
+			ast_cli(a->fd, "    ---> Default Input Device\n");
+		if (index == def_output)
+			ast_cli(a->fd, "    ---> Default Output Device\n");
+	}
+
+	return CLI_SUCCESS;
+}
+
 static struct ast_cli_entry cli_console[] = {
 	NEW_CLI(cli_console_dial, "Dial an extension from the console"),
 	NEW_CLI(cli_console_hangup, "Hangup a call on the console"),
+	NEW_CLI(cli_list_devices, "List available devices"),
 };
 
 static int start_stream(void)



More information about the svn-commits mailing list