From f6e24c3c950c66ae06ff146adc880898d07f4ff9 Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Mon, 23 Nov 2009 22:15:26 +0000 Subject: [PATCH] mod_portaudio: make the ringfile configurable via new API command 'pa ringfile' git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15633 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../endpoints/mod_portaudio/mod_portaudio.c | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index 24458e440b..bd9c64ba62 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -846,8 +846,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load) switch_console_set_complete("add pa indev"); switch_console_set_complete("add pa outdev"); switch_console_set_complete("add pa ringdev"); + switch_console_set_complete("add pa ringfile"); switch_console_set_complete("add pa play"); - switch_console_set_complete("add pa ringtest"); switch_console_set_complete("add pa looptest"); /* indicate that the module should continue to be loaded */ @@ -1833,6 +1833,7 @@ SWITCH_STANDARD_API(pa_cmd) "pa outdev #|\n" "pa ringdev #|\n" "pa play [ringtest|]\n" + "pa ringfile [filename]\n" "pa looptest\n" "--------------------------------------------------------------------------------\n"; @@ -2060,6 +2061,27 @@ SWITCH_STANDARD_API(pa_cmd) stream->write_function(stream, "Failed to engage audio device\n"); } goto done; + } else if (!strcasecmp(argv[0], "ringfile")) { + if (argv[1]) { + if (engage_device(0) == SWITCH_STATUS_SUCCESS) { + switch_file_handle_t fh = { 0 }; + if (switch_core_file_open(&fh, + argv[1], + globals.read_codec.implementation->number_of_channels, + globals.read_codec.implementation->actual_samples_per_second, + SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) { + switch_core_file_close(&fh); + set_global_ring_file(argv[1]); + } else { + stream->write_function(stream, "Unable to open ring file %s\n", argv[1]); + } + } else { + stream->write_function(stream, "Failed to engage audio device\n"); + } + } else { + stream->write_function(stream, "%s", globals.ring_file); + } + goto done; } if (func) {