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
This commit is contained in:
Andrew Thompson 2009-11-23 22:15:26 +00:00
parent fa29ea1545
commit f6e24c3c95
1 changed files with 23 additions and 1 deletions

View File

@ -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 #<num>|<partial name>\n"
"pa ringdev #<num>|<partial name>\n"
"pa play [ringtest|<filename>]\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) {