From 290daf15632bfff7fb16b4e0e02ed05bb9e203d3 Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Fri, 16 Jan 2009 01:40:32 +0000 Subject: [PATCH] Add support for 'pa devlist xml' to return the device list and which are the ring/in/out devices in XML format git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11253 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../endpoints/mod_portaudio/mod_portaudio.c | 61 ++++++++++++------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index bd976b19fc..56d5ba2fa9 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -1037,34 +1037,51 @@ static switch_status_t devlist(char **argv, int argc, switch_stream_handle_t *st if (numDevices < 0) { return SWITCH_STATUS_SUCCESS; } - for (i = 0; i < numDevices; i++) { - deviceInfo = Pa_GetDeviceInfo(i); - stream->write_function(stream, "%d;%s;%d;%d;", i, deviceInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels); - prev = 0; - if (globals.ringdev == i) { - stream->write_function(stream, "r"); - prev = 1; + if (argv[0] && !strcasecmp(argv[0], "xml")) { + stream->write_function(stream, "\n\t\n"); + + for (i = 0; i < numDevices; i++) { + deviceInfo = Pa_GetDeviceInfo(i); + stream->write_function(stream, "\t\t\n", i, deviceInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels); } - if (globals.indev == i) { - if (prev) { - stream->write_function(stream, ","); + stream->write_function(stream, "\t\n\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\n\n", globals.ringdev, globals.indev, globals.outdev); + } else { + + for (i = 0; i < numDevices; i++) { + deviceInfo = Pa_GetDeviceInfo(i); + stream->write_function(stream, "%d;%s;%d;%d;", i, deviceInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels); + + prev = 0; + if (globals.ringdev == i) { + stream->write_function(stream, "r"); + prev = 1; } - stream->write_function(stream, "i"); - prev = 1; - } - if (globals.outdev == i) { - if (prev) { - stream->write_function(stream, ","); + if (globals.indev == i) { + if (prev) { + stream->write_function(stream, ","); + } + stream->write_function(stream, "i"); + prev = 1; } - stream->write_function(stream, "o"); - prev = 1; + + if (globals.outdev == i) { + if (prev) { + stream->write_function(stream, ","); + } + stream->write_function(stream, "o"); + prev = 1; + } + + stream->write_function(stream, "\n"); + } - - stream->write_function(stream, "\n"); - } return SWITCH_STATUS_SUCCESS; @@ -1670,7 +1687,7 @@ SWITCH_STANDARD_API(pa_cmd) "pa switch [|none]\n" "pa dtmf \n" "pa flags [on|off] [ear] [mouth]\n" - "pa devlist\n" + "pa devlist [xml]\n" "pa indev #|\n" "pa outdev #|\n" "pa ringdev #|\n"