]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_portaudio: make the ringfile configurable via new API command 'pa ringfile'
authorAndrew Thompson <andrew@hijacked.us>
Mon, 23 Nov 2009 22:15:26 +0000 (22:15 +0000)
committerAndrew Thompson <andrew@hijacked.us>
Mon, 23 Nov 2009 22:15:26 +0000 (22:15 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15633 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_portaudio/mod_portaudio.c

index 24458e440b1544096025588120fdf0d16dd9ff24..bd9c64ba6250dee44f9953c41676acf1ca706012 100644 (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) {