]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add param to not fail module load on device fail
authorRaymond Chandler <intralanman@gmail.com>
Wed, 20 Mar 2013 19:10:19 +0000 (15:10 -0400)
committerRaymond Chandler <intralanman@gmail.com>
Wed, 20 Mar 2013 19:10:19 +0000 (15:10 -0400)
src/mod/endpoints/mod_portaudio/conf/autoload_configs/portaudio.conf.xml
src/mod/endpoints/mod_portaudio/mod_portaudio.c

index 02c21ef449189798d8e5fb99ed0e569e428b3bd6..1a69eeb43b3a0b313d13003a45648171a106e282 100644 (file)
@@ -31,6 +31,9 @@
     <!--audio sample rate and interval -->
     <param name="sample-rate" value="48000"/>
     <param name="codec-ms" value="20"/>
+
+    <!--uncomment the following line to make mod_portaudio fail to load if it fails to find a device-->
+    <param name="unload-on-device-fail" value="true"/>
   </settings>
 
   <!-- 
index f5487486ce6cd1b1cb9a66d8acc73eca8df84dbf..10685f3adffb9f547f731038057849d9f1937b30 100644 (file)
@@ -25,6 +25,7 @@
  * 
  * Anthony Minessale II <anthm@freeswitch.org>
  * Moises Silva <moises.silva@gmail.com> (Multiple endpoints work sponsored by Comrex Corporation)
+ * Raymond Chandler <intralanman@freeswitch.org>
  *
  *
  * mod_portaudio.c -- PortAudio Endpoint Module
@@ -185,6 +186,7 @@ static struct {
        int indev;
        int outdev;
        int call_id;
+       int unload_device_fail;
        switch_hash_t *call_hash;
        switch_mutex_t *device_lock;
        switch_mutex_t *pvt_lock;
@@ -1653,6 +1655,7 @@ static switch_status_t load_config(void)
        globals.no_ring_during_call = 0;
        globals.indev = globals.outdev = globals.ringdev = -1;
        globals.sample_rate = 8000;
+       globals.unload_device_fail = 0;
 
        if ((settings = switch_xml_child(cfg, "settings"))) {
                for (param = switch_xml_child(settings, "param"); param; param = param->next) {
@@ -1729,6 +1732,8 @@ static switch_status_t load_config(void)
                                } else {
                                        globals.ringdev = get_dev_by_name(val, 0);
                                }
+                       } else if (!strcasecmp(var, "unload-on-device-fail")) {
+                               globals.unload_device_fail = switch_true(val);
                        }
                }
        }
@@ -1761,21 +1766,27 @@ static switch_status_t load_config(void)
 
        if (globals.indev < 0) {
                globals.indev = get_dev_by_name(NULL, 1);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "global indev [%d]\n", globals.indev);
                if (globals.indev > -1) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Switching to default input device\n");
                } else {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find an input device\n");
-                       status = SWITCH_STATUS_GENERR;
+                       if (globals.unload_device_fail) {
+                               status = SWITCH_STATUS_GENERR;
+                       }
                }
        }
 
        if (globals.outdev < 0) {
                globals.outdev = get_dev_by_name(NULL, 0);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "global outdev [%d]\n", globals.outdev);
                if (globals.outdev > -1) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Switching to default output device\n");
                } else {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find an output device\n");
-                       status = SWITCH_STATUS_GENERR;
+                       if (globals.unload_device_fail) {
+                               status = SWITCH_STATUS_GENERR;
+                       }
                }
        }