Revision
15633
Author
andrew
Date
2009-11-23 16:15:26 -0600 (Mon, 23 Nov 2009)

Log Message

mod_portaudio: make the ringfile configurable via new API command 'pa ringfile'

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c (15632 => 15633)


--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c	2009-11-23 22:05:59 UTC (rev 15632)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c	2009-11-23 22:15:26 UTC (rev 15633)
@@ -846,8 +846,8 @@
 	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 @@
 		"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 @@
 			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) {