<h1>Project "FreeSWITCH Source" received a push.</h1>

<h2>branch: master updated</h2>
<pre>
       via: b3086c1d6b6f4900ec770e22878038ac565424d9 (commit)
       via: 294436486302d0547b34ba26e5fa402c4ebaa58f (commit)
       via: 998a04d2cfa361a4d600175809d5fef02374c720 (commit)
       via: e7d68a79dc7838d74e7b8985494dcde532910d32 (commit)
       via: 8f565277e3a9e814c12779f3d51f2527a081ef99 (commit)
       via: 20976da4114c2c5fc0213fa4cda91f7f4bf8a136 (commit)
       via: e37dd41e311986015393befed7160e27a6450933 (commit)
       via: b8b7266abb7a6c081ad1e1531aea69daf5d7509c (commit)
       via: f4481b05ab8ae1faf6eedb438085e688371e79c6 (commit)
       via: e9e33f5160fb5272c4f912dac6a29415215bba1c (commit)
       via: 36f6218b8bba3233cf3fb501b01a0288a08e9f00 (commit)
       via: 2ec2a9b0d335a8d6a30ab5a92448ac3ad63649ff (commit)
       via: 46f6c6e42d2775ccfecb8f445ebbaaf32ab34df7 (commit)
       via: b6ac001276961761b14a89270da02498b4d3e740 (commit)
       via: 2d190b37abe00999a2e76861b8c88f0053e0b78f (commit)
       via: dc436b82a52da05686ac178ad7854556e9688ed8 (commit)
       via: bdf678e401a8077aab06b9c04004c92ef6631e26 (commit)
       via: e79174cacf6abb943fe34840a5261b940b281c91 (commit)
       via: 33b74ca8c710a58d245ea8903f98e0e86cffe164 (commit)
       via: 68d08547f36777e2c091008b5e1207ca5b15e9e2 (commit)
       via: e5fb456f3bfddbf1e379c77030e8e4dd5549d12a (commit)
       via: 74a0cfd1e101413a3941c41d04ee01d8df2ae418 (commit)
       via: b55b4eeaeea1d1cebc5a44ffdd88b224898d5d8a (commit)
       via: f60fdf653dd2d7f8d3eaa6a9086e1f68bd993c59 (commit)
       via: 85913b70b43483d4d3d840d128549ddba75b56a6 (commit)
       via: 257bf9a46c44f76d8b38c90f288f364bcf1c6398 (commit)
       via: 4ae8282e6c6df0e296113e9b4b4a1383e1af8ad7 (commit)
       via: 89c5f3bf8226bf605336b66e7761fd9f753d935a (commit)
       via: 83dea0ee45a1eed53fe6c7bcac96410229c2fe3c (commit)
      from: 673678509f0f3ea0464ea45798c0cdbc4843946b (commit)


</pre>= COMMIT LOG ===========================================================
<div class="highlight"><pre>committer: Leon de Rooij
comments: 
Merge branch &#39;master&#39; of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
nm 40 doesn&#39;t work yet

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/codecs/mod_opus/mod_opus.c b/src/mod/codecs/mod_opus/mod_opus.c</span>
<span style="color: #000080; font-weight: bold">index 0234ed8..b9a3120 100644</span>
<span style="color: #A00000">--- a/src/mod/codecs/mod_opus/mod_opus.c</span>
<span style="color: #00A000">+++ b/src/mod/codecs/mod_opus/mod_opus.c</span>
<span style="color: #800080; font-weight: bold">@@ -159,7 +159,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load)</span>
 
         SWITCH_ADD_CODEC(codec_interface, &quot;OPUS (BETA 0.9.0)&quot;);
 
<span style="color: #A00000">-        for (x = 0; x &lt; 3; x++) {</span>
<span style="color: #00A000">+        for (x = 0; x &lt; 2; x++) {</span>
                 switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
                                                                                          115,        /* the IANA code number */
                                                                                          &quot;Opus-0.9.0&quot;,/* the IANA code name */
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
add 10 20 and 40ms

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/codecs/mod_opus/mod_opus.c b/src/mod/codecs/mod_opus/mod_opus.c</span>
<span style="color: #000080; font-weight: bold">index ddb5a7a..0234ed8 100644</span>
<span style="color: #A00000">--- a/src/mod/codecs/mod_opus/mod_opus.c</span>
<span style="color: #00A000">+++ b/src/mod/codecs/mod_opus/mod_opus.c</span>
<span style="color: #800080; font-weight: bold">@@ -147,52 +147,43 @@ static switch_status_t switch_opus_decode(switch_codec_t *codec,</span>
 SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load)
 {
         switch_codec_interface_t *codec_interface;
<span style="color: #00A000">+        int samples = 80;</span>
<span style="color: #00A000">+        int bytes = 960;</span>
<span style="color: #00A000">+        int mss = 10000;</span>
<span style="color: #00A000">+        int x = 0;</span>
<span style="color: #00A000">+        int rate = 48000;</span>
<span style="color: #00A000">+        int bits = 32000;</span>
 
         /* connect my internal structure to the blank pointer passed to me */
         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
 
         SWITCH_ADD_CODEC(codec_interface, &quot;OPUS (BETA 0.9.0)&quot;);
 
<span style="color: #A00000">-        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */</span>
<span style="color: #A00000">-                                                                                 115,        /* the IANA code number */</span>
<span style="color: #A00000">-                                                                                 &quot;Opus-0.9.0&quot;,/* the IANA code name */</span>
<span style="color: #A00000">-                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function) */</span>
<span style="color: #A00000">-                                                                                 48000,        /* samples transferred per second */</span>
<span style="color: #A00000">-                                                                                 48000,        /* actual samples transferred per second */</span>
<span style="color: #A00000">-                                                                                 32000,        /* bits transferred per second */</span>
<span style="color: #A00000">-                                                                                 10000,        /* number of microseconds per frame */</span>
<span style="color: #A00000">-                                                                                 80,        /* number of samples per frame */</span>
<span style="color: #A00000">-                                                                                 960,        /* number of bytes per frame decompressed */</span>
<span style="color: #A00000">-                                                                                 0,        /* number of bytes per frame compressed */</span>
<span style="color: #A00000">-                                                                                 1,        /* number of channels represented */</span>
<span style="color: #A00000">-                                                                                 1,        /* number of frames per network packet */</span>
<span style="color: #A00000">-                                                                                 switch_opus_init,        /* function to initialize a codec handle using this implementation */</span>
<span style="color: #A00000">-                                                                                 switch_opus_encode,        /* function to encode raw data into encoded data */</span>
<span style="color: #A00000">-                                                                                 switch_opus_decode,        /* function to decode encoded data into raw data */</span>
<span style="color: #A00000">-                                                                                 switch_opus_destroy);        /* deinitalize a codec handle using this implementation */</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */</span>
<span style="color: #A00000">-                                                                                 115,        /* the IANA code number */</span>
<span style="color: #A00000">-                                                                                 &quot;Opus-0.9.0&quot;,        /* the IANA code name */</span>
<span style="color: #A00000">-                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function) */</span>
<span style="color: #A00000">-                                                                                 48000,        /* samples transferred per second */</span>
<span style="color: #A00000">-                                                                                 48000,        /* actual samples transferred per second */</span>
<span style="color: #A00000">-                                                                                 32000,        /* bits transferred per second */</span>
<span style="color: #A00000">-                                                                                 20000,        /* number of microseconds per frame */</span>
<span style="color: #A00000">-                                                                                 160,        /* number of samples per frame */</span>
<span style="color: #A00000">-                                                                                 1920,        /* number of bytes per frame decompressed */</span>
<span style="color: #A00000">-                                                                                 0,        /* number of bytes per frame compressed */</span>
<span style="color: #A00000">-                                                                                 1,        /* number of channels represented */</span>
<span style="color: #A00000">-                                                                                 1,        /* number of frames per network packet */</span>
<span style="color: #A00000">-                                                                                 switch_opus_init,        /* function to initialize a codec handle using this implementation */</span>
<span style="color: #A00000">-                                                                                 switch_opus_encode,        /* function to encode raw data into encoded data */</span>
<span style="color: #A00000">-                                                                                 switch_opus_decode,        /* function to decode encoded data into raw data */</span>
<span style="color: #A00000">-                                                                                 switch_opus_destroy);        /* deinitalize a codec handle using this implementation */</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        for (x = 0; x &lt; 3; x++) {</span>
<span style="color: #00A000">+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */</span>
<span style="color: #00A000">+                                                                                         115,        /* the IANA code number */</span>
<span style="color: #00A000">+                                                                                         &quot;Opus-0.9.0&quot;,/* the IANA code name */</span>
<span style="color: #00A000">+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */</span>
<span style="color: #00A000">+                                                                                         rate,        /* samples transferred per second */</span>
<span style="color: #00A000">+                                                                                         rate,        /* actual samples transferred per second */</span>
<span style="color: #00A000">+                                                                                         bits,        /* bits transferred per second */</span>
<span style="color: #00A000">+                                                                                         mss,        /* number of microseconds per frame */</span>
<span style="color: #00A000">+                                                                                         samples,        /* number of samples per frame */</span>
<span style="color: #00A000">+                                                                                         bytes,        /* number of bytes per frame decompressed */</span>
<span style="color: #00A000">+                                                                                         0,        /* number of bytes per frame compressed */</span>
<span style="color: #00A000">+                                                                                         1,        /* number of channels represented */</span>
<span style="color: #00A000">+                                                                                         1,        /* number of frames per network packet */</span>
<span style="color: #00A000">+                                                                                         switch_opus_init,        /* function to initialize a codec handle using this implementation */</span>
<span style="color: #00A000">+                                                                                         switch_opus_encode,        /* function to encode raw data into encoded data */</span>
<span style="color: #00A000">+                                                                                         switch_opus_decode,        /* function to decode encoded data into raw data */</span>
<span style="color: #00A000">+                                                                                         switch_opus_destroy);        /* deinitalize a codec handle using this implementation */</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                bytes *= 2;</span>
<span style="color: #00A000">+                samples *= 2;</span>
<span style="color: #00A000">+                mss *= 2;</span>
 
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        </span>
         /* indicate that the module should continue to be loaded */
         return SWITCH_STATUS_SUCCESS;
 }
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
change signalling name to avoid polluting the namespace before its ready

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/codecs/mod_opus/mod_opus.c b/src/mod/codecs/mod_opus/mod_opus.c</span>
<span style="color: #000080; font-weight: bold">index 341254f..ddb5a7a 100644</span>
<span style="color: #A00000">--- a/src/mod/codecs/mod_opus/mod_opus.c</span>
<span style="color: #00A000">+++ b/src/mod/codecs/mod_opus/mod_opus.c</span>
<span style="color: #800080; font-weight: bold">@@ -151,11 +151,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load)</span>
         /* connect my internal structure to the blank pointer passed to me */
         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
 
<span style="color: #A00000">-        SWITCH_ADD_CODEC(codec_interface, &quot;OPUS (BETA)&quot;);</span>
<span style="color: #00A000">+        SWITCH_ADD_CODEC(codec_interface, &quot;OPUS (BETA 0.9.0)&quot;);</span>
 
         switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
                                                                                  115,        /* the IANA code number */
<span style="color: #A00000">-                                                                                 &quot;OPUS&quot;,        /* the IANA code name */</span>
<span style="color: #00A000">+                                                                                 &quot;Opus-0.9.0&quot;,/* the IANA code name */</span>
                                                                                  NULL,        /* default fmtp to send (can be overridden by the init function) */
                                                                                  48000,        /* samples transferred per second */
                                                                                  48000,        /* actual samples transferred per second */
<span style="color: #800080; font-weight: bold">@@ -174,7 +174,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load)</span>
 
         switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
                                                                                  115,        /* the IANA code number */
<span style="color: #A00000">-                                                                                 &quot;OPUS&quot;,        /* the IANA code name */</span>
<span style="color: #00A000">+                                                                                 &quot;Opus-0.9.0&quot;,        /* the IANA code name */</span>
                                                                                  NULL,        /* default fmtp to send (can be overridden by the init function) */
                                                                                  48000,        /* samples transferred per second */
                                                                                  48000,        /* actual samples transferred per second */
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
add mod_opus

<span style="color: #000080; font-weight: bold">diff --git a/build/modules.conf.in b/build/modules.conf.in</span>
<span style="color: #000080; font-weight: bold">index 84a9e9a..8d3dfaa 100644</span>
<span style="color: #A00000">--- a/build/modules.conf.in</span>
<span style="color: #00A000">+++ b/build/modules.conf.in</span>
<span style="color: #800080; font-weight: bold">@@ -48,6 +48,7 @@ codecs/mod_ilbc</span>
 codecs/mod_speex
 codecs/mod_siren
 #codecs/mod_celt
<span style="color: #00A000">+#codecs/mod_opus</span>
 #codecs/mod_sangoma_codec
 #codecs/mod_dahdi_codec
 #dialplans/mod_dialplan_directory
<span style="color: #000080; font-weight: bold">diff --git a/conf/autoload_configs/modules.conf.xml b/conf/autoload_configs/modules.conf.xml</span>
<span style="color: #000080; font-weight: bold">index 2e7ebfa..8b4a4e7 100644</span>
<span style="color: #A00000">--- a/conf/autoload_configs/modules.conf.xml</span>
<span style="color: #00A000">+++ b/conf/autoload_configs/modules.conf.xml</span>
<span style="color: #800080; font-weight: bold">@@ -78,6 +78,7 @@</span>
     &lt;load module=&quot;mod_h26x&quot;/&gt;
     &lt;load module=&quot;mod_siren&quot;/&gt;
     &lt;!--&lt;load module=&quot;mod_celt&quot;/&gt;--&gt;
<span style="color: #00A000">+    &lt;!--&lt;load module=&quot;mod_opus&quot;/&gt;--&gt;</span>
 
     &lt;!-- File Format Interfaces --&gt;
     &lt;load module=&quot;mod_sndfile&quot;/&gt;
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/codecs/mod_opus/Makefile b/src/mod/codecs/mod_opus/Makefile</span>
new file mode 100644
<span style="color: #000080; font-weight: bold">index 0000000..a346956</span>
<span style="color: #A00000">--- /dev/null</span>
<span style="color: #00A000">+++ b/src/mod/codecs/mod_opus/Makefile</span>
<span style="color: #800080; font-weight: bold">@@ -0,0 +1,28 @@</span>
<span style="color: #00A000">+BASE=../../../..</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+OPUS=opus-0.9.0</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+OPUS_DIR=$(switch_srcdir)/libs/$(OPUS)</span>
<span style="color: #00A000">+OPUS_BUILDDIR=$(switch_builddir)/libs/$(OPUS)</span>
<span style="color: #00A000">+LOCAL_CFLAGS=-I$(OPUS_DIR)/src -g -O2</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+IETF_LA=$(OPUS_BUILDDIR)/src/.libs/libietfcodec.a</span>
<span style="color: #00A000">+CELT_LA=$(OPUS_BUILDDIR)/celt/libcelt/.libs/libcelt0.a</span>
<span style="color: #00A000">+SILK_LA=$(OPUS_BUILDDIR)/silk/.libs/libSKP_SILK_SDK.a</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+LOCAL_LIBADD=$(IETF_LA) $(CELT_LA) $(SILK_LA) -lm -lz</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+include $(BASE)/build/modmake.rules</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+$(OPUS_DIR):</span>
<span style="color: #00A000">+        $(GETLIB) $(OPUS).tar.gz</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+$(OPUS_BUILDDIR)/Makefile: $(OPUS_DIR)</span>
<span style="color: #00A000">+        mkdir -p $(OPUS_BUILDDIR)</span>
<span style="color: #00A000">+        cd $(OPUS_BUILDDIR) &amp;&amp; $(DEFAULT_VARS) $(OPUS_DIR)/configure --disable-shared --with-pic --srcdir=$(OPUS_DIR)</span>
<span style="color: #00A000">+        $(TOUCH_TARGET)</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+$(IETF_LA): $(OPUS_BUILDDIR)/Makefile</span>
<span style="color: #00A000">+        cd $(OPUS_BUILDDIR) &amp;&amp; $(MAKE)</span>
<span style="color: #00A000">+        $(TOUCH_TARGET)</span>
<span style="color: #00A000">+</span>
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/codecs/mod_opus/mod_opus.c b/src/mod/codecs/mod_opus/mod_opus.c</span>
new file mode 100644
<span style="color: #000080; font-weight: bold">index 0000000..341254f</span>
<span style="color: #A00000">--- /dev/null</span>
<span style="color: #00A000">+++ b/src/mod/codecs/mod_opus/mod_opus.c</span>
<span style="color: #800080; font-weight: bold">@@ -0,0 +1,209 @@</span>
<span style="color: #00A000">+/* </span>
<span style="color: #00A000">+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application</span>
<span style="color: #00A000">+ * Copyright (C) 2005-2011, Anthony Minessale II &lt;anthm@freeswitch.org&gt;</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ * Version: MPL 1.1</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ * The contents of this file are subject to the Mozilla Public License Version</span>
<span style="color: #00A000">+ * 1.1 (the &quot;License&quot;); you may not use this file except in compliance with</span>
<span style="color: #00A000">+ * the License. You may obtain a copy of the License at</span>
<span style="color: #00A000">+ * http://www.mozilla.org/MPL/</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ * Software distributed under the License is distributed on an &quot;AS IS&quot; basis,</span>
<span style="color: #00A000">+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License</span>
<span style="color: #00A000">+ * for the specific language governing rights and limitations under the</span>
<span style="color: #00A000">+ * License.</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ * The Initial Developer of the Original Code is</span>
<span style="color: #00A000">+ * Anthony Minessale II &lt;anthm@freeswitch.org&gt;</span>
<span style="color: #00A000">+ * Portions created by the Initial Developer are Copyright (C)</span>
<span style="color: #00A000">+ * the Initial Developer. All Rights Reserved.</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ * Contributor(s):</span>
<span style="color: #00A000">+ * </span>
<span style="color: #00A000">+ * Brian K. West &lt;brian@freeswitch.org&gt;</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ * mod_opus.c -- The OPUS ultra-low delay audio codec (http://www.opus-codec.org/)</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+#include &quot;switch.h&quot;</span>
<span style="color: #00A000">+#include &quot;opus.h&quot;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load);</span>
<span style="color: #00A000">+SWITCH_MODULE_DEFINITION(mod_opus, mod_opus_load, NULL, NULL);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+struct opus_context {</span>
<span style="color: #00A000">+        OpusEncoder *encoder_object;</span>
<span style="color: #00A000">+        OpusDecoder *decoder_object;</span>
<span style="color: #00A000">+        int frame_size;</span>
<span style="color: #00A000">+};</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        struct opus_context *context = NULL;</span>
<span style="color: #00A000">+        int encoding = (flags &amp; SWITCH_CODEC_FLAG_ENCODE);</span>
<span style="color: #00A000">+        int decoding = (flags &amp; SWITCH_CODEC_FLAG_DECODE);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (!(encoding || decoding) || (!(context = switch_core_alloc(codec-&gt;memory_pool, sizeof(*context))))) {</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        context-&gt;frame_size = codec-&gt;implementation-&gt;samples_per_packet;</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        if (encoding) {</span>
<span style="color: #00A000">+                /* come up with a way to specify these */</span>
<span style="color: #00A000">+                int bitrate_bps = codec-&gt;implementation-&gt;bits_per_second;</span>
<span style="color: #00A000">+                int mode = MODE_HYBRID;</span>
<span style="color: #00A000">+                int use_vbr = 1;</span>
<span style="color: #00A000">+                int complexity = 10;</span>
<span style="color: #00A000">+                int use_inbandfec = 1;</span>
<span style="color: #00A000">+                int use_dtx = 1;</span>
<span style="color: #00A000">+                int bandwidth = BANDWIDTH_FULLBAND;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                context-&gt;encoder_object = opus_encoder_create(codec-&gt;implementation-&gt;actual_samples_per_second, codec-&gt;implementation-&gt;number_of_channels);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                opus_encoder_ctl(context-&gt;encoder_object, OPUS_SET_MODE(mode));</span>
<span style="color: #00A000">+                opus_encoder_ctl(context-&gt;encoder_object, OPUS_SET_BITRATE(bitrate_bps));</span>
<span style="color: #00A000">+                opus_encoder_ctl(context-&gt;encoder_object, OPUS_SET_BANDWIDTH(bandwidth));</span>
<span style="color: #00A000">+                opus_encoder_ctl(context-&gt;encoder_object, OPUS_SET_VBR_FLAG(use_vbr));</span>
<span style="color: #00A000">+                opus_encoder_ctl(context-&gt;encoder_object, OPUS_SET_COMPLEXITY(complexity));</span>
<span style="color: #00A000">+                opus_encoder_ctl(context-&gt;encoder_object, OPUS_SET_INBAND_FEC_FLAG(use_inbandfec));</span>
<span style="color: #00A000">+                opus_encoder_ctl(context-&gt;encoder_object, OPUS_SET_DTX_FLAG(use_dtx));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        if (decoding) {</span>
<span style="color: #00A000">+                context-&gt;decoder_object = opus_decoder_create(codec-&gt;implementation-&gt;actual_samples_per_second, codec-&gt;implementation-&gt;number_of_channels);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        codec-&gt;private_info = context;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t switch_opus_destroy(switch_codec_t *codec)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        codec-&gt;private_info = NULL;</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t switch_opus_encode(switch_codec_t *codec,</span>
<span style="color: #00A000">+                                                                                  switch_codec_t *other_codec,</span>
<span style="color: #00A000">+                                                                                  void *decoded_data,</span>
<span style="color: #00A000">+                                                                                  uint32_t decoded_data_len,</span>
<span style="color: #00A000">+                                                                                  uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,</span>
<span style="color: #00A000">+                                                                                  unsigned int *flag)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        struct opus_context *context = codec-&gt;private_info;</span>
<span style="color: #00A000">+        int bytes = 0;</span>
<span style="color: #00A000">+        int len = (int) *encoded_data_len;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (!context) {</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (len &gt; 1275) len = 1275;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        bytes = opus_encode(context-&gt;encoder_object, (void *) decoded_data, decoded_data_len / 2, (unsigned char *) encoded_data, len);</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        if (bytes &gt; 0) {</span>
<span style="color: #00A000">+                *encoded_data_len = (uint32_t) bytes;</span>
<span style="color: #00A000">+                return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Encoder Error!\n&quot;);</span>
<span style="color: #00A000">+        return SWITCH_STATUS_GENERR;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t switch_opus_decode(switch_codec_t *codec,</span>
<span style="color: #00A000">+                                                                                  switch_codec_t *other_codec,</span>
<span style="color: #00A000">+                                                                                  void *encoded_data,</span>
<span style="color: #00A000">+                                                                                  uint32_t encoded_data_len,</span>
<span style="color: #00A000">+                                                                                  uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,</span>
<span style="color: #00A000">+                                                                                  unsigned int *flag)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        struct opus_context *context = codec-&gt;private_info;</span>
<span style="color: #00A000">+        int samples = 0;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (!context) {</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        samples = opus_decode(context-&gt;decoder_object, encoded_data, encoded_data_len, decoded_data, *decoded_data_len);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (samples &lt; 0) {</span>
<span style="color: #00A000">+                return SWITCH_STATUS_GENERR;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        *decoded_data_len = samples * 2;</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        switch_codec_interface_t *codec_interface;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* connect my internal structure to the blank pointer passed to me */</span>
<span style="color: #00A000">+        *module_interface = switch_loadable_module_create_module_interface(pool, modname);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        SWITCH_ADD_CODEC(codec_interface, &quot;OPUS (BETA)&quot;);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */</span>
<span style="color: #00A000">+                                                                                 115,        /* the IANA code number */</span>
<span style="color: #00A000">+                                                                                 &quot;OPUS&quot;,        /* the IANA code name */</span>
<span style="color: #00A000">+                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function) */</span>
<span style="color: #00A000">+                                                                                 48000,        /* samples transferred per second */</span>
<span style="color: #00A000">+                                                                                 48000,        /* actual samples transferred per second */</span>
<span style="color: #00A000">+                                                                                 32000,        /* bits transferred per second */</span>
<span style="color: #00A000">+                                                                                 10000,        /* number of microseconds per frame */</span>
<span style="color: #00A000">+                                                                                 80,        /* number of samples per frame */</span>
<span style="color: #00A000">+                                                                                 960,        /* number of bytes per frame decompressed */</span>
<span style="color: #00A000">+                                                                                 0,        /* number of bytes per frame compressed */</span>
<span style="color: #00A000">+                                                                                 1,        /* number of channels represented */</span>
<span style="color: #00A000">+                                                                                 1,        /* number of frames per network packet */</span>
<span style="color: #00A000">+                                                                                 switch_opus_init,        /* function to initialize a codec handle using this implementation */</span>
<span style="color: #00A000">+                                                                                 switch_opus_encode,        /* function to encode raw data into encoded data */</span>
<span style="color: #00A000">+                                                                                 switch_opus_decode,        /* function to decode encoded data into raw data */</span>
<span style="color: #00A000">+                                                                                 switch_opus_destroy);        /* deinitalize a codec handle using this implementation */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */</span>
<span style="color: #00A000">+                                                                                 115,        /* the IANA code number */</span>
<span style="color: #00A000">+                                                                                 &quot;OPUS&quot;,        /* the IANA code name */</span>
<span style="color: #00A000">+                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function) */</span>
<span style="color: #00A000">+                                                                                 48000,        /* samples transferred per second */</span>
<span style="color: #00A000">+                                                                                 48000,        /* actual samples transferred per second */</span>
<span style="color: #00A000">+                                                                                 32000,        /* bits transferred per second */</span>
<span style="color: #00A000">+                                                                                 20000,        /* number of microseconds per frame */</span>
<span style="color: #00A000">+                                                                                 160,        /* number of samples per frame */</span>
<span style="color: #00A000">+                                                                                 1920,        /* number of bytes per frame decompressed */</span>
<span style="color: #00A000">+                                                                                 0,        /* number of bytes per frame compressed */</span>
<span style="color: #00A000">+                                                                                 1,        /* number of channels represented */</span>
<span style="color: #00A000">+                                                                                 1,        /* number of frames per network packet */</span>
<span style="color: #00A000">+                                                                                 switch_opus_init,        /* function to initialize a codec handle using this implementation */</span>
<span style="color: #00A000">+                                                                                 switch_opus_encode,        /* function to encode raw data into encoded data */</span>
<span style="color: #00A000">+                                                                                 switch_opus_decode,        /* function to decode encoded data into raw data */</span>
<span style="color: #00A000">+                                                                                 switch_opus_destroy);        /* deinitalize a codec handle using this implementation */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* indicate that the module should continue to be loaded */</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/* For Emacs:</span>
<span style="color: #00A000">+ * Local Variables:</span>
<span style="color: #00A000">+ * mode:c</span>
<span style="color: #00A000">+ * indent-tabs-mode:t</span>
<span style="color: #00A000">+ * tab-width:4</span>
<span style="color: #00A000">+ * c-basic-offset:4</span>
<span style="color: #00A000">+ * End:</span>
<span style="color: #00A000">+ * For VIM:</span>
<span style="color: #00A000">+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4:</span>
<span style="color: #00A000">+ */</span>
</pre></div>
<div class="highlight"><pre>committer: Christopher Rienzo
comments: 
forgot this spot when closing speech channel

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c</span>
<span style="color: #000080; font-weight: bold">index 812744c..734ef21 100644</span>
<span style="color: #A00000">--- a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c</span>
<span style="color: #00A000">+++ b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c</span>
<span style="color: #800080; font-weight: bold">@@ -1362,6 +1362,8 @@ static switch_status_t speech_channel_stop(speech_channel_t *schannel)</span>
                         goto done;
                 }
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) %s stopped\n&quot;, schannel-&gt;name, speech_channel_type_to_string(schannel-&gt;type));
<span style="color: #00A000">+        } else if (schannel-&gt;state == SPEECH_CHANNEL_DONE) {</span>
<span style="color: #00A000">+                speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);</span>
         }
 
   done:
</pre></div>
<div class="highlight"><pre>committer: Christopher Rienzo
comments: 
FS-3201 fix truncated TTS

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c</span>
<span style="color: #000080; font-weight: bold">index 5db1491..812744c 100644</span>
<span style="color: #A00000">--- a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c</span>
<span style="color: #00A000">+++ b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c</span>
<span style="color: #800080; font-weight: bold">@@ -260,6 +260,7 @@ static switch_status_t audio_queue_create(audio_queue_t ** queue, const char *na</span>
 static switch_status_t audio_queue_write(audio_queue_t *queue, void *data, switch_size_t *data_len);
 static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch_size_t *data_len, int block);
 static switch_status_t audio_queue_clear(audio_queue_t *queue);
<span style="color: #00A000">+static switch_status_t audio_queue_signal(audio_queue_t *queue);</span>
 static switch_status_t audio_queue_destroy(audio_queue_t *queue);
 
 /*********************************************************************************************************************************************
<span style="color: #800080; font-weight: bold">@@ -287,6 +288,8 @@ enum speech_channel_state {</span>
         SPEECH_CHANNEL_READY,
         /** processing speech request */
         SPEECH_CHANNEL_PROCESSING,
<span style="color: #00A000">+        /** finished processing speech request */</span>
<span style="color: #00A000">+        SPEECH_CHANNEL_DONE,</span>
         /** error opening channel */
         SPEECH_CHANNEL_ERROR
 };
<span style="color: #800080; font-weight: bold">@@ -667,10 +670,12 @@ static switch_status_t audio_queue_create(audio_queue_t ** audio_queue, const ch</span>
 static switch_status_t audio_queue_write(audio_queue_t *queue, void *data, switch_size_t *data_len)
 {
         switch_status_t status = SWITCH_STATUS_SUCCESS;
<span style="color: #00A000">+#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE</span>
<span style="color: #00A000">+        switch_size_t len = *data_len;</span>
<span style="color: #00A000">+#endif</span>
         switch_mutex_lock(queue-&gt;mutex);
 
 #ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
<span style="color: #A00000">-        switch_size_t len = *data_len;</span>
         if (queue-&gt;file_write) {
                 switch_file_write(queue-&gt;file_write, data, &amp;len);
         }
<span style="color: #800080; font-weight: bold">@@ -708,6 +713,9 @@ static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch</span>
 {
         switch_size_t requested = *data_len;
         switch_status_t status = SWITCH_STATUS_SUCCESS;
<span style="color: #00A000">+#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE</span>
<span style="color: #00A000">+        switch_size_t len = *data_len;</span>
<span style="color: #00A000">+#endif</span>
         switch_mutex_lock(queue-&gt;mutex);
 
         /* wait for data, if allowed */
<span style="color: #800080; font-weight: bold">@@ -736,7 +744,6 @@ static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch</span>
 #ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) audio queue read total = %ld\tread = %ld\trequested = %ld\n&quot;, queue-&gt;name,
                                           queue-&gt;read_bytes, *data_len, requested);
<span style="color: #A00000">-        switch_size_t len = *data_len;</span>
         if (queue-&gt;file_read) {
                 switch_file_write(queue-&gt;file_read, data, &amp;len);
         }
<span style="color: #800080; font-weight: bold">@@ -764,6 +771,20 @@ static switch_status_t audio_queue_clear(audio_queue_t *queue)</span>
 }
 
 /**
<span style="color: #00A000">+ * Wake any threads waiting on this queue</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ * @param queue the queue to empty</span>
<span style="color: #00A000">+ * @return SWITCH_STATUS_SUCCESS</span>
<span style="color: #00A000">+ */</span>
<span style="color: #00A000">+static switch_status_t audio_queue_signal(audio_queue_t *queue)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        switch_mutex_lock(queue-&gt;mutex);</span>
<span style="color: #00A000">+        switch_thread_cond_signal(queue-&gt;cond);</span>
<span style="color: #00A000">+        switch_mutex_unlock(queue-&gt;mutex);</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/**</span>
  * Destroy the audio queue
  *
  * @param queue the queue to clean up
<span style="color: #800080; font-weight: bold">@@ -1438,9 +1459,19 @@ static switch_status_t speech_channel_read(speech_channel_t *schannel, void *dat</span>
         }
 
         switch_mutex_lock(schannel-&gt;mutex);
<span style="color: #A00000">-        if (schannel-&gt;state == SPEECH_CHANNEL_PROCESSING) {</span>
<span style="color: #00A000">+        switch (schannel-&gt;state) {</span>
<span style="color: #00A000">+        case SPEECH_CHANNEL_DONE:</span>
<span style="color: #00A000">+                /* pull any remaining audio - never blocking */</span>
<span style="color: #00A000">+                if (audio_queue_read(schannel-&gt;audio_queue, data, len, 0) == SWITCH_STATUS_FALSE) {</span>
<span style="color: #00A000">+                        /* all frames read */</span>
<span style="color: #00A000">+                        status = SWITCH_STATUS_BREAK;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                break;</span>
<span style="color: #00A000">+        case SPEECH_CHANNEL_PROCESSING:</span>
<span style="color: #00A000">+                /* IN-PROGRESS */</span>
                 audio_queue_read(schannel-&gt;audio_queue, data, len, block);
<span style="color: #A00000">-        } else {</span>
<span style="color: #00A000">+                break;</span>
<span style="color: #00A000">+        default:</span>
                 status = SWITCH_STATUS_BREAK;
         }
         switch_mutex_unlock(schannel-&gt;mutex);
<span style="color: #800080; font-weight: bold">@@ -1463,6 +1494,8 @@ static const char *speech_channel_state_to_string(speech_channel_state_t state)</span>
                 return &quot;READY&quot;;
         case SPEECH_CHANNEL_PROCESSING:
                 return &quot;PROCESSING&quot;;
<span style="color: #00A000">+        case SPEECH_CHANNEL_DONE:</span>
<span style="color: #00A000">+                return &quot;DONE&quot;;</span>
         case SPEECH_CHANNEL_ERROR:
                 return &quot;ERROR&quot;;
         }
<span style="color: #800080; font-weight: bold">@@ -1498,7 +1531,7 @@ static switch_status_t speech_channel_set_state_unlocked(speech_channel_t *schan</span>
 {
         if (schannel-&gt;state == SPEECH_CHANNEL_PROCESSING &amp;&amp; state != SPEECH_CHANNEL_PROCESSING) {
                 /* wake anyone waiting for audio data */
<span style="color: #A00000">-                audio_queue_clear(schannel-&gt;audio_queue);</span>
<span style="color: #00A000">+                audio_queue_signal(schannel-&gt;audio_queue);</span>
         }
 
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) %s ==&gt; %s\n&quot;, schannel-&gt;name, speech_channel_state_to_string(schannel-&gt;state),
<span style="color: #800080; font-weight: bold">@@ -1651,6 +1684,8 @@ static switch_status_t synth_speech_read_tts(switch_speech_handle_t *sh, void *d</span>
                         memset((uint8_t *) data + bytes_read, schannel-&gt;silence, *datalen - bytes_read);
                 }
         } else {
<span style="color: #00A000">+                /* ready for next speak request */</span>
<span style="color: #00A000">+                speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);</span>
                 *datalen = 0;
                 status = SWITCH_STATUS_BREAK;
         }
<span style="color: #800080; font-weight: bold">@@ -1878,7 +1913,7 @@ static apt_bool_t synth_on_message_receive(mrcp_application_t *application, mrcp</span>
                         if (message-&gt;start_line.request_state == MRCP_REQUEST_STATE_COMPLETE) {
                                 /* got COMPLETE */
                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) COMPLETE\n&quot;, schannel-&gt;name);
<span style="color: #A00000">-                                speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);</span>
<span style="color: #00A000">+                                speech_channel_set_state(schannel, SPEECH_CHANNEL_DONE);</span>
                         } else {
                                 /* received unexpected request state */
                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) unexpected STOP response, request_state = %d\n&quot;, schannel-&gt;name,
<span style="color: #800080; font-weight: bold">@@ -1896,7 +1931,7 @@ static apt_bool_t synth_on_message_receive(mrcp_application_t *application, mrcp</span>
                 if (message-&gt;start_line.method_id == SYNTHESIZER_SPEAK_COMPLETE) {
                         /* got SPEAK-COMPLETE */
                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) SPEAK-COMPLETE\n&quot;, schannel-&gt;name);
<span style="color: #A00000">-                        speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);</span>
<span style="color: #00A000">+                        speech_channel_set_state(schannel, SPEECH_CHANNEL_DONE);</span>
                 } else {
                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) unexpected event, method_id = %d\n&quot;, schannel-&gt;name,
                                                           (int) message-&gt;start_line.method_id);
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
add default to conf to demonstrate min-idle-cpu

<span style="color: #000080; font-weight: bold">diff --git a/conf/autoload_configs/switch.conf.xml b/conf/autoload_configs/switch.conf.xml</span>
<span style="color: #000080; font-weight: bold">index 8342f12..32cb76f 100644</span>
<span style="color: #A00000">--- a/conf/autoload_configs/switch.conf.xml</span>
<span style="color: #00A000">+++ b/conf/autoload_configs/switch.conf.xml</span>
<span style="color: #800080; font-weight: bold">@@ -23,6 +23,10 @@</span>
   &lt;settings&gt;
     &lt;!--Colorize the Console --&gt;
     &lt;param name=&quot;colorize-console&quot; value=&quot;true&quot;/&gt;
<span style="color: #00A000">+</span>
<span style="color: #00A000">+    &lt;!-- minimum idle CPU before refusing calls --&gt;</span>
<span style="color: #00A000">+    &lt;param name=&quot;min-idle-cpu&quot; value=&quot;25&quot;/&gt;</span>
<span style="color: #00A000">+</span>
     &lt;!--
         Max number of sessions to allow at any given time.
         
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
fix sql err

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c</span>
<span style="color: #000080; font-weight: bold">index a38a61e..2313cb7 100644</span>
<span style="color: #A00000">--- a/src/mod/endpoints/mod_sofia/sofia_presence.c</span>
<span style="color: #00A000">+++ b/src/mod/endpoints/mod_sofia/sofia_presence.c</span>
<span style="color: #800080; font-weight: bold">@@ -2576,7 +2576,7 @@ uint32_t sofia_presence_contact_count(sofia_profile_t *profile, const char *cont</span>
         char buf[32] = &quot;&quot;;
         char *sql;
         
<span style="color: #A00000">-        sql = switch_mprintf(&quot;select count(*) from sip_subscriptions where profile_name=&#39;%q&#39; and contact_str=&#39;%q&#39;&quot;, profile-&gt;name, contact_str);</span>
<span style="color: #00A000">+        sql = switch_mprintf(&quot;select count(*) from sip_subscriptions where profile_name=&#39;%q&#39; and contact=&#39;%q&#39;&quot;, profile-&gt;name, contact_str);</span>
         
         sofia_glue_execute_sql2str(profile, profile-&gt;ireg_mutex, sql, buf, sizeof(buf));
         switch_safe_free(sql);
</pre></div>
<div class="highlight"><pre>committer: Jeff Lenk
comments: 
FS-3033 VS2010 libportaudio project improvements for DirectX builds and switch to build DirectX by default

<span style="color: #000080; font-weight: bold">diff --git a/Freeswitch.2010.sln b/Freeswitch.2010.sln</span>
<span style="color: #000080; font-weight: bold">index edee701..464cb2e 100644</span>
<span style="color: #A00000">--- a/Freeswitch.2010.sln</span>
<span style="color: #00A000">+++ b/Freeswitch.2010.sln</span>
<span style="color: #800080; font-weight: bold">@@ -1569,18 +1569,18 @@ Global</span>
                 {0A18A071-125E-442F-AFF7-A3F68ABECF99}.All|x64 Setup.ActiveCfg = Release DirectSound|x64
                 {0A18A071-125E-442F-AFF7-A3F68ABECF99}.All|x64 Setup.Build.0 = Release DirectSound|x64
                 {0A18A071-125E-442F-AFF7-A3F68ABECF99}.All|x86 Setup.ActiveCfg = Release DirectSound|x64
<span style="color: #A00000">-                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.ActiveCfg = Debug|Win32</span>
<span style="color: #A00000">-                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.Build.0 = Debug|Win32</span>
<span style="color: #A00000">-                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64.ActiveCfg = Debug|x64</span>
<span style="color: #A00000">-                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64.Build.0 = Debug|x64</span>
<span style="color: #A00000">-                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64 Setup.ActiveCfg = Debug|x64</span>
<span style="color: #A00000">-                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x86 Setup.ActiveCfg = Debug|Win32</span>
<span style="color: #A00000">-                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.ActiveCfg = Release|Win32</span>
<span style="color: #A00000">-                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.Build.0 = Release|Win32</span>
<span style="color: #A00000">-                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64.ActiveCfg = Release|x64</span>
<span style="color: #A00000">-                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64.Build.0 = Release|x64</span>
<span style="color: #A00000">-                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64 Setup.ActiveCfg = Release|x64</span>
<span style="color: #A00000">-                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x86 Setup.ActiveCfg = Release|Win32</span>
<span style="color: #00A000">+                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.ActiveCfg = Debug DirectSound|Win32</span>
<span style="color: #00A000">+                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.Build.0 = Debug DirectSound|Win32</span>
<span style="color: #00A000">+                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64.ActiveCfg = Debug DirectSound|x64</span>
<span style="color: #00A000">+                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64.Build.0 = Debug DirectSound|x64</span>
<span style="color: #00A000">+                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64 Setup.ActiveCfg = Debug DirectSound|x64</span>
<span style="color: #00A000">+                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x86 Setup.ActiveCfg = Debug DirectSound|Win32</span>
<span style="color: #00A000">+                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.ActiveCfg = Release DirectSound|Win32</span>
<span style="color: #00A000">+                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.Build.0 = Release DirectSound|Win32</span>
<span style="color: #00A000">+                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64.ActiveCfg = Release DirectSound|x64</span>
<span style="color: #00A000">+                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64.Build.0 = Release DirectSound|x64</span>
<span style="color: #00A000">+                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64 Setup.ActiveCfg = Release DirectSound|x64</span>
<span style="color: #00A000">+                {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x86 Setup.ActiveCfg = Release DirectSound|Win32</span>
                 {08DAD348-9E0A-4A2E-97F1-F1E7E24A7836}.All|Win32.ActiveCfg = Release|x64
                 {08DAD348-9E0A-4A2E-97F1-F1E7E24A7836}.All|x64.ActiveCfg = Release|x64
                 {08DAD348-9E0A-4A2E-97F1-F1E7E24A7836}.All|x64.Build.0 = Release|x64
<span style="color: #000080; font-weight: bold">diff --git a/libs/portaudio/build/msvc/portaudio.2010.vcxproj b/libs/portaudio/build/msvc/portaudio.2010.vcxproj</span>
<span style="color: #000080; font-weight: bold">index b4eca56..10b4c25 100644</span>
<span style="color: #A00000">--- a/libs/portaudio/build/msvc/portaudio.2010.vcxproj</span>
<span style="color: #00A000">+++ b/libs/portaudio/build/msvc/portaudio.2010.vcxproj</span>
<span style="color: #800080; font-weight: bold">@@ -41,11 +41,11 @@</span>
   &lt;/PropertyGroup&gt;
   &lt;Import Project=&quot;$(VCTargetsPath)\Microsoft.Cpp.Default.props&quot; /&gt;
   &lt;PropertyGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot; Label=&quot;Configuration&quot;&gt;
<span style="color: #A00000">-    &lt;ConfigurationType&gt;DynamicLibrary&lt;/ConfigurationType&gt;</span>
<span style="color: #00A000">+    &lt;ConfigurationType&gt;StaticLibrary&lt;/ConfigurationType&gt;</span>
     &lt;UseOfMfc&gt;false&lt;/UseOfMfc&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot; Label=&quot;Configuration&quot;&gt;
<span style="color: #A00000">-    &lt;ConfigurationType&gt;DynamicLibrary&lt;/ConfigurationType&gt;</span>
<span style="color: #00A000">+    &lt;ConfigurationType&gt;StaticLibrary&lt;/ConfigurationType&gt;</span>
     &lt;UseOfMfc&gt;false&lt;/UseOfMfc&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug|Win32&#39;&quot; Label=&quot;Configuration&quot;&gt;
<span style="color: #800080; font-weight: bold">@@ -57,11 +57,11 @@</span>
     &lt;UseOfMfc&gt;false&lt;/UseOfMfc&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot; Label=&quot;Configuration&quot;&gt;
<span style="color: #A00000">-    &lt;ConfigurationType&gt;DynamicLibrary&lt;/ConfigurationType&gt;</span>
<span style="color: #00A000">+    &lt;ConfigurationType&gt;StaticLibrary&lt;/ConfigurationType&gt;</span>
     &lt;UseOfMfc&gt;false&lt;/UseOfMfc&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot; Label=&quot;Configuration&quot;&gt;
<span style="color: #A00000">-    &lt;ConfigurationType&gt;DynamicLibrary&lt;/ConfigurationType&gt;</span>
<span style="color: #00A000">+    &lt;ConfigurationType&gt;StaticLibrary&lt;/ConfigurationType&gt;</span>
     &lt;UseOfMfc&gt;false&lt;/UseOfMfc&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug|x64&#39;&quot; Label=&quot;Configuration&quot;&gt;
<span style="color: #800080; font-weight: bold">@@ -77,9 +77,11 @@</span>
   &lt;/ImportGroup&gt;
   &lt;ImportGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot; Label=&quot;PropertySheets&quot;&gt;
     &lt;Import Project=&quot;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&quot; Condition=&quot;exists(&#39;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&#39;)&quot; Label=&quot;LocalAppDataPlatform&quot; /&gt;
<span style="color: #00A000">+    &lt;Import Project=&quot;..\..\..\..\w32\extlib.props&quot; /&gt;</span>
   &lt;/ImportGroup&gt;
   &lt;ImportGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot; Label=&quot;PropertySheets&quot;&gt;
     &lt;Import Project=&quot;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&quot; Condition=&quot;exists(&#39;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&#39;)&quot; Label=&quot;LocalAppDataPlatform&quot; /&gt;
<span style="color: #00A000">+    &lt;Import Project=&quot;..\..\..\..\w32\extlib.props&quot; /&gt;</span>
   &lt;/ImportGroup&gt;
   &lt;ImportGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug|Win32&#39;&quot; Label=&quot;PropertySheets&quot;&gt;
     &lt;Import Project=&quot;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&quot; Condition=&quot;exists(&#39;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&#39;)&quot; Label=&quot;LocalAppDataPlatform&quot; /&gt;
<span style="color: #800080; font-weight: bold">@@ -92,10 +94,12 @@</span>
   &lt;ImportGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot; Label=&quot;PropertySheets&quot;&gt;
     &lt;Import Project=&quot;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&quot; Condition=&quot;exists(&#39;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&#39;)&quot; Label=&quot;LocalAppDataPlatform&quot; /&gt;
     &lt;Import Project=&quot;$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props&quot; /&gt;
<span style="color: #00A000">+    &lt;Import Project=&quot;..\..\..\..\w32\extlib.props&quot; /&gt;</span>
   &lt;/ImportGroup&gt;
   &lt;ImportGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot; Label=&quot;PropertySheets&quot;&gt;
     &lt;Import Project=&quot;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&quot; Condition=&quot;exists(&#39;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&#39;)&quot; Label=&quot;LocalAppDataPlatform&quot; /&gt;
     &lt;Import Project=&quot;$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props&quot; /&gt;
<span style="color: #00A000">+    &lt;Import Project=&quot;..\..\..\..\w32\extlib.props&quot; /&gt;</span>
   &lt;/ImportGroup&gt;
   &lt;ImportGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug|x64&#39;&quot; Label=&quot;PropertySheets&quot;&gt;
     &lt;Import Project=&quot;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&quot; Condition=&quot;exists(&#39;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&#39;)&quot; Label=&quot;LocalAppDataPlatform&quot; /&gt;
<span style="color: #800080; font-weight: bold">@@ -110,18 +114,6 @@</span>
   &lt;PropertyGroup Label=&quot;UserMacros&quot; /&gt;
   &lt;PropertyGroup&gt;
     &lt;_ProjectFileVersion&gt;10.0.30319.1&lt;/_ProjectFileVersion&gt;
<span style="color: #A00000">-    &lt;OutDir Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;$(Configuration)\&lt;/OutDir&gt;</span>
<span style="color: #A00000">-    &lt;IntDir Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;$(Configuration)\&lt;/IntDir&gt;</span>
<span style="color: #A00000">-    &lt;LinkIncremental Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;true&lt;/LinkIncremental&gt;</span>
<span style="color: #A00000">-    &lt;OutDir Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;$(Platform)\$(Configuration)\&lt;/OutDir&gt;</span>
<span style="color: #A00000">-    &lt;IntDir Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;$(Platform)\$(Configuration)\&lt;/IntDir&gt;</span>
<span style="color: #A00000">-    &lt;LinkIncremental Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;true&lt;/LinkIncremental&gt;</span>
<span style="color: #A00000">-    &lt;OutDir Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;$(Configuration)\&lt;/OutDir&gt;</span>
<span style="color: #A00000">-    &lt;IntDir Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;$(Configuration)\&lt;/IntDir&gt;</span>
<span style="color: #A00000">-    &lt;LinkIncremental Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;false&lt;/LinkIncremental&gt;</span>
<span style="color: #A00000">-    &lt;OutDir Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;$(Platform)\$(Configuration)\&lt;/OutDir&gt;</span>
<span style="color: #A00000">-    &lt;IntDir Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;$(Platform)\$(Configuration)\&lt;/IntDir&gt;</span>
<span style="color: #A00000">-    &lt;LinkIncremental Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;false&lt;/LinkIncremental&gt;</span>
   &lt;/PropertyGroup&gt;
   &lt;ItemDefinitionGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release|Win32&#39;&quot;&gt;
     &lt;Midl&gt;
<span style="color: #800080; font-weight: bold">@@ -231,45 +223,23 @@</span>
       &lt;MkTypLibCompatible&gt;true&lt;/MkTypLibCompatible&gt;
       &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;
       &lt;TargetEnvironment&gt;Win32&lt;/TargetEnvironment&gt;
<span style="color: #A00000">-      &lt;TypeLibraryName&gt;.\Debug_x86/portaudio.tlb&lt;/TypeLibraryName&gt;</span>
<span style="color: #A00000">-      &lt;HeaderFileName&gt;</span>
<span style="color: #A00000">-      &lt;/HeaderFileName&gt;</span>
     &lt;/Midl&gt;
     &lt;ClCompile&gt;
       &lt;Optimization&gt;Disabled&lt;/Optimization&gt;
       &lt;AdditionalIncludeDirectories&gt;..\..\src\common;..\..\include;.\;..\..\src\os\win;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
<span style="color: #A00000">-      &lt;PreprocessorDefinitions&gt;WIN32;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PAWIN_USE_WDMKS_DEVICE_INFO;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;</span>
<span style="color: #00A000">+      &lt;PreprocessorDefinitions&gt;WIN32;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PA_NO_WMME;PAWIN_USE_WDMKS_DEVICE_INFO;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;</span>
       &lt;MinimalRebuild&gt;true&lt;/MinimalRebuild&gt;
       &lt;BasicRuntimeChecks&gt;EnableFastChecks&lt;/BasicRuntimeChecks&gt;
       &lt;RuntimeLibrary&gt;MultiThreadedDebugDLL&lt;/RuntimeLibrary&gt;
<span style="color: #A00000">-      &lt;PrecompiledHeaderOutputFile&gt;$(Platform)\$(Configuration)/portaudio.pch&lt;/PrecompiledHeaderOutputFile&gt;</span>
<span style="color: #A00000">-      &lt;AssemblerListingLocation&gt;$(Platform)\$(Configuration)\&lt;/AssemblerListingLocation&gt;</span>
<span style="color: #A00000">-      &lt;ObjectFileName&gt;$(Platform)\$(Configuration)\&lt;/ObjectFileName&gt;</span>
<span style="color: #A00000">-      &lt;ProgramDataBaseFileName&gt;$(Platform)\$(Configuration)\&lt;/ProgramDataBaseFileName&gt;</span>
       &lt;WarningLevel&gt;Level3&lt;/WarningLevel&gt;
       &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;
<span style="color: #A00000">-      &lt;DebugInformationFormat&gt;ProgramDatabase&lt;/DebugInformationFormat&gt;</span>
     &lt;/ClCompile&gt;
     &lt;ResourceCompile&gt;
       &lt;PreprocessorDefinitions&gt;_DEBUG;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;Culture&gt;0x0409&lt;/Culture&gt;
     &lt;/ResourceCompile&gt;
<span style="color: #A00000">-    &lt;Link&gt;</span>
<span style="color: #A00000">-      &lt;AdditionalDependencies&gt;ksuser.lib;%(AdditionalDependencies)&lt;/AdditionalDependencies&gt;</span>
<span style="color: #A00000">-      &lt;OutputFile&gt;$(Platform)\$(Configuration)\portaudio_x86.dll&lt;/OutputFile&gt;</span>
<span style="color: #A00000">-      &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;</span>
<span style="color: #A00000">-      &lt;ModuleDefinitionFile&gt;.\portaudio.def&lt;/ModuleDefinitionFile&gt;</span>
<span style="color: #A00000">-      &lt;GenerateDebugInformation&gt;true&lt;/GenerateDebugInformation&gt;</span>
<span style="color: #A00000">-      &lt;ProgramDatabaseFile&gt;$(Platform)\$(Configuration)\portaudio_x86.pdb&lt;/ProgramDatabaseFile&gt;</span>
<span style="color: #A00000">-      &lt;RandomizedBaseAddress&gt;false&lt;/RandomizedBaseAddress&gt;</span>
<span style="color: #A00000">-      &lt;DataExecutionPrevention&gt;</span>
<span style="color: #A00000">-      &lt;/DataExecutionPrevention&gt;</span>
<span style="color: #A00000">-      &lt;ImportLibrary&gt;$(Platform)\$(Configuration)\portaudio_x86.lib&lt;/ImportLibrary&gt;</span>
<span style="color: #A00000">-      &lt;TargetMachine&gt;MachineX86&lt;/TargetMachine&gt;</span>
<span style="color: #A00000">-    &lt;/Link&gt;</span>
     &lt;Bscmake&gt;
       &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;
<span style="color: #A00000">-      &lt;OutputFile&gt;$(Platform)\$(Configuration)\portaudio.bsc&lt;/OutputFile&gt;</span>
     &lt;/Bscmake&gt;
   &lt;/ItemDefinitionGroup&gt;
   &lt;ItemDefinitionGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;
<span style="color: #800080; font-weight: bold">@@ -278,45 +248,23 @@</span>
       &lt;MkTypLibCompatible&gt;true&lt;/MkTypLibCompatible&gt;
       &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;
       &lt;TargetEnvironment&gt;X64&lt;/TargetEnvironment&gt;
<span style="color: #A00000">-      &lt;TypeLibraryName&gt;.\Debug_x86/portaudio.tlb&lt;/TypeLibraryName&gt;</span>
<span style="color: #A00000">-      &lt;HeaderFileName&gt;</span>
<span style="color: #A00000">-      &lt;/HeaderFileName&gt;</span>
     &lt;/Midl&gt;
     &lt;ClCompile&gt;
       &lt;Optimization&gt;Disabled&lt;/Optimization&gt;
       &lt;AdditionalIncludeDirectories&gt;..\..\src\common;..\..\include;.\;..\..\src\os\win;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
<span style="color: #A00000">-      &lt;PreprocessorDefinitions&gt;WIN32;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PAWIN_USE_WDMKS_DEVICE_INFO;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;</span>
<span style="color: #00A000">+      &lt;PreprocessorDefinitions&gt;WIN32;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PA_NO_WMME;PAWIN_USE_WDMKS_DEVICE_INFO;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;</span>
       &lt;MinimalRebuild&gt;true&lt;/MinimalRebuild&gt;
       &lt;BasicRuntimeChecks&gt;EnableFastChecks&lt;/BasicRuntimeChecks&gt;
       &lt;RuntimeLibrary&gt;MultiThreadedDebugDLL&lt;/RuntimeLibrary&gt;
<span style="color: #A00000">-      &lt;PrecompiledHeaderOutputFile&gt;$(Platform)\$(Configuration)\portaudio.pch&lt;/PrecompiledHeaderOutputFile&gt;</span>
<span style="color: #A00000">-      &lt;AssemblerListingLocation&gt;$(Platform)\$(Configuration)\&lt;/AssemblerListingLocation&gt;</span>
<span style="color: #A00000">-      &lt;ObjectFileName&gt;$(Platform)\$(Configuration)\&lt;/ObjectFileName&gt;</span>
<span style="color: #A00000">-      &lt;ProgramDataBaseFileName&gt;$(Platform)\$(Configuration)\&lt;/ProgramDataBaseFileName&gt;</span>
       &lt;WarningLevel&gt;Level3&lt;/WarningLevel&gt;
       &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;
<span style="color: #A00000">-      &lt;DebugInformationFormat&gt;ProgramDatabase&lt;/DebugInformationFormat&gt;</span>
     &lt;/ClCompile&gt;
     &lt;ResourceCompile&gt;
       &lt;PreprocessorDefinitions&gt;_DEBUG;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;Culture&gt;0x0409&lt;/Culture&gt;
     &lt;/ResourceCompile&gt;
<span style="color: #A00000">-    &lt;Link&gt;</span>
<span style="color: #A00000">-      &lt;AdditionalDependencies&gt;ksuser.lib;%(AdditionalDependencies)&lt;/AdditionalDependencies&gt;</span>
<span style="color: #A00000">-      &lt;OutputFile&gt;$(Platform)\$(Configuration)\portaudio_x64.dll&lt;/OutputFile&gt;</span>
<span style="color: #A00000">-      &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;</span>
<span style="color: #A00000">-      &lt;ModuleDefinitionFile&gt;.\portaudio.def&lt;/ModuleDefinitionFile&gt;</span>
<span style="color: #A00000">-      &lt;GenerateDebugInformation&gt;true&lt;/GenerateDebugInformation&gt;</span>
<span style="color: #A00000">-      &lt;ProgramDatabaseFile&gt;$(Platform)\$(Configuration)/portaudio_x64.pdb&lt;/ProgramDatabaseFile&gt;</span>
<span style="color: #A00000">-      &lt;RandomizedBaseAddress&gt;false&lt;/RandomizedBaseAddress&gt;</span>
<span style="color: #A00000">-      &lt;DataExecutionPrevention&gt;</span>
<span style="color: #A00000">-      &lt;/DataExecutionPrevention&gt;</span>
<span style="color: #A00000">-      &lt;ImportLibrary&gt;$(Platform)\$(Configuration)\portaudio_x64.lib&lt;/ImportLibrary&gt;</span>
<span style="color: #A00000">-      &lt;TargetMachine&gt;MachineX64&lt;/TargetMachine&gt;</span>
<span style="color: #A00000">-    &lt;/Link&gt;</span>
     &lt;Bscmake&gt;
       &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;
<span style="color: #A00000">-      &lt;OutputFile&gt;$(Platform)\$(Configuration)/portaudio_x64.bsc&lt;/OutputFile&gt;</span>
     &lt;/Bscmake&gt;
   &lt;/ItemDefinitionGroup&gt;
   &lt;ItemDefinitionGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;
<span style="color: #800080; font-weight: bold">@@ -325,22 +273,15 @@</span>
       &lt;MkTypLibCompatible&gt;true&lt;/MkTypLibCompatible&gt;
       &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;
       &lt;TargetEnvironment&gt;Win32&lt;/TargetEnvironment&gt;
<span style="color: #A00000">-      &lt;TypeLibraryName&gt;.\Release_x86/portaudio.tlb&lt;/TypeLibraryName&gt;</span>
<span style="color: #A00000">-      &lt;HeaderFileName&gt;</span>
<span style="color: #A00000">-      &lt;/HeaderFileName&gt;</span>
     &lt;/Midl&gt;
     &lt;ClCompile&gt;
       &lt;Optimization&gt;MaxSpeed&lt;/Optimization&gt;
<span style="color: #A00000">-      &lt;InlineFunctionExpansion&gt;OnlyExplicitInline&lt;/InlineFunctionExpansion&gt;</span>
<span style="color: #00A000">+      &lt;InlineFunctionExpansion&gt;Default&lt;/InlineFunctionExpansion&gt;</span>
       &lt;AdditionalIncludeDirectories&gt;..\..\src\common;..\..\include;.\;..\..\src\os\win;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
<span style="color: #A00000">-      &lt;PreprocessorDefinitions&gt;WIN32;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;</span>
<span style="color: #00A000">+      &lt;PreprocessorDefinitions&gt;WIN32;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PA_NO_WMME;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;</span>
       &lt;StringPooling&gt;true&lt;/StringPooling&gt;
       &lt;RuntimeLibrary&gt;MultiThreadedDLL&lt;/RuntimeLibrary&gt;
       &lt;FunctionLevelLinking&gt;true&lt;/FunctionLevelLinking&gt;
<span style="color: #A00000">-      &lt;PrecompiledHeaderOutputFile&gt;$(Platform)\$(Configuration)/portaudio.pch&lt;/PrecompiledHeaderOutputFile&gt;</span>
<span style="color: #A00000">-      &lt;AssemblerListingLocation&gt;$(Platform)\$(Configuration)\&lt;/AssemblerListingLocation&gt;</span>
<span style="color: #A00000">-      &lt;ObjectFileName&gt;$(Platform)\$(Configuration)\&lt;/ObjectFileName&gt;</span>
<span style="color: #A00000">-      &lt;ProgramDataBaseFileName&gt;$(Platform)\$(Configuration)\&lt;/ProgramDataBaseFileName&gt;</span>
       &lt;WarningLevel&gt;Level3&lt;/WarningLevel&gt;
       &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;
     &lt;/ClCompile&gt;
<span style="color: #800080; font-weight: bold">@@ -348,20 +289,8 @@</span>
       &lt;PreprocessorDefinitions&gt;NDEBUG;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;Culture&gt;0x0409&lt;/Culture&gt;
     &lt;/ResourceCompile&gt;
<span style="color: #A00000">-    &lt;Link&gt;</span>
<span style="color: #A00000">-      &lt;OutputFile&gt;$(Platform)\$(Configuration)\portaudio_x86.dll&lt;/OutputFile&gt;</span>
<span style="color: #A00000">-      &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;</span>
<span style="color: #A00000">-      &lt;ModuleDefinitionFile&gt;.\portaudio.def&lt;/ModuleDefinitionFile&gt;</span>
<span style="color: #A00000">-      &lt;ProgramDatabaseFile&gt;$(Platform)\$(Configuration)\portaudio_x86.pdb&lt;/ProgramDatabaseFile&gt;</span>
<span style="color: #A00000">-      &lt;RandomizedBaseAddress&gt;false&lt;/RandomizedBaseAddress&gt;</span>
<span style="color: #A00000">-      &lt;DataExecutionPrevention&gt;</span>
<span style="color: #A00000">-      &lt;/DataExecutionPrevention&gt;</span>
<span style="color: #A00000">-      &lt;ImportLibrary&gt;$(Platform)\$(Configuration)\portaudio_x86.lib&lt;/ImportLibrary&gt;</span>
<span style="color: #A00000">-      &lt;TargetMachine&gt;MachineX86&lt;/TargetMachine&gt;</span>
<span style="color: #A00000">-    &lt;/Link&gt;</span>
     &lt;Bscmake&gt;
       &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;
<span style="color: #A00000">-      &lt;OutputFile&gt;$(Platform)\$(Configuration)\portaudio.bsc&lt;/OutputFile&gt;</span>
     &lt;/Bscmake&gt;
   &lt;/ItemDefinitionGroup&gt;
   &lt;ItemDefinitionGroup Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;
<span style="color: #800080; font-weight: bold">@@ -370,22 +299,15 @@</span>
       &lt;MkTypLibCompatible&gt;true&lt;/MkTypLibCompatible&gt;
       &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;
       &lt;TargetEnvironment&gt;X64&lt;/TargetEnvironment&gt;
<span style="color: #A00000">-      &lt;TypeLibraryName&gt;.\Release_x86/portaudio.tlb&lt;/TypeLibraryName&gt;</span>
<span style="color: #A00000">-      &lt;HeaderFileName&gt;</span>
<span style="color: #A00000">-      &lt;/HeaderFileName&gt;</span>
     &lt;/Midl&gt;
     &lt;ClCompile&gt;
       &lt;Optimization&gt;MaxSpeed&lt;/Optimization&gt;
<span style="color: #A00000">-      &lt;InlineFunctionExpansion&gt;OnlyExplicitInline&lt;/InlineFunctionExpansion&gt;</span>
<span style="color: #A00000">-      &lt;AdditionalIncludeDirectories&gt;..\..\src\common;..\..\include;.\;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;</span>
<span style="color: #A00000">-      &lt;PreprocessorDefinitions&gt;WIN32;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;</span>
<span style="color: #00A000">+      &lt;InlineFunctionExpansion&gt;Default&lt;/InlineFunctionExpansion&gt;</span>
<span style="color: #00A000">+      &lt;AdditionalIncludeDirectories&gt;..\..\src\common;..\..\include;.\;..\..\src\os\win;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;</span>
<span style="color: #00A000">+      &lt;PreprocessorDefinitions&gt;WIN32;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PA_NO_WMME;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;</span>
       &lt;StringPooling&gt;true&lt;/StringPooling&gt;
       &lt;RuntimeLibrary&gt;MultiThreadedDLL&lt;/RuntimeLibrary&gt;
       &lt;FunctionLevelLinking&gt;true&lt;/FunctionLevelLinking&gt;
<span style="color: #A00000">-      &lt;PrecompiledHeaderOutputFile&gt;$(Platform)\$(Configuration)\portaudio.pch&lt;/PrecompiledHeaderOutputFile&gt;</span>
<span style="color: #A00000">-      &lt;AssemblerListingLocation&gt;$(Platform)\$(Configuration)\&lt;/AssemblerListingLocation&gt;</span>
<span style="color: #A00000">-      &lt;ObjectFileName&gt;$(Platform)\$(Configuration)\&lt;/ObjectFileName&gt;</span>
<span style="color: #A00000">-      &lt;ProgramDataBaseFileName&gt;$(Platform)\$(Configuration)\&lt;/ProgramDataBaseFileName&gt;</span>
       &lt;WarningLevel&gt;Level3&lt;/WarningLevel&gt;
       &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;
     &lt;/ClCompile&gt;
<span style="color: #800080; font-weight: bold">@@ -393,20 +315,8 @@</span>
       &lt;PreprocessorDefinitions&gt;NDEBUG;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;Culture&gt;0x0409&lt;/Culture&gt;
     &lt;/ResourceCompile&gt;
<span style="color: #A00000">-    &lt;Link&gt;</span>
<span style="color: #A00000">-      &lt;OutputFile&gt;$(Platform)\$(Configuration)\portaudio_x64.dll&lt;/OutputFile&gt;</span>
<span style="color: #A00000">-      &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;</span>
<span style="color: #A00000">-      &lt;ModuleDefinitionFile&gt;.\portaudio.def&lt;/ModuleDefinitionFile&gt;</span>
<span style="color: #A00000">-      &lt;ProgramDatabaseFile&gt;$(Platform)\$(Configuration)/portaudio_x64.pdb&lt;/ProgramDatabaseFile&gt;</span>
<span style="color: #A00000">-      &lt;RandomizedBaseAddress&gt;false&lt;/RandomizedBaseAddress&gt;</span>
<span style="color: #A00000">-      &lt;DataExecutionPrevention&gt;</span>
<span style="color: #A00000">-      &lt;/DataExecutionPrevention&gt;</span>
<span style="color: #A00000">-      &lt;ImportLibrary&gt;$(Platform)\$(Configuration)/portaudio_x64.lib&lt;/ImportLibrary&gt;</span>
<span style="color: #A00000">-      &lt;TargetMachine&gt;MachineX64&lt;/TargetMachine&gt;</span>
<span style="color: #A00000">-    &lt;/Link&gt;</span>
     &lt;Bscmake&gt;
       &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;
<span style="color: #A00000">-      &lt;OutputFile&gt;$(Platform)\$(Configuration)\portaudio_x64.bsc&lt;/OutputFile&gt;</span>
     &lt;/Bscmake&gt;
   &lt;/ItemDefinitionGroup&gt;
   &lt;ItemGroup&gt;
<span style="color: #800080; font-weight: bold">@@ -594,6 +504,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -605,6 +516,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -618,6 +530,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -629,6 +542,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -642,6 +556,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -653,6 +568,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -666,6 +582,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -677,6 +594,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -690,6 +608,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -701,6 +620,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -714,6 +634,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -725,6 +646,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -738,6 +660,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -749,6 +672,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -762,6 +686,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Debug|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
<span style="color: #800080; font-weight: bold">@@ -773,6 +698,7 @@</span>
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|Win32&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
<span style="color: #00A000">+      &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;</span>
       &lt;AdditionalIncludeDirectories Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
       &lt;PreprocessorDefinitions Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release DirectSound|x64&#39;&quot;&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
       &lt;ExcludedFromBuild Condition=&quot;&#39;$(Configuration)|$(Platform)&#39;==&#39;Release|Win32&#39;&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
add sanity check on jitterbuffer debug

<span style="color: #000080; font-weight: bold">diff --git a/src/switch_rtp.c b/src/switch_rtp.c</span>
<span style="color: #000080; font-weight: bold">index e8d7558..4df867a 100644</span>
<span style="color: #A00000">--- a/src/switch_rtp.c</span>
<span style="color: #00A000">+++ b/src/switch_rtp.c</span>
<span style="color: #800080; font-weight: bold">@@ -1875,6 +1875,10 @@ static void jb_logger(const char *file, const char *func, int line, int level, c</span>
 SWITCH_DECLARE(switch_status_t) switch_rtp_debug_jitter_buffer(switch_rtp_t *rtp_session, const char *name)
 {
 
<span style="color: #00A000">+        if (!switch_rtp_ready(rtp_session)) {</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        </span>
         stfu_n_debug(rtp_session-&gt;jb, name);
         stfu_global_set_logger(jb_logger);
 
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
skip blocking writes on fs_cli to avoid backing up event socket

<span style="color: #000080; font-weight: bold">diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c</span>
<span style="color: #000080; font-weight: bold">index 19e8d7f..a70d63f 100644</span>
<span style="color: #A00000">--- a/libs/esl/fs_cli.c</span>
<span style="color: #00A000">+++ b/libs/esl/fs_cli.c</span>
<span style="color: #800080; font-weight: bold">@@ -589,22 +589,36 @@ static void *msg_thread_run(esl_thread_t *me, void *obj)</span>
 
         while(thread_running &amp;&amp; handle-&gt;connected) {
                 esl_status_t status = esl_recv_event_timed(handle, 10, 1, NULL);
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                if (WARN_STOP) {</span>
<span style="color: #A00000">-                        printf(&quot;Type control-D or /exit or /quit or /bye to exit.\n\n&quot;);</span>
<span style="color: #A00000">-                        WARN_STOP = 0;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #00A000">+                int aok = 1;                </span>
 
                 if (status == ESL_FAIL) {
<span style="color: #A00000">-                        esl_log(ESL_LOG_WARNING, &quot;Disconnected.\n&quot;);</span>
<span style="color: #00A000">+                        if (aok) esl_log(ESL_LOG_WARNING, &quot;Disconnected.\n&quot;);</span>
                         running = -1; thread_running = 0;
                 } else if (status == ESL_SUCCESS) {
<span style="color: #00A000">+#ifndef WIN32</span>
<span style="color: #00A000">+                        fd_set can_write;</span>
<span style="color: #00A000">+                        int fd;</span>
<span style="color: #00A000">+                        struct timeval to;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        fd = fileno(stdout);</span>
<span style="color: #00A000">+                        memset(&amp;to, 0, sizeof(to));</span>
<span style="color: #00A000">+                        FD_ZERO(&amp;can_write);</span>
<span style="color: #00A000">+                        FD_SET(fd, &amp;can_write);</span>
<span style="color: #00A000">+                        to.tv_sec = 0;</span>
<span style="color: #00A000">+                        to.tv_usec = 100000;</span>
<span style="color: #00A000">+                        if (select(fd + 1, NULL, &amp;can_write, NULL, &amp;to) &gt; 0) {</span>
<span style="color: #00A000">+                                aok = FD_ISSET(fd, &amp;can_write);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                aok = 0;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+#endif</span>
<span style="color: #00A000">+                        </span>
                         if (handle-&gt;last_event) {
                                 const char *type = esl_event_get_header(handle-&gt;last_event, &quot;content-type&quot;);
                                 int known = 0;
 
                                 if (!esl_strlen_zero(type)) {
<span style="color: #A00000">-                                        if (!strcasecmp(type, &quot;log/data&quot;)) {</span>
<span style="color: #00A000">+                                        if (aok &amp;&amp; !strcasecmp(type, &quot;log/data&quot;)) {</span>
                                                 const char *userdata = esl_event_get_header(handle-&gt;last_event, &quot;user-data&quot;);
                                                 
                                                 if (esl_strlen_zero(userdata) || esl_strlen_zero(filter_uuid) || !strcasecmp(filter_uuid, userdata)) {
<span style="color: #800080; font-weight: bold">@@ -631,7 +645,7 @@ static void *msg_thread_run(esl_thread_t *me, void *obj)</span>
                                         } else if (!strcasecmp(type, &quot;text/disconnect-notice&quot;)) {
                                                 running = -1; thread_running = 0;
                                                 known++;
<span style="color: #A00000">-                                        } else if (!strcasecmp(type, &quot;text/event-plain&quot;)) {</span>
<span style="color: #00A000">+                                        } else if (aok &amp;&amp; !strcasecmp(type, &quot;text/event-plain&quot;)) {</span>
                                                 char *foo;
                                                 esl_event_serialize(handle-&gt;last_ievent, &amp;foo, ESL_FALSE);
                                                 printf(&quot;RECV EVENT\n%s\n&quot;, foo);
<span style="color: #800080; font-weight: bold">@@ -641,7 +655,7 @@ static void *msg_thread_run(esl_thread_t *me, void *obj)</span>
                                         }
                                 }
                                 
<span style="color: #A00000">-                                if (!known) {</span>
<span style="color: #00A000">+                                if (aok &amp;&amp; !known) {</span>
                                         char *foo;
                                         printf(&quot;INCOMING DATA [%s]\n%s\n&quot;, type, handle-&gt;last_event-&gt;body ? handle-&gt;last_event-&gt;body : &quot;&quot;);
                                         esl_event_serialize(handle-&gt;last_event, &amp;foo, ESL_FALSE);
<span style="color: #800080; font-weight: bold">@@ -651,6 +665,11 @@ static void *msg_thread_run(esl_thread_t *me, void *obj)</span>
                         }
                 }
 
<span style="color: #00A000">+                if (WARN_STOP) {</span>
<span style="color: #00A000">+                        if (aok) printf(&quot;Type control-D or /exit or /quit or /bye to exit.\n\n&quot;);</span>
<span style="color: #00A000">+                        WARN_STOP = 0;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
                 usleep(1000);
         }
 
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
fix regression from f60fdf653dd2d7f8d3eaa6a9086e1f68bd993c59

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c</span>
<span style="color: #000080; font-weight: bold">index 0b16492..f7bf86b 100755</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_dptools/mod_dptools.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_dptools/mod_dptools.c</span>
<span style="color: #800080; font-weight: bold">@@ -2774,7 +2774,7 @@ static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session</span>
         switch_originate_flag_t myflags = SOF_NONE;
         char *cid_name_override = NULL;
         char *cid_num_override = NULL;
<span style="color: #A00000">-        char *domain = NULL;</span>
<span style="color: #00A000">+        char *domain = NULL, *dup_domain = NULL;</span>
         switch_channel_t *new_channel = NULL;
         unsigned int timelimit = 60;
         const char *skip, *var;
<span style="color: #800080; font-weight: bold">@@ -2788,6 +2788,7 @@ static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session</span>
                 *domain++ = &#39;\0&#39;;
         } else {
                 domain = switch_core_get_variable_pdup(&quot;domain&quot;, switch_core_session_get_pool(session));
<span style="color: #00A000">+                dup_domain = domain;</span>
         }
 
         if (!domain) {
<span style="color: #800080; font-weight: bold">@@ -2859,6 +2860,7 @@ static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session</span>
 
         switch_safe_free(template);
         switch_safe_free(group);
<span style="color: #00A000">+        switch_safe_free(dup_domain);</span>
 
         if (cause == SWITCH_CAUSE_NONE) {
                 cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c b/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c</span>
<span style="color: #000080; font-weight: bold">index 43534da..3bc5cb4 100644</span>
<span style="color: #A00000">--- a/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c</span>
<span style="color: #00A000">+++ b/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c</span>
<span style="color: #800080; font-weight: bold">@@ -309,11 +309,13 @@ static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session,</span>
                                                                                                 switch_call_cause_t *cancel_cause)
 {
         const char *profile;
<span style="color: #00A000">+        char *dup_profile = NULL;</span>
 
         if (session) {
                 profile = switch_channel_get_variable(switch_core_session_get_channel(session), &quot;sip_profile&quot;);
         } else {
<span style="color: #A00000">-                profile = switch_core_get_variable_pdup(&quot;sip_profile&quot;, switch_core_session_get_pool(session));</span>
<span style="color: #00A000">+                dup_profile = switch_core_get_variable_dup(&quot;sip_profile&quot;);</span>
<span style="color: #00A000">+                profile = dup_profile;</span>
         }
         if (zstr(profile)) {
                 profile = &quot;default&quot;;
<span style="color: #800080; font-weight: bold">@@ -323,6 +325,8 @@ static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session,</span>
 
         UNPROTECT_INTERFACE(sip_endpoint_interface);
 
<span style="color: #00A000">+        switch_safe_free(dup_profile);</span>
<span style="color: #00A000">+</span>
         return switch_core_session_outgoing_channel(session, var_event, &quot;sofia&quot;, outbound_profile, new_session, pool, SOF_NONE, cancel_cause);
 }
 
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
fix regression from f60fdf653dd2d7f8d3eaa6a9086e1f68bd993c59

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c</span>
<span style="color: #000080; font-weight: bold">index 4be2a64..0b16492 100755</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_dptools/mod_dptools.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_dptools/mod_dptools.c</span>
<span style="color: #800080; font-weight: bold">@@ -2887,7 +2887,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,</span>
                                                                                                  switch_call_cause_t *cancel_cause)
 {
         switch_xml_t x_domain = NULL, xml = NULL, x_user = NULL, x_group = NULL, x_param, x_params;
<span style="color: #A00000">-        char *user = NULL, *domain = NULL;</span>
<span style="color: #00A000">+        char *user = NULL, *domain = NULL, *dup_domain = NULL;</span>
         const char *dest = NULL;
         static switch_call_cause_t cause = SWITCH_CAUSE_NONE;
         unsigned int timelimit = 60;
<span style="color: #800080; font-weight: bold">@@ -2908,7 +2908,8 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,</span>
         if ((domain = strchr(user, &#39;@&#39;))) {
                 *domain++ = &#39;\0&#39;;
         } else {
<span style="color: #A00000">-                domain = switch_core_get_variable_pdup(&quot;domain&quot;, switch_core_session_get_pool(session));</span>
<span style="color: #00A000">+                domain = switch_core_get_variable_dup(&quot;domain&quot;);</span>
<span style="color: #00A000">+                dup_domain = domain;</span>
         }
 
         if (!domain) {
<span style="color: #800080; font-weight: bold">@@ -3115,6 +3116,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,</span>
         }
 
         switch_safe_free(user);
<span style="color: #00A000">+        switch_safe_free(dup_domain);</span>
 
         return cause;
 }
</pre></div>
<div class="highlight"><pre>committer: Jeff Lenk
comments: 
fix iLBC under windows

<span style="color: #000080; font-weight: bold">diff --git a/libs/ilbc/src/iLBC_decode.c b/libs/ilbc/src/iLBC_decode.c</span>
<span style="color: #000080; font-weight: bold">index fc46fe4..9fc7a24 100644</span>
<span style="color: #A00000">--- a/libs/ilbc/src/iLBC_decode.c</span>
<span style="color: #00A000">+++ b/libs/ilbc/src/iLBC_decode.c</span>
<span style="color: #800080; font-weight: bold">@@ -47,7 +47,9 @@</span>
             {
             fld dbl
             frndint
<span style="color: #00A000">+            fstp dbl</span>
         }
<span style="color: #00A000">+        return (long int) dbl;</span>
     }
 #elif defined (_WIN64)
 #include &lt;intrin.h&gt;
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
block control-z from fs cli and print a warning how to exit properly

<span style="color: #000080; font-weight: bold">diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c</span>
<span style="color: #000080; font-weight: bold">index 1e3bf04..19e8d7f 100644</span>
<span style="color: #A00000">--- a/libs/esl/fs_cli.c</span>
<span style="color: #00A000">+++ b/libs/esl/fs_cli.c</span>
<span style="color: #800080; font-weight: bold">@@ -8,6 +8,7 @@</span>
 #include &lt;signal.h&gt;
 
 #define CMD_BUFLEN 1024
<span style="color: #00A000">+static int WARN_STOP = 0;</span>
 
 #ifdef WIN32
 #define strdup(src) _strdup(src)
<span style="color: #800080; font-weight: bold">@@ -535,6 +536,13 @@ static BOOL console_readConsole(HANDLE conIn, char* buf, int len, int* pRed, int</span>
 static void handle_SIGINT(int sig)
 {
         if (sig);
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        WARN_STOP = 1;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        signal(SIGINT, handle_SIGINT);</span>
<span style="color: #00A000">+#ifdef SIGTSTP</span>
<span style="color: #00A000">+        signal(SIGTSTP, handle_SIGINT);</span>
<span style="color: #00A000">+#endif</span>
         return;
 }
 
<span style="color: #800080; font-weight: bold">@@ -581,6 +589,12 @@ static void *msg_thread_run(esl_thread_t *me, void *obj)</span>
 
         while(thread_running &amp;&amp; handle-&gt;connected) {
                 esl_status_t status = esl_recv_event_timed(handle, 10, 1, NULL);
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (WARN_STOP) {</span>
<span style="color: #00A000">+                        printf(&quot;Type control-D or /exit or /quit or /bye to exit.\n\n&quot;);</span>
<span style="color: #00A000">+                        WARN_STOP = 0;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
                 if (status == ESL_FAIL) {
                         esl_log(ESL_LOG_WARNING, &quot;Disconnected.\n&quot;);
                         running = -1; thread_running = 0;
<span style="color: #800080; font-weight: bold">@@ -1023,6 +1037,9 @@ int main(int argc, char *argv[])</span>
         }
         
         signal(SIGINT, handle_SIGINT);
<span style="color: #00A000">+#ifdef SIGTSTP</span>
<span style="color: #00A000">+        signal(SIGTSTP, handle_SIGINT);</span>
<span style="color: #00A000">+#endif</span>
 #ifdef SIGQUIT
         signal(SIGQUIT, handle_SIGQUIT);
 #endif
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
dont run execute_on_fsk when there was no data collected

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_fsk/mod_fsk.c b/src/mod/applications/mod_fsk/mod_fsk.c</span>
<span style="color: #000080; font-weight: bold">index 9802353..0291707 100644</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_fsk/mod_fsk.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_fsk/mod_fsk.c</span>
<span style="color: #800080; font-weight: bold">@@ -220,6 +220,7 @@ static switch_bool_t fsk_detect_callback(switch_media_bug_t *bug, void *user_dat</span>
                                 char *sp;
                                 switch_event_t *event;
                                 const char *app_var;
<span style="color: #00A000">+                                int total = 0;</span>
 
                                 switch_event_create_plain(&amp;event, SWITCH_EVENT_CHANNEL_DATA);
                                 
<span style="color: #800080; font-weight: bold">@@ -255,6 +256,7 @@ static switch_bool_t fsk_detect_callback(switch_media_bug_t *bug, void *user_dat</span>
                                         }
 
                                         if (varname &amp;&amp; val) {
<span style="color: #00A000">+                                                total++;</span>
                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;%s setting FSK var [%s][%s]\n&quot;, 
                                                                                   switch_channel_get_name(channel), varname, val);
                                                 switch_channel_set_variable(channel, varname, val);
<span style="color: #800080; font-weight: bold">@@ -270,7 +272,7 @@ static switch_bool_t fsk_detect_callback(switch_media_bug_t *bug, void *user_dat</span>
                                         }
                                 }
                                 
<span style="color: #A00000">-                                if ((app_var = switch_channel_get_variable(channel, &quot;execute_on_fsk&quot;))) {</span>
<span style="color: #00A000">+                                if (total &amp;&amp; (app_var = switch_channel_get_variable(channel, &quot;execute_on_fsk&quot;))) {</span>
                                         char *app_arg;
 
                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;%s processing execute_on_fsk [%s]\n&quot;, 
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
fix regression from d72cde9b76a856cf002366300bea02c26db44ffb

<span style="color: #000080; font-weight: bold">diff --git a/src/switch_core_session.c b/src/switch_core_session.c</span>
<span style="color: #000080; font-weight: bold">index 4836aae..d2e28de 100644</span>
<span style="color: #A00000">--- a/src/switch_core_session.c</span>
<span style="color: #00A000">+++ b/src/switch_core_session.c</span>
<span style="color: #800080; font-weight: bold">@@ -1865,6 +1865,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_app_flags(const char *ap</span>
 SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_async(switch_core_session_t *session, const char *app, const char *arg)
 {
         switch_event_t *execute_event;
<span style="color: #00A000">+        char *ap, *arp;</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        if (!arg &amp;&amp; strstr(app, &quot;::&quot;)) {</span>
<span style="color: #00A000">+                ap = switch_core_session_strdup(session, app);</span>
<span style="color: #00A000">+                app = ap;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if ((arp = strstr(ap, &quot;::&quot;))) {</span>
<span style="color: #00A000">+                        *arp = &#39;\0&#39;;</span>
<span style="color: #00A000">+                        arg = arp + 2;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
         
         if (switch_event_create(&amp;execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
                 switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, &quot;call-command&quot;, &quot;execute&quot;);
<span style="color: #800080; font-weight: bold">@@ -1894,6 +1905,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_get_flag</span>
         switch_application_interface_t *application_interface;
         switch_status_t status = SWITCH_STATUS_SUCCESS;
 
<span style="color: #00A000">+        if (!arg &amp;&amp; strstr(app, &quot;::&quot;)) {</span>
<span style="color: #00A000">+                return switch_core_session_execute_application_async(session, app, arg);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         if (switch_channel_down(session-&gt;channel)) {
                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Channel is hungup, aborting execution of application: %s\n&quot;, app);
                 return SWITCH_STATUS_FALSE;
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
FS-3006

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c</span>
<span style="color: #000080; font-weight: bold">index 8978b85..baa33d4 100644</span>
<span style="color: #A00000">--- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c</span>
<span style="color: #00A000">+++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c</span>
<span style="color: #800080; font-weight: bold">@@ -40,6 +40,8 @@</span>
 
 #define MY_EVENT_RINGING &quot;portaudio::ringing&quot;
 #define MY_EVENT_MAKE_CALL &quot;portaudio::makecall&quot;
<span style="color: #00A000">+#define MY_EVENT_CALL_HELD &quot;portaudio::callheld&quot;</span>
<span style="color: #00A000">+#define MY_EVENT_CALL_RESUMED &quot;portaudio::callresumed&quot;</span>
 #define MY_EVENT_ERROR_AUDIO_DEV &quot;portaudio::audio_dev_error&quot;
 #define SWITCH_PA_CALL_ID_VARIABLE &quot;pa_call_id&quot;
 
<span style="color: #800080; font-weight: bold">@@ -90,12 +92,20 @@ struct private_object {</span>
         switch_file_handle_t *hfh;
         switch_frame_t hold_frame;
         unsigned char holdbuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
<span style="color: #A00000">-        switch_codec_t write_codec;</span>
         struct private_object *next;
 };
 
 typedef struct private_object private_t;
 
<span style="color: #00A000">+struct audio_stream {</span>
<span style="color: #00A000">+        int indev;</span>
<span style="color: #00A000">+        int outdev;</span>
<span style="color: #00A000">+        PABLIO_Stream *stream;</span>
<span style="color: #00A000">+        switch_timer_t write_timer;</span>
<span style="color: #00A000">+        struct audio_stream *next;</span>
<span style="color: #00A000">+};</span>
<span style="color: #00A000">+typedef struct audio_stream audio_stream_t;</span>
<span style="color: #00A000">+</span>
 static struct {
         int debug;
         int port;
<span style="color: #800080; font-weight: bold">@@ -113,12 +123,13 @@ static struct {</span>
         switch_hash_t *call_hash;
         switch_mutex_t *device_lock;
         switch_mutex_t *pvt_lock;
<span style="color: #00A000">+        switch_mutex_t *streams_lock;</span>
         switch_mutex_t *flag_mutex;
         switch_mutex_t *pa_mutex;
         int sample_rate;
         int codec_ms;
<span style="color: #A00000">-        PABLIO_Stream *audio_stream;</span>
<span style="color: #A00000">-        PABLIO_Stream *ring_stream;</span>
<span style="color: #00A000">+        audio_stream_t *main_stream;</span>
<span style="color: #00A000">+        audio_stream_t *ring_stream;</span>
         switch_codec_t read_codec;
         switch_codec_t write_codec;
         switch_frame_t read_frame;
<span style="color: #800080; font-weight: bold">@@ -126,13 +137,20 @@ static struct {</span>
         unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
         unsigned char cngbuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
         private_t *call_list;
<span style="color: #00A000">+        audio_stream_t *stream_list;</span>
         int ring_interval;
         GFLAGS flags;
         switch_timer_t read_timer;
<span style="color: #A00000">-        switch_timer_t write_timer;</span>
<span style="color: #00A000">+        switch_timer_t readfile_timer;</span>
         switch_timer_t hold_timer;
         int dual_streams;
         time_t deactivate_timer;
<span style="color: #00A000">+        int live_stream_switch;</span>
<span style="color: #00A000">+        int no_auto_resume_call;</span>
<span style="color: #00A000">+        int no_ring_during_call;</span>
<span style="color: #00A000">+        int codecs_inited;</span>
<span style="color: #00A000">+        int stream_in_use; //only really used by playdev</span>
<span style="color: #00A000">+        int destroying_streams;</span>
 } globals;
 
 
<span style="color: #800080; font-weight: bold">@@ -164,9 +182,22 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi</span>
 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
<span style="color: #A00000">-static switch_status_t engage_device(int restart);</span>
<span style="color: #A00000">-static switch_status_t engage_ring_device(void);</span>
<span style="color: #A00000">-static void deactivate_ring_device(void);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t create_codecs(int restart);</span>
<span style="color: #00A000">+static void create_hold_event(private_t *tech_pvt, int unhold);</span>
<span style="color: #00A000">+static audio_stream_t * find_audio_stream(int indev, int outdev, int already_locked);</span>
<span style="color: #00A000">+static audio_stream_t * get_audio_stream(int indev, int outdev);</span>
<span style="color: #00A000">+static audio_stream_t * create_audio_stream(int indev, int outdev);</span>
<span style="color: #00A000">+PaError open_audio_stream(PABLIO_Stream **stream, const PaStreamParameters * inputParameters, const PaStreamParameters * outputParameters);</span>
<span style="color: #00A000">+static switch_status_t switch_audio_stream();</span>
<span style="color: #00A000">+static void add_stream(audio_stream_t *stream, int already_locked);</span>
<span style="color: #00A000">+static void remove_stream(audio_stream_t *stream, int already_locked);</span>
<span style="color: #00A000">+static switch_status_t destroy_audio_stream(int indev, int outdev);</span>
<span style="color: #00A000">+static switch_status_t destroy_actual_stream(audio_stream_t *stream);</span>
<span style="color: #00A000">+static void destroy_audio_streams();</span>
<span style="color: #00A000">+static switch_status_t validate_main_audio_stream();</span>
<span style="color: #00A000">+static switch_status_t validate_ring_audio_stream();</span>
<span style="color: #00A000">+</span>
 static int dump_info(int verbose);
 static switch_status_t load_config(void);
 static int get_dev_by_name(char *name, int in);
<span style="color: #800080; font-weight: bold">@@ -212,9 +243,8 @@ static switch_status_t channel_on_routing(switch_core_session_t *session)</span>
         if (hold_file) {
                 tech_pvt-&gt;hold_file = switch_core_session_strdup(session, hold_file);
         }
<span style="color: #A00000">-        </span>
<span style="color: #A00000">-        if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {</span>
<span style="color: #A00000">-                if (engage_device(0) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {</span>
<span style="color: #00A000">+                if (validate_main_audio_stream() != SWITCH_STATUS_SUCCESS) {</span>
                         switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
                         return SWITCH_STATUS_FALSE;
                 }
<span style="color: #800080; font-weight: bold">@@ -238,7 +268,7 @@ static switch_status_t channel_on_routing(switch_core_session_t *session)</span>
                                                                                   globals.read_codec.implementation-&gt;actual_samples_per_second,
                                                                                   SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {
 
<span style="color: #A00000">-                                        if (engage_ring_device() != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                                        if (validate_ring_audio_stream() != SWITCH_STATUS_SUCCESS) {</span>
                                                 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Ring Error!\n&quot;);
                                                 switch_core_file_close(&amp;fh);
<span style="color: #800080; font-weight: bold">@@ -263,7 +293,7 @@ static switch_status_t channel_on_routing(switch_core_session_t *session)</span>
                 }
 
                 while (switch_channel_get_state(channel) == CS_ROUTING &amp;&amp; !switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
<span style="color: #A00000">-                        switch_size_t olen = globals.read_timer.samples;</span>
<span style="color: #00A000">+                        switch_size_t olen = globals.readfile_timer.samples;</span>
 
                         if (switch_micro_time_now() - last &gt;= waitsec) {
                                 char buf[512];
<span style="color: #800080; font-weight: bold">@@ -273,7 +303,8 @@ static switch_status_t channel_on_routing(switch_core_session_t *session)</span>
 
                                 if (switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, MY_EVENT_RINGING) == SWITCH_STATUS_SUCCESS) {
                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;event_info&quot;, buf);
<span style="color: #A00000">-                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;call_id&quot;, tech_pvt-&gt;call_id);</span>
<span style="color: #00A000">+                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;call_id&quot;, tech_pvt-&gt;call_id); /* left behind for backwards compatability */</span>
<span style="color: #00A000">+                                        switch_channel_set_variable(channel, SWITCH_PA_CALL_ID_VARIABLE, tech_pvt-&gt;call_id);</span>
                                         switch_channel_event_set_data(channel, event);
                                         switch_event_fire(&amp;event);
                                 }
<span style="color: #800080; font-weight: bold">@@ -282,7 +313,7 @@ static switch_status_t channel_on_routing(switch_core_session_t *session)</span>
                         }
 
                         if (ring_file) {
<span style="color: #A00000">-                                if (switch_core_timer_next(&amp;globals.read_timer) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                                if (switch_core_timer_next(&amp;globals.readfile_timer) != SWITCH_STATUS_SUCCESS) {</span>
                                         switch_core_file_close(&amp;fh);
                                         break;
                                 }
<span style="color: #800080; font-weight: bold">@@ -292,8 +323,9 @@ static switch_status_t channel_on_routing(switch_core_session_t *session)</span>
                                         switch_core_file_seek(&amp;fh, &amp;pos, 0, SEEK_SET);
                                 }
 
<span style="color: #A00000">-                                if (globals.ring_stream) {</span>
<span style="color: #A00000">-                                        WriteAudioStream(globals.ring_stream, abuf, (long) olen, &amp;globals.write_timer);</span>
<span style="color: #00A000">+                                if (globals.ring_stream &amp;&amp; (! switch_test_flag(globals.call_list, TFLAG_MASTER) || </span>
<span style="color: #00A000">+                                                        ( !globals.no_ring_during_call &amp;&amp; globals.main_stream != globals.ring_stream)) ) { //if there is a ring stream and not an active call or if there is an active call and we are allowed to ring during it AND the ring stream is not the main stream                                                </span>
<span style="color: #00A000">+                                                WriteAudioStream(globals.ring_stream-&gt;stream, abuf, (long) olen, &amp;globals.ring_stream-&gt;write_timer);</span>
                                 }
                         } else {
                                 switch_yield(10000);
<span style="color: #800080; font-weight: bold">@@ -303,7 +335,6 @@ static switch_status_t channel_on_routing(switch_core_session_t *session)</span>
         }
 
         if (ring_file) {
<span style="color: #A00000">-                deactivate_ring_device();</span>
                 switch_core_file_close(&amp;fh);
         }
 
<span style="color: #800080; font-weight: bold">@@ -329,27 +360,130 @@ static switch_status_t channel_on_execute(switch_core_session_t *session)</span>
         return SWITCH_STATUS_SUCCESS;
 }
 
<span style="color: #A00000">-static void deactivate_audio_device(void)</span>
<span style="color: #00A000">+static audio_stream_t* find_audio_stream(int indev, int outdev, int already_locked)</span>
 {
<span style="color: #A00000">-        if (!globals.audio_stream) {</span>
<span style="color: #A00000">-                return;</span>
<span style="color: #00A000">+        audio_stream_t *cur_stream;</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        if (! globals.stream_list) {</span>
<span style="color: #00A000">+                return NULL;</span>
         }
 
<span style="color: #A00000">-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Stop audio device.\n&quot;);</span>
<span style="color: #00A000">+        if (! already_locked) {</span>
<span style="color: #00A000">+                switch_mutex_lock(globals.streams_lock);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        cur_stream = globals.stream_list;</span>
 
<span style="color: #A00000">-        switch_mutex_lock(globals.device_lock);</span>
<span style="color: #A00000">-        /* LOCKED ************************************************************************************************** */</span>
<span style="color: #00A000">+        while (cur_stream != NULL) {</span>
<span style="color: #00A000">+                if (cur_stream-&gt;outdev == outdev) {</span>
<span style="color: #00A000">+                        if (indev == -1 || cur_stream-&gt;indev == indev) {</span>
<span style="color: #00A000">+                                if (! already_locked) {</span>
<span style="color: #00A000">+                                        switch_mutex_unlock(globals.streams_lock);</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                                return cur_stream;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                cur_stream = cur_stream-&gt;next;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (! already_locked) {</span>
<span style="color: #00A000">+                switch_mutex_unlock(globals.streams_lock);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        return NULL;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+static void destroy_audio_streams()</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int close_wait = 4;</span>
<span style="color: #00A000">+        globals.destroying_streams = 1;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        while (globals.stream_in_use &amp;&amp; close_wait--) {</span>
<span style="color: #00A000">+                switch_yield(250000);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        while (globals.stream_list != NULL) {</span>
<span style="color: #00A000">+                destroy_audio_stream(globals.stream_list-&gt;indev, globals.stream_list-&gt;outdev);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        globals.destroying_streams = 0;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+static switch_status_t validate_main_audio_stream()</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        if (globals.read_timer.timer_interface) {</span>
<span style="color: #00A000">+                switch_core_timer_sync(&amp;globals.read_timer);</span>
<span style="color: #00A000">+        }</span>
 
<span style="color: #A00000">-        if (globals.audio_stream) {</span>
<span style="color: #A00000">-                if (globals.ring_stream == globals.audio_stream) {</span>
<span style="color: #A00000">-                        globals.ring_stream = NULL;</span>
<span style="color: #00A000">+        if (globals.main_stream) {</span>
<span style="color: #00A000">+                if (globals.main_stream-&gt;write_timer.timer_interface) {</span>
<span style="color: #00A000">+                        switch_core_timer_sync(&amp;(globals.main_stream-&gt;write_timer));</span>
                 }
<span style="color: #A00000">-                CloseAudioStream(globals.audio_stream);</span>
<span style="color: #A00000">-                globals.audio_stream = NULL;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                return SWITCH_STATUS_SUCCESS;</span>
         }
 
<span style="color: #A00000">-        /* UNLOCKED ************************************************************************************************* */</span>
<span style="color: #A00000">-        switch_mutex_unlock(globals.device_lock);</span>
<span style="color: #00A000">+        globals.main_stream = get_audio_stream(globals.indev, globals.outdev);</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        if (globals.main_stream) {</span>
<span style="color: #00A000">+                return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t validate_ring_audio_stream()</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        if (globals.ringdev == -1) {</span>
<span style="color: #00A000">+                return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (globals.ring_stream) {</span>
<span style="color: #00A000">+                if (globals.ring_stream-&gt;write_timer.timer_interface) {</span>
<span style="color: #00A000">+                        switch_core_timer_sync(&amp;(globals.ring_stream-&gt;write_timer));</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        globals.ring_stream = get_audio_stream(-1, globals.ringdev);</span>
<span style="color: #00A000">+        if (globals.ring_stream) {</span>
<span style="color: #00A000">+                return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t destroy_actual_stream(audio_stream_t *stream)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        if (stream == NULL) {</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (globals.main_stream == stream) {</span>
<span style="color: #00A000">+                globals.main_stream = NULL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (globals.ring_stream == stream) {</span>
<span style="color: #00A000">+                globals.ring_stream = NULL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        CloseAudioStream(stream-&gt;stream);</span>
<span style="color: #00A000">+        stream-&gt;stream = NULL;</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        if (stream-&gt;write_timer.timer_interface) {</span>
<span style="color: #00A000">+                switch_core_timer_destroy(&amp;stream-&gt;write_timer);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        switch_safe_free(stream);</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+static switch_status_t destroy_audio_stream(int indev, int outdev)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        audio_stream_t *stream;</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        switch_mutex_lock(globals.streams_lock);</span>
<span style="color: #00A000">+        stream = find_audio_stream(indev, outdev,1);</span>
<span style="color: #00A000">+        if (stream == NULL) {</span>
<span style="color: #00A000">+                switch_mutex_unlock(globals.streams_lock);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;                </span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        remove_stream(stream, 1);</span>
<span style="color: #00A000">+        switch_mutex_unlock(globals.streams_lock);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        destroy_actual_stream(stream);</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
 }
 
 
<span style="color: #800080; font-weight: bold">@@ -368,34 +502,69 @@ static void destroy_codecs(void)</span>
                 switch_core_timer_destroy(&amp;globals.read_timer);
         }
 
<span style="color: #A00000">-        if (globals.write_timer.timer_interface) {</span>
<span style="color: #A00000">-                switch_core_timer_destroy(&amp;globals.write_timer);</span>
<span style="color: #00A000">+        if (globals.readfile_timer.timer_interface) {</span>
<span style="color: #00A000">+                switch_core_timer_destroy(&amp;globals.readfile_timer);</span>
         }
 
         if (globals.hold_timer.timer_interface) {
                 switch_core_timer_destroy(&amp;globals.hold_timer);
         }
 
<span style="color: #A00000">-</span>
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        globals.codecs_inited = 0;</span>
 }
 
<span style="color: #A00000">-static void deactivate_ring_device(void)</span>
<span style="color: #00A000">+static void create_hold_event(private_t *tech_pvt, int unhold)</span>
 {
<span style="color: #A00000">-        if (!globals.ring_stream) {</span>
<span style="color: #A00000">-                return;</span>
<span style="color: #00A000">+        switch_event_t *event;</span>
<span style="color: #00A000">+        char * event_id;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (unhold) {</span>
<span style="color: #00A000">+                event_id = MY_EVENT_CALL_RESUMED;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                event_id = MY_EVENT_CALL_HELD;</span>
         }
 
<span style="color: #A00000">-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Stop ring device.\n&quot;);</span>
<span style="color: #A00000">-        switch_mutex_lock(globals.device_lock);</span>
<span style="color: #A00000">-        if (globals.ring_stream &amp;&amp; globals.ring_stream != globals.audio_stream) {</span>
<span style="color: #A00000">-                CloseAudioStream(globals.ring_stream);</span>
<span style="color: #00A000">+        if (switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, event_id) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                switch_channel_event_set_data(switch_core_session_get_channel(tech_pvt-&gt;session), event);</span>
<span style="color: #00A000">+                switch_event_fire(&amp;event);</span>
         }
<span style="color: #A00000">-        globals.ring_stream = NULL;</span>
<span style="color: #A00000">-        switch_mutex_unlock(globals.device_lock);</span>
 }
 
<span style="color: #00A000">+static void add_stream(audio_stream_t * stream, int already_locked)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        audio_stream_t *last;</span>
 
<span style="color: #00A000">+        if (! already_locked) {</span>
<span style="color: #00A000">+                switch_mutex_lock(globals.streams_lock);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        for (last = globals.stream_list; last &amp;&amp; last-&gt;next; last = last-&gt;next);</span>
<span style="color: #00A000">+        if (last == NULL) {</span>
<span style="color: #00A000">+                globals.stream_list = stream;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                last-&gt;next = stream;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (! already_locked) {</span>
<span style="color: #00A000">+                switch_mutex_unlock(globals.streams_lock);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+static void remove_stream(audio_stream_t * stream, int already_locked)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        audio_stream_t *previous;</span>
<span style="color: #00A000">+        if (! already_locked) {</span>
<span style="color: #00A000">+                switch_mutex_lock(globals.streams_lock);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (globals.stream_list == stream) {</span>
<span style="color: #00A000">+                globals.stream_list = stream-&gt;next;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                for (previous = globals.stream_list; previous &amp;&amp; previous-&gt;next &amp;&amp; previous-&gt;next != stream; previous = previous-&gt;next) {</span>
<span style="color: #00A000">+                        </span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                previous-&gt;next = stream-&gt;next;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (! already_locked) {</span>
<span style="color: #00A000">+                switch_mutex_unlock(globals.streams_lock);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+}</span>
 
 static void add_pvt(private_t *tech_pvt, int master)
 {
<span style="color: #800080; font-weight: bold">@@ -418,8 +587,9 @@ static void add_pvt(private_t *tech_pvt, int master)</span>
                 if (tp == tech_pvt) {
                         in_list = 1;
                 }
<span style="color: #A00000">-                if (master) {</span>
<span style="color: #00A000">+                if (master &amp;&amp; switch_test_flag(tp, TFLAG_MASTER) ) {</span>
                         switch_clear_flag_locked(tp, TFLAG_MASTER);
<span style="color: #00A000">+                        create_hold_event(tp,0);</span>
                 }
         }
 
<span style="color: #800080; font-weight: bold">@@ -446,11 +616,16 @@ static void add_pvt(private_t *tech_pvt, int master)</span>
 static void remove_pvt(private_t *tech_pvt)
 {
         private_t *tp, *last = NULL;
<span style="color: #00A000">+        int was_master = 0;</span>
 
         switch_mutex_lock(globals.pvt_lock);
         for (tp = globals.call_list; tp; tp = tp-&gt;next) {
<span style="color: #A00000">-                switch_clear_flag_locked(tp, TFLAG_MASTER);</span>
<span style="color: #00A000">+                </span>
                 if (tp == tech_pvt) {
<span style="color: #00A000">+                        if (switch_test_flag(tp, TFLAG_MASTER)) {</span>
<span style="color: #00A000">+                                switch_clear_flag_locked(tp, TFLAG_MASTER);</span>
<span style="color: #00A000">+                                was_master = 1;</span>
<span style="color: #00A000">+                        }</span>
                         if (last) {
                                 last-&gt;next = tp-&gt;next;
                         } else {
<span style="color: #800080; font-weight: bold">@@ -461,10 +636,13 @@ static void remove_pvt(private_t *tech_pvt)</span>
         }
 
         if (globals.call_list) {
<span style="color: #A00000">-                switch_set_flag_locked(globals.call_list, TFLAG_MASTER);</span>
<span style="color: #00A000">+                if (was_master &amp;&amp; ! globals.no_auto_resume_call) {</span>
<span style="color: #00A000">+                        switch_set_flag_locked(globals.call_list, TFLAG_MASTER);</span>
<span style="color: #00A000">+                        create_hold_event(globals.call_list, 1);</span>
<span style="color: #00A000">+                }</span>
         } else {
                 globals.deactivate_timer = switch_epoch_time_now(NULL) + 2;
<span style="color: #A00000">-                deactivate_audio_device();</span>
<span style="color: #00A000">+                destroy_audio_streams();</span>
         }
 
         switch_mutex_unlock(globals.pvt_lock);
<span style="color: #800080; font-weight: bold">@@ -555,8 +733,8 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch</span>
         int samples = 0;
         switch_status_t status = SWITCH_STATUS_FALSE;
         switch_assert(tech_pvt != NULL);
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (!globals.audio_stream) {</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        if (!globals.main_stream) {</span>
                 goto normal_return;
         }
 
<span style="color: #800080; font-weight: bold">@@ -618,7 +796,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch</span>
         }
 
         switch_mutex_lock(globals.device_lock);
<span style="color: #A00000">-        samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data, globals.read_codec.implementation-&gt;samples_per_packet, &amp;globals.read_timer);</span>
<span style="color: #00A000">+        samples = ReadAudioStream(globals.main_stream-&gt;stream, globals.read_frame.data, globals.read_codec.implementation-&gt;samples_per_packet, &amp;globals.read_timer);</span>
         switch_mutex_unlock(globals.device_lock);
 
         if (samples) {
<span style="color: #800080; font-weight: bold">@@ -635,7 +813,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch</span>
                 goto cng_nowait;
         }
 
<span style="color: #A00000">-  normal_return:</span>
<span style="color: #00A000">+normal_return:</span>
         return status;
 
   cng_nowait:
<span style="color: #800080; font-weight: bold">@@ -655,7 +833,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc</span>
         private_t *tech_pvt = switch_core_session_get_private(session);
         switch_assert(tech_pvt != NULL);
 
<span style="color: #A00000">-        if (!globals.audio_stream) {</span>
<span style="color: #00A000">+        if (!globals.main_stream) {</span>
                 return SWITCH_STATUS_FALSE;
         }
 
<span style="color: #800080; font-weight: bold">@@ -667,9 +845,9 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc</span>
                 return SWITCH_STATUS_SUCCESS;
         }
 
<span style="color: #A00000">-        if (globals.audio_stream) {</span>
<span style="color: #00A000">+        if (globals.main_stream) {</span>
                 if (switch_test_flag((&amp;globals), GFLAG_EAR)) {
<span style="color: #A00000">-                        WriteAudioStream(globals.audio_stream, (short *) frame-&gt;data, (int) (frame-&gt;datalen / sizeof(SAMPLE)), &amp;globals.write_timer);</span>
<span style="color: #00A000">+                        WriteAudioStream(globals.main_stream-&gt;stream, (short *) frame-&gt;data, (int) (frame-&gt;datalen / sizeof(SAMPLE)), &amp;(globals.main_stream-&gt;write_timer));</span>
                 }
                 status = SWITCH_STATUS_SUCCESS;
         }
<span style="color: #800080; font-weight: bold">@@ -747,7 +925,6 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi</span>
                         channel = switch_core_session_get_channel(*new_session);
                         switch_core_session_set_private(*new_session, tech_pvt);
                         tech_pvt-&gt;session = *new_session;
<span style="color: #A00000">-                        globals.flags = GFLAG_EAR | GFLAG_MOUTH;</span>
                 } else {
                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_CRIT, &quot;Hey where is my memory pool?\n&quot;);
                         switch_core_session_destroy(new_session);
<span style="color: #800080; font-weight: bold">@@ -796,16 +973,17 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load)</span>
         switch_core_hash_init(&amp;globals.call_hash, module_pool);
         switch_mutex_init(&amp;globals.device_lock, SWITCH_MUTEX_NESTED, module_pool);
         switch_mutex_init(&amp;globals.pvt_lock, SWITCH_MUTEX_NESTED, module_pool);
<span style="color: #00A000">+        switch_mutex_init(&amp;globals.streams_lock, SWITCH_MUTEX_NESTED, module_pool);</span>
         switch_mutex_init(&amp;globals.flag_mutex, SWITCH_MUTEX_NESTED, module_pool);
         switch_mutex_init(&amp;globals.pa_mutex, SWITCH_MUTEX_NESTED, module_pool);
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        globals.codecs_inited=0;</span>
         globals.read_frame.data = globals.databuf;
         globals.read_frame.buflen = sizeof(globals.databuf);
         globals.cng_frame.data = globals.cngbuf;
         globals.cng_frame.buflen = sizeof(globals.cngbuf);
         globals.cng_frame.datalen = switch_samples_per_packet(globals.sample_rate, globals.codec_ms) * 2;
         switch_set_flag((&amp;globals.cng_frame), SFF_CNG);
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        globals.flags = GFLAG_EAR | GFLAG_MOUTH;</span>
         /* dual streams makes portaudio on solaris choke */
 #if defined(sun) || defined(__sun)
         globals.dual_streams = 0;
<span style="color: #800080; font-weight: bold">@@ -834,6 +1012,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load)</span>
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn&#39;t register subclass!\n&quot;);
                 return SWITCH_STATUS_GENERR;
         }
<span style="color: #00A000">+        if (switch_event_reserve_subclass(MY_EVENT_CALL_HELD) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn&#39;t register subclass!\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_GENERR;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (switch_event_reserve_subclass(MY_EVENT_CALL_RESUMED) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn&#39;t register subclass!\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_GENERR;</span>
<span style="color: #00A000">+        }</span>
 
         if (switch_event_reserve_subclass(MY_EVENT_ERROR_AUDIO_DEV) != SWITCH_STATUS_SUCCESS) {
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn&#39;t register subclass!\n&quot;);
<span style="color: #800080; font-weight: bold">@@ -861,9 +1047,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load)</span>
         switch_console_set_complete(&quot;add pa devlist&quot;);
         switch_console_set_complete(&quot;add pa indev&quot;);
         switch_console_set_complete(&quot;add pa outdev&quot;);
<span style="color: #00A000">+        switch_console_set_complete(&quot;add pa preparestream&quot;);</span>
<span style="color: #00A000">+        switch_console_set_complete(&quot;add pa switchstream&quot;);</span>
<span style="color: #00A000">+        switch_console_set_complete(&quot;add pa closestreams&quot;);</span>
         switch_console_set_complete(&quot;add pa ringdev&quot;);
         switch_console_set_complete(&quot;add pa ringfile&quot;);
         switch_console_set_complete(&quot;add pa play&quot;);
<span style="color: #00A000">+        switch_console_set_complete(&quot;add pa playdev&quot;);</span>
         switch_console_set_complete(&quot;add pa looptest&quot;);
 
         /* indicate that the module should continue to be loaded */
<span style="color: #800080; font-weight: bold">@@ -881,9 +1071,12 @@ static switch_status_t load_config(void)</span>
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Open of %s failed\n&quot;, cf);
                 return SWITCH_STATUS_TERM;
         }
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        destroy_audio_streams();</span>
<span style="color: #00A000">+        destroy_codecs();</span>
         globals.dual_streams = 0;
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        globals.live_stream_switch = 0;</span>
<span style="color: #00A000">+        globals.no_auto_resume_call = 0;</span>
<span style="color: #00A000">+        globals.no_ring_during_call = 0;</span>
         globals.indev = globals.outdev = globals.ringdev = -1;
         globals.sample_rate = 8000;
 
<span style="color: #800080; font-weight: bold">@@ -896,6 +1089,24 @@ static switch_status_t load_config(void)</span>
                                 globals.debug = atoi(val);
                         } else if (!strcmp(var, &quot;ring-interval&quot;)) {
                                 globals.ring_interval = atoi(val);
<span style="color: #00A000">+                        } else if (!strcmp(var, &quot;no-auto-resume-call&quot;)) {</span>
<span style="color: #00A000">+                                if (switch_true(val)) {</span>
<span style="color: #00A000">+                                        globals.no_auto_resume_call = 1;</span>
<span style="color: #00A000">+                                } else {</span>
<span style="color: #00A000">+                                        globals.no_auto_resume_call = 0;</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                        } else if (!strcmp(var, &quot;no-ring-during-call&quot;)) {</span>
<span style="color: #00A000">+                                if (switch_true(val)) {</span>
<span style="color: #00A000">+                                        globals.no_ring_during_call = 1;</span>
<span style="color: #00A000">+                                } else {</span>
<span style="color: #00A000">+                                        globals.no_ring_during_call = 0;</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                        } else if (!strcmp(var, &quot;live-stream-switch&quot;)) {</span>
<span style="color: #00A000">+                                if (switch_true(val)) {</span>
<span style="color: #00A000">+                                        globals.live_stream_switch = 1;</span>
<span style="color: #00A000">+                                } else {</span>
<span style="color: #00A000">+                                        globals.live_stream_switch = 0;</span>
<span style="color: #00A000">+                                }</span>
                         } else if (!strcmp(var, &quot;ring-file&quot;)) {
                                 set_global_ring_file(val);
                         } else if (!strcmp(var, &quot;hold-file&quot;)) {
<span style="color: #800080; font-weight: bold">@@ -1007,8 +1218,7 @@ static switch_status_t load_config(void)</span>
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_portaudio_shutdown)
 {
 
<span style="color: #A00000">-        deactivate_audio_device();</span>
<span style="color: #A00000">-        deactivate_ring_device();</span>
<span style="color: #00A000">+        destroy_audio_streams();</span>
         destroy_codecs();
 
         Pa_Terminate();
<span style="color: #800080; font-weight: bold">@@ -1017,6 +1227,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_portaudio_shutdown)</span>
         switch_event_free_subclass(MY_EVENT_RINGING);
         switch_event_free_subclass(MY_EVENT_MAKE_CALL);
         switch_event_free_subclass(MY_EVENT_ERROR_AUDIO_DEV);
<span style="color: #00A000">+        switch_event_free_subclass(MY_EVENT_CALL_HELD);</span>
<span style="color: #00A000">+        switch_event_free_subclass(MY_EVENT_CALL_RESUMED);</span>
<span style="color: #00A000">+        </span>
 
         switch_safe_free(globals.dialplan);
         switch_safe_free(globals.context);
<span style="color: #800080; font-weight: bold">@@ -1118,7 +1331,99 @@ static void PrintSupportedStandardSampleRates(const PaStreamParameters * inputPa</span>
 }
 
 /*******************************************************************/
<span style="color: #00A000">+static switch_status_t play_dev(switch_stream_handle_t *stream, int outdev, char * file, const char * max_seconds, const char * no_close)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        switch_file_handle_t fh = { 0 };</span>
<span style="color: #00A000">+        int samples = 0;</span>
<span style="color: #00A000">+        int seconds = 5;</span>
<span style="color: #00A000">+        audio_stream_t * audio_stream;</span>
<span style="color: #00A000">+        int created_stream = 0;</span>
<span style="color: #00A000">+        int wrote = 0;</span>
<span style="color: #00A000">+        switch_size_t olen;</span>
<span style="color: #00A000">+        int16_t abuf[2048];</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (!strcasecmp(file, &quot;ringtest&quot;)) {</span>
<span style="color: #00A000">+                file = globals.ring_file;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (outdev == -1) {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;Invalid output audio device\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        audio_stream = get_audio_stream(-1, outdev);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        fh.pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (switch_core_file_open(&amp;fh,        file,</span>
<span style="color: #00A000">+                globals.read_codec.implementation-&gt;number_of_channels,</span>
<span style="color: #00A000">+                globals.read_codec.implementation-&gt;actual_samples_per_second,</span>
<span style="color: #00A000">+                SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                        stream-&gt;write_function(stream, &quot;Cannot play requested file %s\n&quot;, file);</span>
<span style="color: #00A000">+                        return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        olen = globals.read_codec.implementation-&gt;samples_per_packet;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (max_seconds) {</span>
<span style="color: #00A000">+                int i = atoi(max_seconds);</span>
<span style="color: #00A000">+                if (i &gt;= 0) {</span>
<span style="color: #00A000">+                        seconds = i;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (globals.call_list) {</span>
<span style="color: #00A000">+                switch_mutex_lock(globals.pvt_lock);</span>
<span style="color: #00A000">+                if (!globals.main_stream) {</span>
<span style="color: #00A000">+                        switch_mutex_unlock(globals.pvt_lock);</span>
<span style="color: #00A000">+                        return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if ( switch_test_flag(globals.call_list, TFLAG_MASTER) &amp;&amp; globals.main_stream-&gt;outdev == outdev) { /*so we are the active stream so we need to dupe it basically */</span>
<span style="color: #00A000">+                        audio_stream = create_audio_stream(-1,outdev);</span>
<span style="color: #00A000">+                        created_stream=1;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                switch_mutex_unlock(globals.pvt_lock);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (! audio_stream) {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;Failed to engage audio device\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
 
<span style="color: #00A000">+        samples = globals.read_codec.implementation-&gt;actual_samples_per_second * seconds;</span>
<span style="color: #00A000">+        globals.stream_in_use=1;</span>
<span style="color: #00A000">+        while (switch_core_file_read(&amp;fh, abuf, &amp;olen) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                if (globals.destroying_streams ||  ! audio_stream-&gt;stream) {</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                WriteAudioStream(audio_stream-&gt;stream, abuf, (long) olen, &amp;(audio_stream-&gt;write_timer));</span>
<span style="color: #00A000">+                wrote += (int) olen;</span>
<span style="color: #00A000">+                if (samples) {</span>
<span style="color: #00A000">+                        samples -= (int) olen;</span>
<span style="color: #00A000">+                        if (samples &lt;= 0) {</span>
<span style="color: #00A000">+                                break;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                olen = globals.read_codec.implementation-&gt;samples_per_packet;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        globals.stream_in_use = 0;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        switch_core_file_close(&amp;fh);</span>
<span style="color: #00A000">+        if (! globals.call_list &amp;&amp; ( ! no_close || strcasecmp(no_close,  &quot;no_close&quot;))) {</span>
<span style="color: #00A000">+                destroy_audio_streams();</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        seconds = wrote / globals.read_codec.implementation-&gt;actual_samples_per_second;</span>
<span style="color: #00A000">+        stream-&gt;write_function(stream, &quot;playback test [%s] %d second(s) %d samples @%dkhz&quot;,</span>
<span style="color: #00A000">+                file, seconds, wrote, globals.read_codec.implementation-&gt;actual_samples_per_second);</span>
<span style="color: #00A000">+        if (created_stream) { /*still need this as not added to the global pool */</span>
<span style="color: #00A000">+                destroy_actual_stream(audio_stream);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
 static switch_status_t devlist(char **argv, int argc, switch_stream_handle_t *stream)
 {
         int i, numDevices, prev;
<span style="color: #800080; font-weight: bold">@@ -1200,8 +1505,7 @@ static int dump_info(int verbose)</span>
         }
 
         if (verbose &lt; 0) {
<span style="color: #A00000">-                deactivate_audio_device();</span>
<span style="color: #A00000">-                deactivate_ring_device();</span>
<span style="color: #00A000">+                destroy_audio_streams();</span>
                 destroy_codecs();
                 Pa_Terminate();
                 Pa_Initialize();
<span style="color: #800080; font-weight: bold">@@ -1309,36 +1613,15 @@ static int dump_info(int verbose)</span>
         return err;
 }
 
<span style="color: #A00000">-static switch_status_t engage_device(int restart)</span>
<span style="color: #00A000">+static switch_status_t create_codecs(int restart)</span>
 {
<span style="color: #A00000">-        PaStreamParameters inputParameters, outputParameters;</span>
<span style="color: #A00000">-        PaError err;</span>
         int sample_rate = globals.sample_rate;
         int codec_ms = globals.codec_ms;
<span style="color: #A00000">-        switch_event_t *event;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        switch_mutex_lock(globals.device_lock);</span>
<span style="color: #A00000">-        while (globals.deactivate_timer &gt; switch_epoch_time_now(NULL)) {</span>
<span style="color: #A00000">-                switch_yield(1000000);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        switch_mutex_unlock(globals.device_lock);</span>
<span style="color: #A00000">-</span>
 
         if (restart) {
<span style="color: #A00000">-                deactivate_audio_device();</span>
<span style="color: #A00000">-                deactivate_ring_device();</span>
                 destroy_codecs();
         }
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (globals.read_timer.timer_interface) {</span>
<span style="color: #A00000">-                switch_core_timer_sync(&amp;globals.read_timer);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (globals.write_timer.timer_interface) {</span>
<span style="color: #A00000">-                switch_core_timer_sync(&amp;globals.write_timer);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (globals.audio_stream) {</span>
<span style="color: #00A000">+        if (globals.codecs_inited) {</span>
                 return SWITCH_STATUS_SUCCESS;
         }
 
<span style="color: #800080; font-weight: bold">@@ -1375,20 +1658,18 @@ static switch_status_t engage_device(int restart)</span>
                         return SWITCH_STATUS_FALSE;
                 }
         }
<span style="color: #A00000">-</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (!globals.write_timer.timer_interface) {</span>
<span style="color: #A00000">-                if (switch_core_timer_init(&amp;globals.write_timer,</span>
<span style="color: #00A000">+        if (!globals.readfile_timer.timer_interface) {</span>
<span style="color: #00A000">+                if (switch_core_timer_init(&amp;globals.readfile_timer,</span>
                                                                    globals.timer_name, codec_ms, globals.read_codec.implementation-&gt;samples_per_packet,
                                                                    module_pool) != SWITCH_STATUS_SUCCESS) {
                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;setup timer failed!\n&quot;);
                         switch_core_codec_destroy(&amp;globals.read_codec);
                         switch_core_codec_destroy(&amp;globals.write_codec);
<span style="color: #A00000">-                        switch_core_timer_destroy(&amp;globals.read_timer);</span>
                         return SWITCH_STATUS_FALSE;
                 }
         }
 
<span style="color: #00A000">+</span>
         if (!globals.hold_timer.timer_interface) {
                 if (switch_core_timer_init(&amp;globals.hold_timer,
                                                                    globals.timer_name, codec_ms, globals.read_codec.implementation-&gt;samples_per_packet,
<span style="color: #800080; font-weight: bold">@@ -1397,106 +1678,119 @@ static switch_status_t engage_device(int restart)</span>
                         switch_core_codec_destroy(&amp;globals.read_codec);
                         switch_core_codec_destroy(&amp;globals.write_codec);
                         switch_core_timer_destroy(&amp;globals.read_timer);
<span style="color: #A00000">-                        switch_core_timer_destroy(&amp;globals.write_timer);</span>
<span style="color: #00A000">+                        switch_core_timer_destroy(&amp;globals.readfile_timer);</span>
<span style="color: #00A000">+                        </span>
                         return SWITCH_STATUS_FALSE;
                 }
         }
 
<span style="color: #A00000">-        globals.read_frame.rate = sample_rate;</span>
<span style="color: #A00000">-        globals.read_frame.codec = &amp;globals.read_codec;</span>
<span style="color: #00A000">+        globals.cng_frame.rate = globals.read_frame.rate = sample_rate;</span>
<span style="color: #00A000">+        globals.cng_frame.codec = globals.read_frame.codec = &amp;globals.read_codec;</span>
 
<span style="color: #A00000">-        switch_mutex_lock(globals.device_lock);</span>
<span style="color: #A00000">-        /* LOCKED ************************************************************************************************** */</span>
<span style="color: #A00000">-        inputParameters.device = globals.indev;</span>
<span style="color: #A00000">-        inputParameters.channelCount = 1;</span>
<span style="color: #A00000">-        inputParameters.sampleFormat = SAMPLE_TYPE;</span>
<span style="color: #A00000">-        inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)-&gt;defaultLowInputLatency;</span>
<span style="color: #A00000">-        inputParameters.hostApiSpecificStreamInfo = NULL;</span>
<span style="color: #A00000">-        outputParameters.device = globals.outdev;</span>
<span style="color: #00A000">+        globals.codecs_inited=1;</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t switch_audio_stream()</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        audio_stream_t *stream;</span>
<span style="color: #00A000">+        if (! globals.call_list) { /* If no active calls then it will automatically switch over on next call */</span>
<span style="color: #00A000">+                return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        stream = get_audio_stream(globals.indev, globals.outdev);</span>
<span style="color: #00A000">+        if (stream == NULL) {</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        globals.main_stream = stream;//TODO: need locks around here??</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+PaError open_audio_stream(PABLIO_Stream **stream, const PaStreamParameters * inputParameters, const PaStreamParameters * outputParameters)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        if (inputParameters-&gt;device != -1) {</span>
<span style="color: #00A000">+                return OpenAudioStream(stream, inputParameters, outputParameters, globals.sample_rate, paClipOff, globals.read_codec.implementation-&gt;samples_per_packet, globals.dual_streams);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        return OpenAudioStream(stream, NULL, outputParameters, globals.sample_rate, paClipOff, globals.read_codec.implementation-&gt;samples_per_packet, 0);</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static audio_stream_t *create_audio_stream(int indev, int outdev)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        PaStreamParameters inputParameters, outputParameters;</span>
<span style="color: #00A000">+        PaError err;</span>
<span style="color: #00A000">+        switch_event_t *event;</span>
<span style="color: #00A000">+        audio_stream_t *stream;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        stream = malloc(sizeof(audio_stream_t));</span>
<span style="color: #00A000">+        if (stream == NULL) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Unable to alloc memory\n&quot;);</span>
<span style="color: #00A000">+                return NULL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        memset(stream, 0, sizeof(audio_stream_t));</span>
<span style="color: #00A000">+        stream-&gt;next = NULL;</span>
<span style="color: #00A000">+        stream-&gt;stream = NULL;</span>
<span style="color: #00A000">+        stream-&gt;indev = indev;</span>
<span style="color: #00A000">+        stream-&gt;outdev = outdev;</span>
<span style="color: #00A000">+        if (!stream-&gt;write_timer.timer_interface) {</span>
<span style="color: #00A000">+                if (switch_core_timer_init(&amp;(stream-&gt;write_timer),</span>
<span style="color: #00A000">+                                                                   globals.timer_name, globals.codec_ms, globals.read_codec.implementation-&gt;samples_per_packet,</span>
<span style="color: #00A000">+                                                                   module_pool) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;setup timer failed!\n&quot;);</span>
<span style="color: #00A000">+                        switch_safe_free(stream);</span>
<span style="color: #00A000">+                        return NULL;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        inputParameters.device = indev;</span>
<span style="color: #00A000">+        if (indev != -1) {</span>
<span style="color: #00A000">+                inputParameters.channelCount = 1;</span>
<span style="color: #00A000">+                inputParameters.sampleFormat = SAMPLE_TYPE;</span>
<span style="color: #00A000">+                inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)-&gt;defaultLowInputLatency;</span>
<span style="color: #00A000">+                inputParameters.hostApiSpecificStreamInfo = NULL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        outputParameters.device = outdev;</span>
         outputParameters.channelCount = 1;
         outputParameters.sampleFormat = SAMPLE_TYPE;
         outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)-&gt;defaultLowOutputLatency;
         outputParameters.hostApiSpecificStreamInfo = NULL;
<span style="color: #A00000">-        //err = OpenAudioStream(&amp;globals.audio_stream, NULL/*&amp;inputParameters*/, &amp;outputParameters, sample_rate, paClipOff,</span>
<span style="color: #A00000">-        //globals.read_codec.implementation-&gt;samples_per_packet);</span>
<span style="color: #A00000">-        err = OpenAudioStream(&amp;globals.audio_stream, &amp;inputParameters, &amp;outputParameters, sample_rate, paClipOff,</span>
<span style="color: #A00000">-                                                  globals.read_codec.implementation-&gt;samples_per_packet, globals.dual_streams);</span>
<span style="color: #A00000">-        /* UNLOCKED ************************************************************************************************* */</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        err = open_audio_stream(&amp;(stream-&gt;stream), &amp;inputParameters, &amp;outputParameters);</span>
         if (err != paNoError) {
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error opening audio device retrying\n&quot;);
                 switch_yield(1000000);
<span style="color: #A00000">-                err = OpenAudioStream(&amp;globals.audio_stream, &amp;inputParameters, &amp;outputParameters, sample_rate, paClipOff,</span>
<span style="color: #A00000">-                                                          globals.read_codec.implementation-&gt;samples_per_packet, globals.dual_streams);</span>
<span style="color: #00A000">+                err = open_audio_stream(&amp;(stream-&gt;stream), &amp;inputParameters, &amp;outputParameters);</span>
         }
 
<span style="color: #A00000">-        switch_mutex_unlock(globals.device_lock);</span>
<span style="color: #A00000">-</span>
         if (err != paNoError) {
<span style="color: #00A000">+                switch_safe_free(stream);</span>
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Can&#39;t open audio device\n&quot;);
<span style="color: #A00000">-                switch_core_codec_destroy(&amp;globals.read_codec);</span>
<span style="color: #A00000">-                switch_core_codec_destroy(&amp;globals.write_codec);</span>
<span style="color: #A00000">-                switch_core_timer_destroy(&amp;globals.read_timer);</span>
<span style="color: #A00000">-                switch_core_timer_destroy(&amp;globals.write_timer);</span>
<span style="color: #A00000">-                switch_core_timer_destroy(&amp;globals.hold_timer);</span>
                 if (switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, MY_EVENT_ERROR_AUDIO_DEV) == SWITCH_STATUS_SUCCESS) {
                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Reason&quot;, Pa_GetErrorText(err));
                         switch_event_fire(&amp;event);
                 }
<span style="color: #A00000">-                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+                return NULL;</span>
         }
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Engage audio device rate: %d channels %d\n&quot;, sample_rate, outputParameters.channelCount);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        engage_ring_device();</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Created audio stream: %d channels %d\n&quot;, globals.sample_rate, outputParameters.channelCount);</span>
<span style="color: #00A000">+        return stream;</span>
 }
 
<span style="color: #A00000">-static switch_status_t engage_ring_device(void)</span>
<span style="color: #00A000">+audio_stream_t *get_audio_stream(int indev, int outdev)</span>
 {
<span style="color: #A00000">-        PaStreamParameters outputParameters = { 0 };</span>
<span style="color: #A00000">-        PaError err;</span>
<span style="color: #A00000">-        int sample_rate = globals.sample_rate;</span>
<span style="color: #A00000">-        int channels = 1;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (globals.ring_stream) {</span>
<span style="color: #A00000">-                return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+        audio_stream_t *stream;</span>
<span style="color: #00A000">+        if (outdev == -1) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error invalid output audio device\n&quot;);</span>
         }
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (globals.ringdev == globals.outdev) {</span>
<span style="color: #A00000">-                if (engage_device(0) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #A00000">-                        globals.ring_stream = globals.audio_stream;</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        goto error;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        } else {</span>
<span style="color: #A00000">-                switch_mutex_lock(globals.device_lock);</span>
<span style="color: #A00000">-                /* LOCKED ************************************************************************************************** */</span>
<span style="color: #A00000">-                outputParameters.device = globals.ringdev;</span>
<span style="color: #A00000">-                outputParameters.channelCount = channels;</span>
<span style="color: #A00000">-                outputParameters.sampleFormat = SAMPLE_TYPE;</span>
<span style="color: #A00000">-                outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)-&gt;defaultLowOutputLatency;</span>
<span style="color: #A00000">-                outputParameters.hostApiSpecificStreamInfo = NULL;</span>
<span style="color: #A00000">-                err = OpenAudioStream(&amp;globals.ring_stream, NULL,</span>
<span style="color: #A00000">-                                                          &amp;outputParameters, sample_rate, paClipOff, globals.read_codec.implementation-&gt;samples_per_packet, globals.dual_streams);</span>
<span style="color: #A00000">-                /* UNLOCKED ************************************************************************************************* */</span>
<span style="color: #A00000">-                switch_mutex_unlock(globals.device_lock);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                if (err != paNoError) {</span>
<span style="color: #A00000">-                        goto error;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #00A000">+        if (create_codecs(0) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                return NULL;</span>
         }
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        switch_yield(10000);</span>
<span style="color: #A00000">-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Engage ring device rate: %d channels %d\n&quot;, sample_rate, channels);</span>
<span style="color: #A00000">-        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-  error:</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Can&#39;t open ring device\n&quot;);</span>
<span style="color: #A00000">-        return SWITCH_STATUS_FALSE;</span>
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        stream = find_audio_stream(indev, outdev, 0);</span>
<span style="color: #00A000">+        if (stream != NULL) {</span>
<span style="color: #00A000">+                return stream;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        stream = create_audio_stream(indev, outdev);</span>
<span style="color: #00A000">+        if (stream) {</span>
<span style="color: #00A000">+                add_stream(stream, 0);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        return stream;</span>
 }
 
 static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t *stream)
<span style="color: #800080; font-weight: bold">@@ -1523,6 +1817,211 @@ static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t *</span>
         return SWITCH_STATUS_SUCCESS;
 }
 
<span style="color: #00A000">+static switch_status_t close_streams(char **argv, int argc, switch_stream_handle_t *stream)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        if (globals.call_list) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;ERROR: Cannot use this command this while a call is in progress\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        destroy_audio_streams();</span>
<span style="color: #00A000">+        stream-&gt;write_function(stream, &quot;closestreams all open streams closed\n&quot;);</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t set_indev(char **argv, int argc, switch_stream_handle_t *stream)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int devval;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (globals.call_list &amp;&amp; ! globals.live_stream_switch) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;ERROR: Cannot use this command this while a call is in progress\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (*argv[0] == &#39;#&#39;) {</span>
<span style="color: #00A000">+                devval = get_dev_by_number(argv[0] + 1, 1);</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                devval = get_dev_by_name(argv[0], 1);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (devval &lt; 0) {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;indev not set (invalid value)\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        globals.indev = devval;</span>
<span style="color: #00A000">+        switch_audio_stream();</span>
<span style="color: #00A000">+        stream-&gt;write_function(stream, &quot;indev set to %d\n&quot;, devval);</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t set_outdev(char **argv, int argc, switch_stream_handle_t *stream)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int devval;</span>
<span style="color: #00A000">+        if (globals.call_list &amp;&amp; ! globals.live_stream_switch) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;ERROR: Cannot use this command this while a call is in progress\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (*argv[0] == &#39;#&#39;) {</span>
<span style="color: #00A000">+                devval = get_dev_by_number(argv[0] + 1, 0);</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                devval = get_dev_by_name(argv[0], 0);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (devval &lt; 0) {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;outdev not set (invalid value)\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        globals.outdev = devval;</span>
<span style="color: #00A000">+        switch_audio_stream();</span>
<span style="color: #00A000">+        stream-&gt;write_function(stream, &quot;outdev set to %d\n&quot;, devval);</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t prepare_stream(char **argv, int argc, switch_stream_handle_t *stream)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int devval=-2,devval2=-1;</span>
<span style="color: #00A000">+        if (! strcmp(argv[0], &quot;#-1&quot;)) {</span>
<span style="color: #00A000">+                devval = -1;</span>
<span style="color: #00A000">+        } else if (*argv[0] == &#39;#&#39;) {</span>
<span style="color: #00A000">+                devval = get_dev_by_number(argv[0]+1, 1);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (devval == -2) {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;preparestream not prepared as indev has (invalid value)\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (*argv[1] == &#39;#&#39;) {</span>
<span style="color: #00A000">+                devval2 = get_dev_by_number(argv[1]+1, 0);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (devval2 == -1) {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;preparestream not prepared as outdev has (invalid value)\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (! get_audio_stream(devval,devval2)) {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;preparestream not prepared received an invalid stream back\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        stream-&gt;write_function(stream, &quot;preparestream prepared indev: %d outdev: %d\n&quot;, devval, devval2);</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t switch_stream(char **argv, int argc, switch_stream_handle_t *stream)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int devval =-1, devval2 = -1;</span>
<span style="color: #00A000">+        if (globals.call_list &amp;&amp; ! globals.live_stream_switch) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;ERROR: Cannot use this command this while a call is in progress\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (*argv[0] == &#39;#&#39;) {</span>
<span style="color: #00A000">+                devval = get_dev_by_number(argv[0]+1, 1);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (devval == -1) {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;switchstream not prepared as indev has (invalid value)\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (*argv[1] == &#39;#&#39;) {</span>
<span style="color: #00A000">+                devval2 = get_dev_by_number(argv[1]+1, 0);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (devval2 == -1) {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;switchstream not prepared as outdev has (invalid value)\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        globals.indev = devval;</span>
<span style="color: #00A000">+        globals.outdev = devval2;</span>
<span style="color: #00A000">+        if (switch_audio_stream() != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;switchstream was unable to switch\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        stream-&gt;write_function(stream, &quot;switchstream switched to indev: %d outdev: %d\n&quot;, devval, devval2);</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t set_ringdev(char **argv, int argc, switch_stream_handle_t *stream)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int devval;</span>
<span style="color: #00A000">+        if (globals.call_list &amp;&amp; ! globals.live_stream_switch) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;ERROR: Cannot use this command this while a call is in progress\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (! strcmp(argv[0], &quot;#-1&quot;)) {</span>
<span style="color: #00A000">+                globals.ring_stream = NULL;</span>
<span style="color: #00A000">+                globals.ringdev = -1;</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;ringdev set to %d\n&quot;, globals.ringdev);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+        } else if (*argv[0] == &#39;#&#39;) {</span>
<span style="color: #00A000">+                devval = get_dev_by_number(argv[0] + 1, 0);</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                devval = get_dev_by_name(argv[0], 0);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (devval == -1) {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;ringdev not set as dev has (invalid value)\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        globals.ringdev = devval;</span>
<span style="color: #00A000">+        stream-&gt;write_function(stream, &quot;ringdev set to %d\n&quot;, globals.ringdev);</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t looptest(char **argv, int argc, switch_stream_handle_t *stream)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int samples = 0;</span>
<span style="color: #00A000">+        int success = 0;</span>
<span style="color: #00A000">+        int i;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (globals.call_list) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;ERROR: Cannot use this command this while a call is in progress\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (validate_main_audio_stream() != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;looptest Failed to engage audio device\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        globals.stream_in_use = 1;</span>
<span style="color: #00A000">+        for (i = 0; i &lt; 400; i++) {</span>
<span style="color: #00A000">+                if (globals.destroying_streams ||  ! globals.main_stream-&gt;stream) {</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                if ((samples = ReadAudioStream(globals.main_stream-&gt;stream, globals.read_frame.data, globals.read_codec.implementation-&gt;samples_per_packet, &amp;globals.read_timer))) {</span>
<span style="color: #00A000">+                        WriteAudioStream(globals.main_stream-&gt;stream, globals.read_frame.data, (long) samples, &amp;(globals.main_stream-&gt;write_timer));</span>
<span style="color: #00A000">+                        success = 1;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                switch_yield(10000);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        globals.stream_in_use = 0;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (!success) {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;Failed to read any bytes from indev\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        destroy_audio_streams();</span>
<span style="color: #00A000">+        stream-&gt;write_function(stream, &quot;looptest complete\n&quot;);</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t set_ringfile(char **argv, int argc, switch_stream_handle_t *stream)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        if (! argv[0]) {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;%s&quot;, globals.ring_file);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (create_codecs(0) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                switch_file_handle_t fh = { 0 };</span>
<span style="color: #00A000">+                if (switch_core_file_open(&amp;fh,</span>
<span style="color: #00A000">+                                                                  argv[0],</span>
<span style="color: #00A000">+                                                                  globals.read_codec.implementation-&gt;number_of_channels,</span>
<span style="color: #00A000">+                                                                  globals.read_codec.implementation-&gt;actual_samples_per_second,</span>
<span style="color: #00A000">+                                                                  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                        switch_core_file_close(&amp;fh);</span>
<span style="color: #00A000">+                        set_global_ring_file(argv[0]);</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        stream-&gt;write_function(stream, &quot;ringfile Unable to open ring file %s\n&quot;, argv[0]);</span>
<span style="color: #00A000">+                        return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;ringfile Failed to init codecs device\n&quot;);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        stream-&gt;write_function(stream, &quot;ringfile set to %s&quot;, globals.ring_file);</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
 static switch_status_t switch_call(char **argv, int argc, switch_stream_handle_t *stream)
 {
         private_t *tp, *tech_pvt = NULL;
<span style="color: #800080; font-weight: bold">@@ -1542,7 +2041,10 @@ static switch_status_t switch_call(char **argv, int argc, switch_stream_handle_t</span>
                 }
         } else if (!strcasecmp(callid, &quot;none&quot;)) {
                 for (tp = globals.call_list; tp; tp = tp-&gt;next) {
<span style="color: #00A000">+                        if (switch_test_flag(tp, TFLAG_MASTER))        {</span>
                         switch_clear_flag_locked(tp, TFLAG_MASTER);
<span style="color: #00A000">+                                create_hold_event(tp,0);</span>
<span style="color: #00A000">+                        }</span>
                 }
                 stream-&gt;write_function(stream, &quot;OK\n&quot;);
                 goto done;
<span style="color: #800080; font-weight: bold">@@ -1559,6 +2061,7 @@ static switch_status_t switch_call(char **argv, int argc, switch_stream_handle_t</span>
                         remove_pvt(tech_pvt);
                 }
                 add_pvt(tech_pvt, PA_MASTER);
<span style="color: #00A000">+                create_hold_event(tech_pvt, 1);</span>
                 stream-&gt;write_function(stream, &quot;OK\n&quot;);
         } else {
                 stream-&gt;write_function(stream, &quot;NO SUCH CALL\n&quot;);
<span style="color: #800080; font-weight: bold">@@ -1609,7 +2112,6 @@ static switch_status_t answer_call(char **argv, int argc, switch_stream_handle_t</span>
                                 switch_channel_t *channel = switch_core_session_get_channel(tp-&gt;session);
                                 switch_set_flag_locked(tp, TFLAG_ANSWER);
                                 add_pvt(tp, PA_MASTER);
<span style="color: #A00000">-                                deactivate_ring_device();</span>
                                 switch_channel_mark_answered(channel);
                         }
                 } else {
<span style="color: #800080; font-weight: bold">@@ -1624,7 +2126,6 @@ static switch_status_t answer_call(char **argv, int argc, switch_stream_handle_t</span>
                         switch_channel_t *channel = switch_core_session_get_channel(tp-&gt;session);
                         switch_set_flag_locked(tp, TFLAG_ANSWER);
                         add_pvt(tp, PA_MASTER);
<span style="color: #A00000">-                        deactivate_ring_device();</span>
                         switch_channel_mark_answered(channel);
                         x++;
                         break;
<span style="color: #800080; font-weight: bold">@@ -1766,7 +2267,6 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t</span>
                         channel = switch_core_session_get_channel(session);
                         switch_core_session_set_private(session, tech_pvt);
                         tech_pvt-&gt;session = session;
<span style="color: #A00000">-                        globals.flags = GFLAG_EAR | GFLAG_MOUTH;</span>
                 } else {
                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, &quot;Hey where is my memory pool?\n&quot;);
                         switch_core_session_destroy(&amp;session);
<span style="color: #800080; font-weight: bold">@@ -1805,9 +2305,8 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t</span>
                         switch_channel_set_caller_profile(channel, tech_pvt-&gt;caller_profile);
                 }
                 tech_pvt-&gt;session = session;
<span style="color: #A00000">-                if ((status = engage_device(0)) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                if ((status = validate_main_audio_stream()) == SWITCH_STATUS_SUCCESS) {</span>
                         switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
<span style="color: #A00000">-                        deactivate_ring_device();</span>
                         switch_channel_mark_answered(channel);
                         switch_channel_set_state(channel, CS_INIT);
                         if (switch_core_session_thread_launch(tech_pvt-&gt;session) != SWITCH_STATUS_SUCCESS) {
<span style="color: #800080; font-weight: bold">@@ -1855,10 +2354,11 @@ SWITCH_STANDARD_API(pa_cmd)</span>
 {
         char *argv[1024] = { 0 };
         int argc = 0;
<span style="color: #A00000">-        char *mycmd = NULL, *devname = NULL;</span>
<span style="color: #00A000">+        char *mycmd = NULL;</span>
         switch_status_t status = SWITCH_STATUS_SUCCESS;
         pa_command_t func = NULL;
<span style="color: #A00000">-        int lead = 1, devval = 0;</span>
<span style="color: #00A000">+        int devval;</span>
<span style="color: #00A000">+        int lead = 1;</span>
         char *wcmd = NULL, *action = NULL;
         char cmd_buf[1024] = &quot;&quot;;
         char *http = NULL;
<span style="color: #800080; font-weight: bold">@@ -1878,9 +2378,15 @@ SWITCH_STANDARD_API(pa_cmd)</span>
                 &quot;pa devlist [xml]\n&quot;
                 &quot;pa indev #&lt;num&gt;|&lt;partial name&gt;\n&quot;
                 &quot;pa outdev #&lt;num&gt;|&lt;partial name&gt;\n&quot;
<span style="color: #00A000">+                &quot;pa preparestream #&lt;indev_num&gt; #&lt;outdev_num&gt;\n&quot;</span>
<span style="color: #00A000">+                &quot;pa switchstream #&lt;indev_num&gt; #&lt;outdev_num&gt;\n&quot;</span>
<span style="color: #00A000">+                &quot;pa closestreams\n&quot;</span>
                 &quot;pa ringdev #&lt;num&gt;|&lt;partial name&gt;\n&quot;
<span style="color: #A00000">-                &quot;pa play [ringtest|&lt;filename&gt;]\n&quot;</span>
<span style="color: #A00000">-                &quot;pa ringfile [filename]\n&quot; &quot;pa looptest\n&quot; &quot;--------------------------------------------------------------------------------\n&quot;;</span>
<span style="color: #00A000">+                &quot;pa play [ringtest|&lt;filename&gt;] [seconds] [no_close]\n&quot;</span>
<span style="color: #00A000">+                &quot;pa playdev #&lt;num&gt; [ringtest|&lt;filename&gt;] [seconds] [no_close]\n&quot;</span>
<span style="color: #00A000">+                &quot;pa ringfile [filename]\n&quot;</span>
<span style="color: #00A000">+                &quot;pa looptest\n&quot;</span>
<span style="color: #00A000">+                &quot;--------------------------------------------------------------------------------\n&quot;;</span>
 
 
         if (stream-&gt;param_event) {
<span style="color: #800080; font-weight: bold">@@ -1973,169 +2479,42 @@ SWITCH_STANDARD_API(pa_cmd)</span>
                 func = switch_call;
         } else if (!strcasecmp(argv[0], &quot;dtmf&quot;)) {
                 func = dtmf_call;
<span style="color: #00A000">+        } else if (!strcasecmp(argv[0], &quot;closestreams&quot;)) {</span>
<span style="color: #00A000">+                func = close_streams;</span>
         } else if (argv[1] &amp;&amp; !strcmp(argv[0], &quot;indev&quot;)) {
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                if (globals.call_list) {</span>
<span style="color: #A00000">-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;ERROR: Cannot use this command this while a call is in progress\n&quot;);</span>
<span style="color: #A00000">-                        goto done;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                if (*argv[1] == &#39;#&#39;) {</span>
<span style="color: #A00000">-                        devval = get_dev_by_number(argv[1] + 1, 1);</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        devval = get_dev_by_name(argv[1], 1);</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                devname = &quot;indev&quot;;</span>
<span style="color: #A00000">-                if (devval &gt; -1) {</span>
<span style="color: #A00000">-                        globals.indev = devval;</span>
<span style="color: #A00000">-                        //engage_device(1);</span>
<span style="color: #A00000">-                }</span>
<span style="color: #00A000">+                func = set_indev;</span>
         } else if (argv[1] &amp;&amp; !strcmp(argv[0], &quot;outdev&quot;)) {
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                if (globals.call_list) {</span>
<span style="color: #A00000">-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;ERROR: Cannot use this command this while a call is in progress\n&quot;);</span>
<span style="color: #A00000">-                        goto done;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                if (*argv[1] == &#39;#&#39;) {</span>
<span style="color: #A00000">-                        devval = get_dev_by_number(argv[1] + 1, 0);</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        devval = get_dev_by_name(argv[1], 0);</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                devname = &quot;outdev&quot;;</span>
<span style="color: #A00000">-                if (devval &gt; -1) {</span>
<span style="color: #A00000">-                        globals.outdev = devval;</span>
<span style="color: #A00000">-                        //engage_device(1);</span>
<span style="color: #A00000">-                }</span>
<span style="color: #00A000">+                func = set_outdev;</span>
<span style="color: #00A000">+        } else if (argv[1] &amp;&amp; argv[2] &amp;&amp; !strcmp(argv[0], &quot;preparestream&quot;)) {</span>
<span style="color: #00A000">+                func = prepare_stream;        </span>
<span style="color: #00A000">+        } else if (argv[1] &amp;&amp; argv[2] &amp;&amp; !strcmp(argv[0], &quot;switchstream&quot;)) {</span>
<span style="color: #00A000">+                func = switch_stream;        </span>
         } else if (argv[1] &amp;&amp; !strcmp(argv[0], &quot;ringdev&quot;)) {
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                if (globals.call_list) {</span>
<span style="color: #A00000">-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;ERROR: Cannot use this command this while a call is in progress\n&quot;);</span>
<span style="color: #A00000">-                        goto done;</span>
<span style="color: #00A000">+                func = set_ringdev;</span>
<span style="color: #00A000">+        } else if ((argv[1] &amp;&amp; !strcmp(argv[0], &quot;play&quot;))) {</span>
<span style="color: #00A000">+                if (validate_main_audio_stream() == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                        play_dev(stream, globals.main_stream ? globals.main_stream-&gt;outdev : -1,argv[1],argv[2], argv[3]);</span>
<span style="color: #00A000">+                }else{</span>
<span style="color: #00A000">+                        stream-&gt;write_function(stream, &quot;Failed to engage audio device\n&quot;);</span>
                 }
<span style="color: #A00000">-</span>
<span style="color: #00A000">+                goto done;</span>
<span style="color: #00A000">+        } else if ((argv[1] &amp;&amp; argv[2] &amp;&amp; !strcmp(argv[0], &quot;playdev&quot;))) {</span>
                 if (*argv[1] == &#39;#&#39;) {
                         devval = get_dev_by_number(argv[1] + 1, 0);
                 } else {
<span style="color: #A00000">-                        devval = get_dev_by_name(argv[1], 0);</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                devname = &quot;ringdev&quot;;</span>
<span style="color: #A00000">-                if (devval &gt; -1) {</span>
<span style="color: #A00000">-                        globals.ringdev = devval;</span>
<span style="color: #A00000">-                        //engage_device(1);</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        } else if ((argv[1] &amp;&amp; !strcasecmp(argv[0], &quot;play&quot;))) {</span>
<span style="color: #A00000">-                switch_file_handle_t fh = { 0 };</span>
<span style="color: #A00000">-                char *playfile = NULL;</span>
<span style="color: #A00000">-                int samples = 0;</span>
<span style="color: #A00000">-                int seconds = 5;</span>
<span style="color: #A00000">-                int wrote = 0;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                if (globals.call_list) {</span>
<span style="color: #A00000">-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;ERROR: Cannot use this command this while a call is in progress\n&quot;);</span>
<span style="color: #A00000">-                        goto done;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                if (!strcasecmp(argv[1], &quot;ringtest&quot;)) {</span>
<span style="color: #A00000">-                        playfile = globals.ring_file;</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        playfile = argv[1];</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                fh.pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN;</span>
<span style="color: #A00000">-                if (engage_device(0) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #A00000">-                        if (switch_core_file_open(&amp;fh,</span>
<span style="color: #A00000">-                                                                          playfile,</span>
<span style="color: #A00000">-                                                                          globals.read_codec.implementation-&gt;number_of_channels,</span>
<span style="color: #A00000">-                                                                          globals.read_codec.implementation-&gt;actual_samples_per_second,</span>
<span style="color: #A00000">-                                                                          SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #A00000">-                                switch_size_t olen = globals.read_codec.implementation-&gt;samples_per_packet;</span>
<span style="color: #A00000">-                                int16_t abuf[2048];</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                if (argv[2]) {</span>
<span style="color: #A00000">-                                        int i = atoi(argv[2]);</span>
<span style="color: #A00000">-                                        if (i &gt;= 0) {</span>
<span style="color: #A00000">-                                                seconds = i;</span>
<span style="color: #A00000">-                                        }</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                samples = globals.read_codec.implementation-&gt;actual_samples_per_second * seconds;</span>
<span style="color: #A00000">-                                while (switch_core_file_read(&amp;fh, abuf, &amp;olen) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #A00000">-                                        WriteAudioStream(globals.audio_stream, abuf, (long) olen, &amp;globals.read_timer);</span>
<span style="color: #A00000">-                                        wrote += (int) olen;</span>
<span style="color: #A00000">-                                        if (samples) {</span>
<span style="color: #A00000">-                                                samples -= (int) olen;</span>
<span style="color: #A00000">-                                                if (samples &lt;= 0) {</span>
<span style="color: #A00000">-                                                        break;</span>
<span style="color: #A00000">-                                                }</span>
<span style="color: #A00000">-                                        }</span>
<span style="color: #A00000">-                                        olen = globals.read_codec.implementation-&gt;samples_per_packet;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                switch_core_file_close(&amp;fh);</span>
<span style="color: #A00000">-                                deactivate_audio_device();</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                seconds = wrote / globals.read_codec.implementation-&gt;actual_samples_per_second;</span>
<span style="color: #A00000">-                                stream-&gt;write_function(stream, &quot;playback test [%s] %d second(s) %d samples @%dkhz&quot;,</span>
<span style="color: #A00000">-                                                                           playfile, seconds, wrote, globals.read_codec.implementation-&gt;actual_samples_per_second);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                stream-&gt;write_function(stream, &quot;Cannot play requested file %s\n&quot;, argv[1]);</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        stream-&gt;write_function(stream, &quot;Failed to engage audio device\n&quot;);</span>
<span style="color: #00A000">+                        devval = -1;</span>
                 }
<span style="color: #00A000">+                play_dev(stream, devval,argv[2],argv[3],argv[4]);</span>
                 goto done;
         } else if (!strcasecmp(argv[0], &quot;looptest&quot;)) {
<span style="color: #A00000">-                if (globals.call_list) {</span>
<span style="color: #A00000">-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;ERROR: Cannot use this command this while a call is in progress\n&quot;);</span>
<span style="color: #A00000">-                        goto done;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                if (engage_device(0) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #A00000">-                        int samples = 0;</span>
<span style="color: #A00000">-                        int success = 0;</span>
<span style="color: #A00000">-                        int i;</span>
<span style="color: #A00000">-                        for (i = 0; i &lt; 400; i++) {</span>
<span style="color: #A00000">-                                if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data,</span>
<span style="color: #A00000">-                                                                                           globals.read_codec.implementation-&gt;samples_per_packet, &amp;globals.read_timer))) {</span>
<span style="color: #A00000">-                                        WriteAudioStream(globals.audio_stream, globals.read_frame.data, (long) samples, &amp;globals.write_timer);</span>
<span style="color: #A00000">-                                        success = 1;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                switch_yield(10000);</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                        if (!success) {</span>
<span style="color: #A00000">-                                stream-&gt;write_function(stream, &quot;Failed to read any bytes from indev\n&quot;);</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                        deactivate_audio_device();</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        stream-&gt;write_function(stream, &quot;Failed to engage audio device\n&quot;);</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                goto done;</span>
<span style="color: #00A000">+                func = looptest;</span>
         } else if (!strcasecmp(argv[0], &quot;ringfile&quot;)) {
<span style="color: #A00000">-                if (argv[1]) {</span>
<span style="color: #A00000">-                        if (engage_device(0) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #A00000">-                                switch_file_handle_t fh = { 0 };</span>
<span style="color: #A00000">-                                if (switch_core_file_open(&amp;fh,</span>
<span style="color: #A00000">-                                                                                  argv[1],</span>
<span style="color: #A00000">-                                                                                  globals.read_codec.implementation-&gt;number_of_channels,</span>
<span style="color: #A00000">-                                                                                  globals.read_codec.implementation-&gt;actual_samples_per_second,</span>
<span style="color: #A00000">-                                                                                  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #A00000">-                                        switch_core_file_close(&amp;fh);</span>
<span style="color: #A00000">-                                        set_global_ring_file(argv[1]);</span>
<span style="color: #A00000">-                                } else {</span>
<span style="color: #A00000">-                                        stream-&gt;write_function(stream, &quot;Unable to open ring file %s\n&quot;, argv[1]);</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                stream-&gt;write_function(stream, &quot;Failed to engage audio device\n&quot;);</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        stream-&gt;write_function(stream, &quot;%s&quot;, globals.ring_file);</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                goto done;</span>
<span style="color: #00A000">+                func = set_ringfile;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;Unknown Command or not enough args [%s]\n&quot;, argv[0]);</span>
         }
 
<span style="color: #00A000">+</span>
         if (func) {
                 if (http) {
                         stream-&gt;write_function(stream, &quot;&lt;pre&gt;&quot;);
<span style="color: #800080; font-weight: bold">@@ -2143,21 +2522,12 @@ SWITCH_STANDARD_API(pa_cmd)</span>
 
                 switch_mutex_lock(globals.pa_mutex);
                 status = func(&amp;argv[lead], argc - lead, stream);
<span style="color: #00A000">+                status = SWITCH_STATUS_SUCCESS; /*if func was defined we want to always return success as the command was found */</span>
                 switch_mutex_unlock(globals.pa_mutex);
 
                 if (http) {
                         stream-&gt;write_function(stream, &quot;\n\n&lt;/pre&gt;&quot;);
                 }
<span style="color: #A00000">-        } else {</span>
<span style="color: #A00000">-                if (devname) {</span>
<span style="color: #A00000">-                        if (devval &gt; -1) {</span>
<span style="color: #A00000">-                                stream-&gt;write_function(stream, &quot;%s set to %d\n&quot;, devname, devval);</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                stream-&gt;write_function(stream, &quot;%s not set (invalid value)\n&quot;, devname);</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        stream-&gt;write_function(stream, &quot;Unknown Command [%s]\n&quot;, argv[0]);</span>
<span style="color: #A00000">-                }</span>
         }
 
   done:
<span style="color: #800080; font-weight: bold">@@ -2171,6 +2541,14 @@ SWITCH_STANDARD_API(pa_cmd)</span>
                                                            &quot;&lt;input name=action type=submit value=\&quot;switch\&quot;&gt; &quot;
                                                            &quot;&lt;input name=action type=submit value=\&quot;mute\&quot;&gt; &quot;
                                                            &quot;&lt;input name=action type=submit value=\&quot;unmute\&quot;&gt; &quot;
<span style="color: #00A000">+                                                           &quot;&lt;input name=action type=submit value=\&quot;indev\&quot;&gt; &quot;</span>
<span style="color: #00A000">+                                                           &quot;&lt;input name=action type=submit value=\&quot;outdev\&quot;&gt; &quot;</span>
<span style="color: #00A000">+                                                           &quot;&lt;input name=action type=submit value=\&quot;preparestream\&quot;&gt; &quot;</span>
<span style="color: #00A000">+                                                           &quot;&lt;input name=action type=submit value=\&quot;switchstream\&quot;&gt; &quot;</span>
<span style="color: #00A000">+                                                           &quot;&lt;input name=action type=submit value=\&quot;closestreams\&quot;&gt; &quot;</span>
<span style="color: #00A000">+                                                           &quot;&lt;input name=action type=submit value=\&quot;ringdev\&quot;&gt; &quot;</span>
<span style="color: #00A000">+                                                           &quot;&lt;input name=action type=submit value=\&quot;play\&quot;&gt; &quot;</span>
<span style="color: #00A000">+                                                           &quot;&lt;input name=action type=submit value=\&quot;playdev\&quot;&gt; &quot;</span>
                                                            &quot;&lt;input name=action type=submit value=\&quot;answer\&quot;&gt; &lt;br&gt;&lt;br&gt;&quot;
                                                            &quot;&lt;table border=1&gt;\n&quot;
                                                            &quot;&lt;tr&gt;&lt;td&gt;&lt;input name=action type=submit value=\&quot;1\&quot;&gt;&lt;/td&gt;&quot;
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
try to improve iLBC compat

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c</span>
<span style="color: #000080; font-weight: bold">index 8b2f470..a0b7fca 100644</span>
<span style="color: #A00000">--- a/src/mod/endpoints/mod_sofia/sofia_glue.c</span>
<span style="color: #00A000">+++ b/src/mod/endpoints/mod_sofia/sofia_glue.c</span>
<span style="color: #800080; font-weight: bold">@@ -4480,7 +4480,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s</span>
                                                 match = strcasecmp(rm_encoding, imp-&gt;iananame) ? 0 : 1;
                                         }
 
<span style="color: #A00000">-                                        if (match &amp;&amp; bit_rate &amp;&amp; map_bit_rate &amp;&amp; map_bit_rate != bit_rate) {</span>
<span style="color: #00A000">+                                        if (match &amp;&amp; bit_rate &amp;&amp; map_bit_rate &amp;&amp; map_bit_rate != bit_rate &amp;&amp; strcasecmp(map-&gt;rm_encoding, &quot;ilbc&quot;)) {</span>
                                                 /* nevermind */
                                                 match = 0;
                                         }
<span style="color: #000080; font-weight: bold">diff --git a/src/switch_core.c b/src/switch_core.c</span>
<span style="color: #000080; font-weight: bold">index 8754305..0eb51cc 100644</span>
<span style="color: #A00000">--- a/src/switch_core.c</span>
<span style="color: #00A000">+++ b/src/switch_core.c</span>
<span style="color: #800080; font-weight: bold">@@ -1486,7 +1486,7 @@ static void switch_load_core_config(const char *file)</span>
 {
         switch_xml_t xml = NULL, cfg = NULL;
 
<span style="color: #A00000">-        //switch_core_hash_insert(runtime.ptimes, &quot;ilbc&quot;, &amp;d_30);</span>
<span style="color: #00A000">+        switch_core_hash_insert(runtime.ptimes, &quot;ilbc&quot;, &amp;d_30);</span>
         switch_core_hash_insert(runtime.ptimes, &quot;G723&quot;, &amp;d_30);
 
         if ((xml = switch_xml_open_cfg(file, &amp;cfg, NULL))) {
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
doh regression

<span style="color: #000080; font-weight: bold">diff --git a/src/switch_event.c b/src/switch_event.c</span>
<span style="color: #000080; font-weight: bold">index 3e12ea1..b626d5b 100644</span>
<span style="color: #A00000">--- a/src/switch_event.c</span>
<span style="color: #00A000">+++ b/src/switch_event.c</span>
<span style="color: #800080; font-weight: bold">@@ -1561,6 +1561,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const</span>
         char *cloned_sub_val = NULL;
         char *func_val = NULL;
         int nv = 0;
<span style="color: #00A000">+        char *gvar = NULL;</span>
 
         nv = switch_string_var_check_const(in) || switch_string_has_escaped_data(in);
 
<span style="color: #800080; font-weight: bold">@@ -1673,7 +1674,6 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const</span>
                                         int offset = 0;
                                         int ooffset = 0;
                                         char *ptr;
<span style="color: #A00000">-                                        char *gvar = NULL;</span>
 
                                         if ((expanded = switch_event_expand_headers(event, (char *) vname)) == vname) {
                                                 expanded = NULL;
<span style="color: #800080; font-weight: bold">@@ -1690,6 +1690,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const</span>
                                         }
 
                                         if (!(sub_val = switch_event_get_header(event, vname))) {
<span style="color: #00A000">+                                                switch_safe_free(gvar);</span>
                                                 if ((gvar = switch_core_get_variable_dup(vname))) {
                                                         sub_val = gvar;
                                                 }
<span style="color: #800080; font-weight: bold">@@ -1713,7 +1714,6 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const</span>
                                                 }
                                         }
 
<span style="color: #A00000">-                                        switch_safe_free(gvar);</span>
                                         switch_safe_free(expanded);
                                 } else {
                                         switch_stream_handle_t stream = { 0 };
<span style="color: #800080; font-weight: bold">@@ -1789,6 +1789,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const</span>
                 }
         }
         free(indup);
<span style="color: #00A000">+        switch_safe_free(gvar);</span>
 
         return data;
 }
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
FS-3027

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c</span>
<span style="color: #000080; font-weight: bold">index dfd6a76..8b2f470 100644</span>
<span style="color: #A00000">--- a/src/mod/endpoints/mod_sofia/sofia_glue.c</span>
<span style="color: #00A000">+++ b/src/mod/endpoints/mod_sofia/sofia_glue.c</span>
<span style="color: #800080; font-weight: bold">@@ -4071,15 +4071,22 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s</span>
         greedy = !!sofia_test_pflag(tech_pvt-&gt;profile, PFLAG_GREEDY);
         scrooge = !!sofia_test_pflag(tech_pvt-&gt;profile, PFLAG_SCROOGE);
 
<span style="color: #A00000">-        if (!greedy || !scrooge) {</span>
<span style="color: #A00000">-                if ((val = switch_channel_get_variable(channel, &quot;sip_codec_negotiation&quot;))) {</span>
<span style="color: #A00000">-                        if (!strcasecmp(val, &quot;greedy&quot;)) {</span>
<span style="color: #A00000">-                                greedy = 1;</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(val, &quot;scrooge&quot;)) {</span>
<span style="color: #A00000">-                                scrooge = 1;</span>
<span style="color: #A00000">-                                greedy = 1;</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                }</span>
<span style="color: #00A000">+        if ((val = switch_channel_get_variable(channel, &quot;sip_codec_negotiation&quot;))) {</span>
<span style="color: #00A000">+                if (!strcasecmp(val, &quot;generous&quot;)) {</span>
<span style="color: #00A000">+                        greedy = 0;</span>
<span style="color: #00A000">+                        scrooge = 0;</span>
<span style="color: #00A000">+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;sip_codec_negotiation overriding sofia inbound-codec-negotiation : generous\n&quot; );</span>
<span style="color: #00A000">+                } else if (!strcasecmp(val, &quot;greedy&quot;)) {</span>
<span style="color: #00A000">+                        greedy = 1;</span>
<span style="color: #00A000">+                        scrooge = 0;</span>
<span style="color: #00A000">+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;sip_codec_negotiation overriding sofia inbound-codec-negotiation : greedy\n&quot; );</span>
<span style="color: #00A000">+                } else if (!strcasecmp(val, &quot;scrooge&quot;)) {</span>
<span style="color: #00A000">+                        scrooge = 1;</span>
<span style="color: #00A000">+                        greedy = 1;</span>
<span style="color: #00A000">+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;sip_codec_negotiation overriding sofia inbound-codec-negotiation : scrooge\n&quot; );</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;sip_codec_negotiation ignored invalid value : &#39;%s&#39; \n&quot;, val );        </span>
<span style="color: #00A000">+                }                </span>
         }
 
         if ((tech_pvt-&gt;origin = switch_core_session_strdup(session, (char *) sdp-&gt;sdp_origin-&gt;o_username))) {
</pre></div>
<div class="highlight"><pre>committer: Jeff Lenk
comments: 
VS2010 fix minor build order problem

<span style="color: #000080; font-weight: bold">diff --git a/libs/win32/sofia/libsofia_sip_ua_static.2010.vcxproj b/libs/win32/sofia/libsofia_sip_ua_static.2010.vcxproj</span>
<span style="color: #000080; font-weight: bold">index d841b89..be91504 100644</span>
<span style="color: #A00000">--- a/libs/win32/sofia/libsofia_sip_ua_static.2010.vcxproj</span>
<span style="color: #00A000">+++ b/libs/win32/sofia/libsofia_sip_ua_static.2010.vcxproj</span>
<span style="color: #800080; font-weight: bold">@@ -508,6 +508,12 @@ if not exist &quot;$(ProjectDir)$(IntDir)\auth_client.obj&quot; &quot;autogen.cmd&quot;</span>
       &lt;Project&gt;{8b3b4c4c-13c2-446c-beb0-f412cc2cfb9a}&lt;/Project&gt;
       &lt;ReferenceOutputAssembly&gt;false&lt;/ReferenceOutputAssembly&gt;
     &lt;/ProjectReference&gt;
<span style="color: #00A000">+    &lt;ProjectReference Include=&quot;..\openssl\libeay32.2010.vcxproj&quot;&gt;</span>
<span style="color: #00A000">+      &lt;Project&gt;{d331904d-a00a-4694-a5a3-fcff64ab5dbe}&lt;/Project&gt;</span>
<span style="color: #00A000">+    &lt;/ProjectReference&gt;</span>
<span style="color: #00A000">+    &lt;ProjectReference Include=&quot;..\openssl\ssleay32.2010.vcxproj&quot;&gt;</span>
<span style="color: #00A000">+      &lt;Project&gt;{b4b62169-5ad4-4559-8707-3d933ac5db39}&lt;/Project&gt;</span>
<span style="color: #00A000">+    &lt;/ProjectReference&gt;</span>
     &lt;ProjectReference Include=&quot;..\pthread\pthread.2010.vcxproj&quot;&gt;
       &lt;Project&gt;{df018947-0fff-4eb3-bdee-441dc81da7a4}&lt;/Project&gt;
       &lt;ReferenceOutputAssembly&gt;false&lt;/ReferenceOutputAssembly&gt;
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
fix possible bad pointer in global vars (please test)

<span style="color: #000080; font-weight: bold">diff --git a/fscomm/widgets/codecwidget.cpp b/fscomm/widgets/codecwidget.cpp</span>
<span style="color: #000080; font-weight: bold">index 42b10fe..2f82e1a 100644</span>
<span style="color: #A00000">--- a/fscomm/widgets/codecwidget.cpp</span>
<span style="color: #00A000">+++ b/fscomm/widgets/codecwidget.cpp</span>
<span style="color: #800080; font-weight: bold">@@ -131,6 +131,8 @@ void CodecWidget::setCodecString(QString codecList)</span>
         QStringList parsed = codecList.split(&quot;{&quot;);
         QString var = parsed.at(1);
         var = var.split(&quot;}&quot;).at(0);
<span style="color: #00A000">+                // warning switch_core_get_Variable may return an unsafe pointer in some cases.</span>
<span style="color: #00A000">+                // revise to use switch_core_get_variable_dup, and then free it after you are done.</span>
         var = switch_core_get_variable(var.toAscii().data());
         if ( ! var.isEmpty() ) {
             codecList = var;
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
only pass publish on when you have a subscription

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c</span>
<span style="color: #000080; font-weight: bold">index 19125c6..a38a61e 100644</span>
<span style="color: #A00000">--- a/src/mod/endpoints/mod_sofia/sofia_presence.c</span>
<span style="color: #00A000">+++ b/src/mod/endpoints/mod_sofia/sofia_presence.c</span>
<span style="color: #800080; font-weight: bold">@@ -2570,6 +2570,19 @@ static int sofia_counterpath_crutch(void *pArg, int argc, char **argv, char **co</span>
         return 0;
 }
 
<span style="color: #00A000">+</span>
<span style="color: #00A000">+uint32_t sofia_presence_contact_count(sofia_profile_t *profile, const char *contact_str)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        char buf[32] = &quot;&quot;;</span>
<span style="color: #00A000">+        char *sql;</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        sql = switch_mprintf(&quot;select count(*) from sip_subscriptions where profile_name=&#39;%q&#39; and contact_str=&#39;%q&#39;&quot;, profile-&gt;name, contact_str);</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        sofia_glue_execute_sql2str(profile, profile-&gt;ireg_mutex, sql, buf, sizeof(buf));</span>
<span style="color: #00A000">+        switch_safe_free(sql);</span>
<span style="color: #00A000">+        return atoi(buf);                                </span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
 void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
                                                                                  tagi_t tags[])
 {
<span style="color: #800080; font-weight: bold">@@ -2584,7 +2597,7 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n</span>
         char expstr[30] = &quot;&quot;;
         long exp = 0, exp_delta = 3600;
         char *pd_dup = NULL;
<span style="color: #A00000">-        int count = 1;</span>
<span style="color: #00A000">+        int count = 1, sub_count = 0;</span>
         char *contact_str;
         int open = 1;
 
<span style="color: #800080; font-weight: bold">@@ -2667,24 +2680,25 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n</span>
                                 count = sofia_reg_reg_count(profile, from_user, from_host);
                         }
                                 
<span style="color: #00A000">+                        sub_count = sofia_presence_contact_count(profile, contact_str);</span>
 
                         /* if (count &gt; 1) let&#39;s not and say we did or all the clients who subscribe to their own presence will think they selves is offline */
 
                         event_type = sip_header_as_string(profile-&gt;home, (void *) sip-&gt;sip_event);
 
                         if (count &lt; 2) {
<span style="color: #A00000">-                                if ((sql =</span>
<span style="color: #A00000">-                                         switch_mprintf(&quot;delete from sip_presence where sip_user=&#39;%q&#39; and sip_host=&#39;%q&#39; &quot;</span>
<span style="color: #A00000">-                                                                        &quot; and profile_name=&#39;%q&#39; and hostname=&#39;%q&#39;&quot;, from_user, from_host, profile-&gt;name, mod_sofia_globals.hostname))) {</span>
<span style="color: #00A000">+                                if ((sql = switch_mprintf(&quot;delete from sip_presence where sip_user=&#39;%q&#39; and sip_host=&#39;%q&#39; &quot;</span>
<span style="color: #00A000">+                                                                                  &quot; and profile_name=&#39;%q&#39; and hostname=&#39;%q&#39;&quot;, </span>
<span style="color: #00A000">+                                                                                  from_user, from_host, profile-&gt;name, mod_sofia_globals.hostname))) {</span>
                                         sofia_glue_execute_sql_now(profile, &amp;sql, SWITCH_TRUE);
                                 }
                                         
<span style="color: #A00000">-                                if ((sql =</span>
<span style="color: #A00000">-                                         switch_mprintf(&quot;insert into sip_presence (sip_user, sip_host, status, rpid, expires, user_agent,&quot;</span>
<span style="color: #A00000">-                                                                        &quot; profile_name, hostname, open_closed) &quot;</span>
<span style="color: #A00000">-                                                                        &quot;values (&#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;,%ld,&#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;)&quot;,</span>
<span style="color: #A00000">-                                                                        from_user, from_host, note_txt, rpid, exp, full_agent, profile-&gt;name, mod_sofia_globals.hostname, open_closed))) {</span>
<span style="color: #A00000">-                                                </span>
<span style="color: #00A000">+                                if (sub_count &gt; 0 &amp;&amp; (sql = switch_mprintf(&quot;insert into sip_presence (sip_user, sip_host, status, rpid, expires, user_agent,&quot;</span>
<span style="color: #00A000">+                                                                                                                   &quot; profile_name, hostname, open_closed) &quot;</span>
<span style="color: #00A000">+                                                                                                                   &quot;values (&#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;,%ld,&#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;)&quot;,</span>
<span style="color: #00A000">+                                                                                                                   from_user, from_host, note_txt, rpid, exp, full_agent, profile-&gt;name, </span>
<span style="color: #00A000">+                                                                                                                   mod_sofia_globals.hostname, open_closed))) {</span>
<span style="color: #00A000">+                                        </span>
                                         sofia_glue_execute_sql_now(profile, &amp;sql, SWITCH_TRUE);
                                 }
                                 
<span style="color: #800080; font-weight: bold">@@ -2696,16 +2710,17 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n</span>
                                 switch_safe_free(sql);
                         }
 
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        if (switch_event_create(&amp;event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #A00000">-                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;proto&quot;, SOFIA_CHAT_PROTO);</span>
<span style="color: #A00000">-                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;rpid&quot;, rpid);</span>
<span style="color: #A00000">-                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;login&quot;, profile-&gt;url);</span>
<span style="color: #A00000">-                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;user-agent&quot;, full_agent);</span>
<span style="color: #A00000">-                                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;from&quot;, &quot;%s@%s&quot;, from_user, from_host);</span>
<span style="color: #A00000">-                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;status&quot;, note_txt);</span>
<span style="color: #A00000">-                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;event_type&quot;, event_type);</span>
<span style="color: #A00000">-                                switch_event_fire(&amp;event);</span>
<span style="color: #00A000">+                        if (sub_count &gt; 0) {</span>
<span style="color: #00A000">+                                if (switch_event_create(&amp;event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;proto&quot;, SOFIA_CHAT_PROTO);</span>
<span style="color: #00A000">+                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;rpid&quot;, rpid);</span>
<span style="color: #00A000">+                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;login&quot;, profile-&gt;url);</span>
<span style="color: #00A000">+                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;user-agent&quot;, full_agent);</span>
<span style="color: #00A000">+                                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;from&quot;, &quot;%s@%s&quot;, from_user, from_host);</span>
<span style="color: #00A000">+                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;status&quot;, note_txt);</span>
<span style="color: #00A000">+                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;event_type&quot;, event_type);</span>
<span style="color: #00A000">+                                        switch_event_fire(&amp;event);</span>
<span style="color: #00A000">+                                }</span>
                         }
 
                         if (event_type) {
<span style="color: #800080; font-weight: bold">@@ -2728,7 +2743,12 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n</span>
 
         switch_snprintf(expstr, sizeof(expstr), &quot;%d&quot;, exp_delta);
         switch_stun_random_string(etag, 8, NULL);
<span style="color: #A00000">-        nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), SIPTAG_ETAG_STR(etag), SIPTAG_EXPIRES_STR(expstr), TAG_END());</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (sub_count &gt; 0) {</span>
<span style="color: #00A000">+                nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), SIPTAG_ETAG_STR(etag), SIPTAG_EXPIRES_STR(expstr), TAG_END());</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                nua_respond(nh, SIP_404_NOT_FOUND, NUTAG_WITH_THIS(nua), TAG_END());</span>
<span style="color: #00A000">+        }</span>
 
         switch_safe_free(contact_str);
 }
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
fix possible bad pointer in global vars (please test)

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c</span>
<span style="color: #000080; font-weight: bold">index 970cb5b..2ef21cc 100755</span>
<span style="color: #A00000">--- a/libs/freetdm/mod_freetdm/mod_freetdm.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/mod_freetdm/mod_freetdm.c</span>
<span style="color: #800080; font-weight: bold">@@ -1067,9 +1067,16 @@ static const char* channel_get_variable(switch_core_session_t *session, switch_e</span>
                        return variable;
                }
        }
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+           // This is unsafe, I don&#39;t see anywhere in the whole code where this is called with NULL session anyway.</span>
<span style="color: #00A000">+           // There is a new switch_core_get_variable_dup that will strdup it for you and then you must free it.</span>
<span style="color: #00A000">+           // That messes up the abstraction completely so I am just commenting it out for you.....</span>
<span style="color: #00A000">+           /*</span>
        if ((variable = switch_core_get_variable(variable_name))) {
                return variable;
        }
<span style="color: #00A000">+           */</span>
        return NULL;
 }
 
<span style="color: #000080; font-weight: bold">diff --git a/libs/openzap/mod_openzap/mod_openzap.c b/libs/openzap/mod_openzap/mod_openzap.c</span>
<span style="color: #000080; font-weight: bold">index d52149c..ef346b8 100644</span>
<span style="color: #A00000">--- a/libs/openzap/mod_openzap/mod_openzap.c</span>
<span style="color: #00A000">+++ b/libs/openzap/mod_openzap/mod_openzap.c</span>
<span style="color: #800080; font-weight: bold">@@ -1234,19 +1234,19 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi</span>
                 zap_set_string(caller_data.ani.digits, dest);
         }
         
<span style="color: #A00000">-        if ((var = switch_event_get_header(var_event, &quot;openzap_outbound_ton&quot;)) || (var = switch_core_get_variable(&quot;openzap_outbound_ton&quot;))) {</span>
<span style="color: #00A000">+        if ((var = switch_event_get_header(var_event, &quot;openzap_outbound_ton&quot;))) {</span>
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Setting TON to: %s\n&quot;, var);
                 zap_set_ton(var, &amp;caller_data.ani.type);
         } else {
                 caller_data.ani.type = outbound_profile-&gt;destination_number_ton;
         }
 
<span style="color: #A00000">-        if ((var = switch_event_get_header(var_event, &quot;openzap_custom_call_data&quot;)) || (var = switch_core_get_variable(&quot;openzap_custom_call_data&quot;))) {</span>
<span style="color: #00A000">+        if ((var = switch_event_get_header(var_event, &quot;openzap_custom_call_data&quot;))) {</span>
                 zap_set_string((char *)caller_data.raw_data, var);
                 caller_data.raw_data_len = strlen(var);
         }
         
<span style="color: #A00000">-        if ((var = switch_event_get_header(var_event, &quot;openzap_outbound_npi&quot;)) || (var = switch_core_get_variable(&quot;openzap_outbound_npi&quot;))) {</span>
<span style="color: #00A000">+        if ((var = switch_event_get_header(var_event, &quot;openzap_outbound_npi&quot;))) {</span>
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Setting NPI to: %s\n&quot;, var);
                 zap_set_npi(var, &amp;caller_data.ani.plan);
         } else {
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
fix possible bad pointer in global vars (please test)

<span style="color: #000080; font-weight: bold">diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h</span>
<span style="color: #000080; font-weight: bold">index 30690b1..05cd24d 100644</span>
<span style="color: #A00000">--- a/src/include/private/switch_core_pvt.h</span>
<span style="color: #00A000">+++ b/src/include/private/switch_core_pvt.h</span>
<span style="color: #800080; font-weight: bold">@@ -246,6 +246,7 @@ struct switch_runtime {</span>
         int sql_buffer_len;
         int max_sql_buffer_len;
         switch_dbtype_t odbc_dbtype;
<span style="color: #00A000">+        char hostname[256];</span>
 };
 
 extern struct switch_runtime runtime;
<span style="color: #000080; font-weight: bold">diff --git a/src/include/switch_core.h b/src/include/switch_core.h</span>
<span style="color: #000080; font-weight: bold">index 109a169..69b0642 100644</span>
<span style="color: #A00000">--- a/src/include/switch_core.h</span>
<span style="color: #00A000">+++ b/src/include/switch_core.h</span>
<span style="color: #800080; font-weight: bold">@@ -759,6 +759,9 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_force_locate(_In_z_</span>
   \return the value of the desired variable
 */
 SWITCH_DECLARE(char *) switch_core_get_variable(_In_z_ const char *varname);
<span style="color: #00A000">+SWITCH_DECLARE(char *) switch_core_get_variable_dup(_In_z_ const char *varname);</span>
<span style="color: #00A000">+SWITCH_DECLARE(char *) switch_core_get_variable_pdup(_In_z_ const char *varname, switch_memory_pool_t *pool);</span>
<span style="color: #00A000">+SWITCH_DECLARE(const char *) switch_core_get_hostname(void);</span>
 
 /*! 
   \brief Add a global variable to the core
<span style="color: #000080; font-weight: bold">diff --git a/src/include/switch_nat.h b/src/include/switch_nat.h</span>
<span style="color: #000080; font-weight: bold">index bdbd51b..9e40546 100644</span>
<span style="color: #A00000">--- a/src/include/switch_nat.h</span>
<span style="color: #00A000">+++ b/src/include/switch_nat.h</span>
<span style="color: #800080; font-weight: bold">@@ -49,7 +49,7 @@ typedef enum {</span>
         SWITCH_NAT_TCP
 } switch_nat_ip_proto_t;
 
<span style="color: #A00000">-</span>
<span style="color: #00A000">+SWITCH_DECLARE(const char *) switch_nat_get_type(void);</span>
 
 /*! 
   \brief Initilize the NAT Traversal System
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c</span>
<span style="color: #000080; font-weight: bold">index 7771b09..807770a 100644</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_commands/mod_commands.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_commands/mod_commands.c</span>
<span style="color: #800080; font-weight: bold">@@ -349,7 +349,7 @@ SWITCH_STANDARD_API(timer_test_function)</span>
 
 SWITCH_STANDARD_API(group_call_function)
 {
<span style="color: #A00000">-        char *domain;</span>
<span style="color: #00A000">+        char *domain, *dup_domain = NULL;</span>
         char *group_name = NULL;
         char *flags;
         int ok = 0;
<span style="color: #800080; font-weight: bold">@@ -392,7 +392,9 @@ SWITCH_STANDARD_API(group_call_function)</span>
         if (domain) {
                 *domain++ = &#39;\0&#39;;
         } else {
<span style="color: #A00000">-                domain = switch_core_get_variable(&quot;domain&quot;);</span>
<span style="color: #00A000">+                if ((dup_domain = switch_core_get_variable_dup(&quot;domain&quot;))) {</span>
<span style="color: #00A000">+                        domain = dup_domain;</span>
<span style="color: #00A000">+                }</span>
         }
 
         if (!zstr(domain)) {
<span style="color: #800080; font-weight: bold">@@ -544,13 +546,14 @@ SWITCH_STANDARD_API(group_call_function)</span>
         }
 
   end:
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        </span>
         switch_safe_free(group_name);
<span style="color: #00A000">+        switch_safe_free(dup_domain);</span>
 
         if (!ok) {
                 stream-&gt;write_function(stream, &quot;error/NO_ROUTE_DESTINATION&quot;);
         }
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        </span>
         return SWITCH_STATUS_SUCCESS;
 }
 
<span style="color: #800080; font-weight: bold">@@ -559,7 +562,7 @@ SWITCH_STANDARD_API(in_group_function)</span>
 {
         switch_xml_t x_domain, xml = NULL, x_user = NULL, x_group;
         int argc;
<span style="color: #A00000">-        char *mydata = NULL, *argv[2], *user, *domain;</span>
<span style="color: #00A000">+        char *mydata = NULL, *argv[2], *user, *domain, *dup_domain = NULL;</span>
         char delim = &#39;,&#39;;
         switch_event_t *params = NULL;
         const char *rval = &quot;false&quot;;
<span style="color: #800080; font-weight: bold">@@ -579,7 +582,9 @@ SWITCH_STANDARD_API(in_group_function)</span>
         if ((domain = strchr(user, &#39;@&#39;))) {
                 *domain++ = &#39;\0&#39;;
         } else {
<span style="color: #A00000">-                domain = switch_core_get_variable(&quot;domain&quot;);</span>
<span style="color: #00A000">+                if ((dup_domain = switch_core_get_variable_dup(&quot;domain&quot;))) {</span>
<span style="color: #00A000">+                        domain = dup_domain;</span>
<span style="color: #00A000">+                }</span>
         }
 
         switch_event_create(&amp;params, SWITCH_EVENT_REQUEST_PARAMS);
<span style="color: #800080; font-weight: bold">@@ -601,6 +606,7 @@ SWITCH_STANDARD_API(in_group_function)</span>
 
         switch_xml_free(xml);
         switch_safe_free(mydata);
<span style="color: #00A000">+        switch_safe_free(dup_domain);</span>
         switch_event_destroy(&amp;params);
 
         return SWITCH_STATUS_SUCCESS;
<span style="color: #800080; font-weight: bold">@@ -610,7 +616,7 @@ SWITCH_STANDARD_API(user_data_function)</span>
 {
         switch_xml_t x_domain, xml = NULL, x_user = NULL, x_group = NULL, x_param, x_params;
         int argc;
<span style="color: #A00000">-        char *mydata = NULL, *argv[3], *key = NULL, *type = NULL, *user, *domain;</span>
<span style="color: #00A000">+        char *mydata = NULL, *argv[3], *key = NULL, *type = NULL, *user, *domain, *dup_domain = NULL;</span>
         char delim = &#39; &#39;;
         const char *container = &quot;params&quot;, *elem = &quot;param&quot;;
         const char *result = NULL;
<span style="color: #800080; font-weight: bold">@@ -631,7 +637,9 @@ SWITCH_STANDARD_API(user_data_function)</span>
         if ((domain = strchr(user, &#39;@&#39;))) {
                 *domain++ = &#39;\0&#39;;
         } else {
<span style="color: #A00000">-                if (!(domain = switch_core_get_variable(&quot;domain&quot;))) {</span>
<span style="color: #00A000">+                if ((dup_domain = switch_core_get_variable(&quot;domain&quot;))) {</span>
<span style="color: #00A000">+                        domain = dup_domain;</span>
<span style="color: #00A000">+                } else {</span>
                         domain = &quot;cluecon.com&quot;;
                 }
         }
<span style="color: #800080; font-weight: bold">@@ -694,6 +702,7 @@ SWITCH_STANDARD_API(user_data_function)</span>
         }
         switch_xml_free(xml);
         switch_safe_free(mydata);
<span style="color: #00A000">+        switch_safe_free(dup_domain);</span>
         switch_event_destroy(&amp;params);
 
         return SWITCH_STATUS_SUCCESS;
<span style="color: #800080; font-weight: bold">@@ -4375,7 +4384,9 @@ SWITCH_STANDARD_API(global_getvar_function)</span>
         if (zstr(cmd)) {
                 switch_core_dump_variables(stream);
         } else {
<span style="color: #A00000">-                stream-&gt;write_function(stream, &quot;%s&quot;, switch_str_nil(switch_core_get_variable(cmd)));</span>
<span style="color: #00A000">+                char *var = switch_core_get_variable_dup(cmd);</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;%s&quot;, switch_str_nil(var));</span>
<span style="color: #00A000">+                switch_safe_free(var);</span>
         }
         return SWITCH_STATUS_SUCCESS;
 }
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c</span>
<span style="color: #000080; font-weight: bold">index 928a9b8..4be2a64 100755</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_dptools/mod_dptools.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_dptools/mod_dptools.c</span>
<span style="color: #800080; font-weight: bold">@@ -2787,7 +2787,7 @@ static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session</span>
         if ((domain = strchr(group, &#39;@&#39;))) {
                 *domain++ = &#39;\0&#39;;
         } else {
<span style="color: #A00000">-                domain = switch_core_get_variable(&quot;domain&quot;);</span>
<span style="color: #00A000">+                domain = switch_core_get_variable_pdup(&quot;domain&quot;, switch_core_session_get_pool(session));</span>
         }
 
         if (!domain) {
<span style="color: #800080; font-weight: bold">@@ -2908,7 +2908,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,</span>
         if ((domain = strchr(user, &#39;@&#39;))) {
                 *domain++ = &#39;\0&#39;;
         } else {
<span style="color: #A00000">-                domain = switch_core_get_variable(&quot;domain&quot;);</span>
<span style="color: #00A000">+                domain = switch_core_get_variable_pdup(&quot;domain&quot;, switch_core_session_get_pool(session));</span>
         }
 
         if (!domain) {
<span style="color: #800080; font-weight: bold">@@ -3193,10 +3193,11 @@ static switch_status_t event_chat_send(const char *proto, const char *from, cons</span>
                 if (body)
                         switch_event_add_body(event, &quot;%s&quot;, body);
                 if (to) {
<span style="color: #A00000">-                        const char *v;</span>
<span style="color: #00A000">+                        char *v;</span>
                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;To&quot;, to);
<span style="color: #A00000">-                        if ((v = switch_core_get_variable(to))) {</span>
<span style="color: #00A000">+                        if ((v = switch_core_get_variable_dup(to))) {</span>
                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Command&quot;, v);
<span style="color: #00A000">+                                free(v);</span>
                         }
                 }
 
<span style="color: #800080; font-weight: bold">@@ -3214,15 +3215,15 @@ static switch_status_t api_chat_send(const char *proto, const char *from, const</span>
                                                                          const char *body, const char *type, const char *hint)
 {
         if (to) {
<span style="color: #A00000">-                const char *v;</span>
<span style="color: #00A000">+                char *v = NULL;</span>
                 switch_stream_handle_t stream = { 0 };
                 char *cmd = NULL, *arg;
 
<span style="color: #A00000">-                if (!(v = switch_core_get_variable(to))) {</span>
<span style="color: #A00000">-                        v = to;</span>
<span style="color: #00A000">+                if (!(v = switch_core_get_variable_dup(to))) {</span>
<span style="color: #00A000">+                        v = strdup(to);</span>
                 }
 
<span style="color: #A00000">-                cmd = strdup(v);</span>
<span style="color: #00A000">+                cmd = v;</span>
                 switch_assert(cmd);
 
                 switch_url_decode(cmd);
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_redis/mod_redis.c b/src/mod/applications/mod_redis/mod_redis.c</span>
<span style="color: #000080; font-weight: bold">index 1e99967..ebf2a9e 100755</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_redis/mod_redis.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_redis/mod_redis.c</span>
<span style="color: #800080; font-weight: bold">@@ -89,7 +89,7 @@ SWITCH_LIMIT_INCR(limit_incr_redis)</span>
         }
         
         /* Get the keys for redis server */
<span style="color: #A00000">-        uuid_rediskey = switch_core_session_sprintf(session,&quot;%s_%s_%s&quot;, switch_core_get_variable(&quot;hostname&quot;), realm, resource);</span>
<span style="color: #00A000">+        uuid_rediskey = switch_core_session_sprintf(session,&quot;%s_%s_%s&quot;, switch_core_get_hostname(), realm, resource);</span>
         rediskey = switch_core_session_sprintf(session, &quot;%s_%s&quot;, realm, resource);
 
         if ((pvt = switch_channel_get_private(channel, &quot;limit_redis&quot;))) {
<span style="color: #800080; font-weight: bold">@@ -179,7 +179,7 @@ SWITCH_LIMIT_RELEASE(limit_release_redis)</span>
                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Couldn&#39;t decrement value corresponding to %s\n&quot;, (char *)p_key);
                                 switch_goto_status(SWITCH_STATUS_FALSE, end);
                         }
<span style="color: #A00000">-                           p_uuid_key = switch_core_session_sprintf(session, &quot;%s_%s&quot;, switch_core_get_variable(&quot;hostname&quot;), (char *)p_key);</span>
<span style="color: #00A000">+                           p_uuid_key = switch_core_session_sprintf(session, &quot;%s_%s&quot;, switch_core_get_hostname(), (char *)p_key);</span>
                         if (credis_decr(redis,p_uuid_key,&amp;uuid_val) != 0) {
                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Couldn&#39;t decrement value corresponding to %s\n&quot;, p_uuid_key);
                                 switch_goto_status(SWITCH_STATUS_FALSE, end);
<span style="color: #800080; font-weight: bold">@@ -193,7 +193,7 @@ SWITCH_LIMIT_RELEASE(limit_release_redis)</span>
         
         } else {        
                    rediskey = switch_core_session_sprintf(session, &quot;%s_%s&quot;, realm, resource);
<span style="color: #A00000">-                uuid_rediskey = switch_core_session_sprintf(session, &quot;%s_%s_%s&quot;, switch_core_get_variable(&quot;hostname&quot;), realm, resource);</span>
<span style="color: #00A000">+                uuid_rediskey = switch_core_session_sprintf(session, &quot;%s_%s_%s&quot;, switch_core_get_hostname(), realm, resource);</span>
                 switch_core_hash_delete(pvt-&gt;hash, (const char *) rediskey);
 
                 if (credis_decr(redis, rediskey, &amp;val) != 0) {
<span style="color: #800080; font-weight: bold">@@ -249,13 +249,13 @@ SWITCH_LIMIT_RESET(limit_reset_redis)</span>
 {
         REDIS redis;
         if (redis_factory(&amp;redis) == SWITCH_STATUS_SUCCESS) {
<span style="color: #A00000">-                char *rediskey = switch_mprintf(&quot;%s_*&quot;, switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                char *rediskey = switch_mprintf(&quot;%s_*&quot;, switch_core_get_hostname());</span>
                 int dec = 0, val = 0, keyc;
                 char *uuids[2000];
         
                 if ((keyc = credis_keys(redis, rediskey, uuids, switch_arraylen(uuids))) &gt; 0) {
                         int i = 0;
<span style="color: #A00000">-                        int hostnamelen = strlen(switch_core_get_variable(&quot;hostname&quot;))+1;</span>
<span style="color: #00A000">+                        int hostnamelen = strlen(switch_core_get_hostname())+1;</span>
                         
                         for (i = 0; i &lt; keyc &amp;&amp; uuids[i]; i++){
                                 const char *key = uuids[i] + hostnamelen;
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #000080; font-weight: bold">index 76870f7..80b011e 100644</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #800080; font-weight: bold">@@ -2734,6 +2734,7 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t</span>
         switch_memory_pool_t *pool = NULL;
         char *forwarded_by = NULL;
         char *read_flags = NORMAL_FLAG_STRING;
<span style="color: #00A000">+        char *dup_domain = NULL;</span>
         
         if (zstr(data)) {
                 status = SWITCH_STATUS_FALSE;
<span style="color: #800080; font-weight: bold">@@ -2781,7 +2782,9 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t</span>
         }
 
         if (zstr(domain)) {
<span style="color: #A00000">-                domain = switch_core_get_variable(&quot;domain&quot;);</span>
<span style="color: #00A000">+                if ((dup_domain = switch_core_get_variable_dup(&quot;domain&quot;))) {</span>
<span style="color: #00A000">+                        domain = dup_domain;</span>
<span style="color: #00A000">+                }</span>
                 profile_name = domain;
         }
 
<span style="color: #800080; font-weight: bold">@@ -2915,6 +2918,7 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t</span>
   end:
 
         switch_safe_free(dup);
<span style="color: #00A000">+        switch_safe_free(dup_domain);</span>
 
         return status;
 }
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c b/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c</span>
<span style="color: #000080; font-weight: bold">index 5869d14..43534da 100644</span>
<span style="color: #A00000">--- a/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c</span>
<span style="color: #00A000">+++ b/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c</span>
<span style="color: #800080; font-weight: bold">@@ -313,7 +313,7 @@ static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session,</span>
         if (session) {
                 profile = switch_channel_get_variable(switch_core_session_get_channel(session), &quot;sip_profile&quot;);
         } else {
<span style="color: #A00000">-                profile = switch_core_get_variable(&quot;sip_profile&quot;);</span>
<span style="color: #00A000">+                profile = switch_core_get_variable_pdup(&quot;sip_profile&quot;, switch_core_session_get_pool(session));</span>
         }
         if (zstr(profile)) {
                 profile = &quot;default&quot;;
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c</span>
<span style="color: #000080; font-weight: bold">index 66f62b2..9fb1f39 100644</span>
<span style="color: #A00000">--- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c</span>
<span style="color: #00A000">+++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c</span>
<span style="color: #800080; font-weight: bold">@@ -2049,7 +2049,7 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val)</span>
         } else if (!strcasecmp(var, &quot;ext-rtp-ip&quot;)) {
                 char *ip = globals.guess_ip;
                 if (val &amp;&amp; !strcasecmp(val, &quot;auto-nat&quot;)) {
<span style="color: #A00000">-                        ip = globals.auto_nat ? switch_core_get_variable(&quot;nat_public_addr&quot;) : globals.guess_ip;</span>
<span style="color: #00A000">+                        ip = globals.auto_nat ? switch_core_get_variable_pdup(&quot;nat_public_addr&quot;, module_pool) : globals.guess_ip;</span>
                 } else if (val &amp;&amp; !strcasecmp(val, &quot;auto&quot;)) {
                         globals.auto_nat = 0;
                         ip = globals.guess_ip;
<span style="color: #800080; font-weight: bold">@@ -2523,7 +2523,7 @@ static switch_status_t load_config(void)</span>
 
         memset(&amp;globals, 0, sizeof(globals));
         globals.running = 1;
<span style="color: #A00000">-        globals.auto_nat = (switch_core_get_variable(&quot;nat_type&quot;) ? 1 : 0);</span>
<span style="color: #00A000">+        globals.auto_nat = (switch_nat_get_type() ? 1 : 0);</span>
 
         switch_find_local_ip(globals.guess_ip, sizeof(globals.guess_ip), NULL, AF_INET);
 
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/endpoints/mod_khomp/src/khomp_pvt.cpp b/src/mod/endpoints/mod_khomp/src/khomp_pvt.cpp</span>
<span style="color: #000080; font-weight: bold">index 1b126eb..15009f2 100644</span>
<span style="color: #A00000">--- a/src/mod/endpoints/mod_khomp/src/khomp_pvt.cpp</span>
<span style="color: #00A000">+++ b/src/mod/endpoints/mod_khomp/src/khomp_pvt.cpp</span>
<span style="color: #800080; font-weight: bold">@@ -1625,9 +1625,10 @@ bool Board::KhompPvt::setCollectCall()</span>
     DBG(FUNC, PVT_FMT(_target, &quot;option drop collect call is &#39;%s&#39;&quot;) % (Opt::_options._drop_collect_call() ? &quot;yes&quot; : &quot;no&quot;));
 
     // get global filter configuration value
<span style="color: #A00000">-    tmp_var = switch_core_get_variable(&quot;KDropCollectCall&quot;);</span>
<span style="color: #00A000">+    tmp_var = switch_core_get_variable_dup(&quot;KDropCollectCall&quot;);</span>
     confvalues.push_back(getTriStateValue(tmp_var));
     DBG(FUNC, PVT_FMT(_target, &quot;global KDropCollectCall was &#39;%s&#39;&quot;) % (tmp_var ? tmp_var : &quot;(empty)&quot;));
<span style="color: #00A000">+        switch_safe_free(tmp_var);</span>
 
     try 
     {
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c</span>
<span style="color: #000080; font-weight: bold">index 8bceb3b..c78aac7 100644</span>
<span style="color: #A00000">--- a/src/mod/endpoints/mod_sofia/mod_sofia.c</span>
<span style="color: #00A000">+++ b/src/mod/endpoints/mod_sofia/mod_sofia.c</span>
<span style="color: #800080; font-weight: bold">@@ -3501,7 +3501,7 @@ SWITCH_STANDARD_API(sofia_contact_function)</span>
         }
 
         if (zstr(domain)) {
<span style="color: #A00000">-                domain = switch_core_get_variable(&quot;domain&quot;);</span>
<span style="color: #00A000">+                domain = switch_core_get_variable_pdup(&quot;domain&quot;, switch_core_session_get_pool(session));</span>
         }
 
         if (!user) goto end;
<span style="color: #800080; font-weight: bold">@@ -4776,7 +4776,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)</span>
         mod_sofia_globals.running = 1;
         switch_mutex_unlock(mod_sofia_globals.mutex);
 
<span style="color: #A00000">-        mod_sofia_globals.auto_nat = (switch_core_get_variable(&quot;nat_type&quot;) ? 1 : 0);</span>
<span style="color: #00A000">+        mod_sofia_globals.auto_nat = (switch_nat_get_type() ? 1 : 0);</span>
 
         switch_queue_create(&amp;mod_sofia_globals.presence_queue, SOFIA_QUEUE_SIZE, mod_sofia_globals.pool);
         switch_queue_create(&amp;mod_sofia_globals.mwi_queue, SOFIA_QUEUE_SIZE, mod_sofia_globals.pool);
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c</span>
<span style="color: #000080; font-weight: bold">index 47f94b1..825d1bf 100644</span>
<span style="color: #A00000">--- a/src/mod/endpoints/mod_sofia/sofia.c</span>
<span style="color: #00A000">+++ b/src/mod/endpoints/mod_sofia/sofia.c</span>
<span style="color: #800080; font-weight: bold">@@ -1459,7 +1459,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void</span>
 
         supported = switch_core_sprintf(profile-&gt;pool, &quot;%s%sprecondition, path, replaces&quot;, use_100rel ? &quot;100rel, &quot; : &quot;&quot;, use_timer ? &quot;timer, &quot; : &quot;&quot;);
 
<span style="color: #A00000">-        if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) &amp;&amp; switch_core_get_variable(&quot;nat_type&quot;)) {</span>
<span style="color: #00A000">+        if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) &amp;&amp; switch_nat_get_type()) {</span>
                 if (switch_nat_add_mapping(profile-&gt;sip_port, SWITCH_NAT_UDP, NULL, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Created UDP nat mapping for %s port %d\n&quot;, profile-&gt;name, profile-&gt;sip_port);
                 }
<span style="color: #800080; font-weight: bold">@@ -1676,7 +1676,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void</span>
                 switch_event_fire(&amp;s_event);
         }
 
<span style="color: #A00000">-        if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) &amp;&amp; switch_core_get_variable(&quot;nat_type&quot;)) {</span>
<span style="color: #00A000">+        if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) &amp;&amp; switch_nat_get_type()) {</span>
                 if (switch_nat_del_mapping(profile-&gt;sip_port, SWITCH_NAT_UDP) == SWITCH_STATUS_SUCCESS) {
                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Deleted UDP nat mapping for %s port %d\n&quot;, profile-&gt;name, profile-&gt;sip_port);
                 }
<span style="color: #800080; font-weight: bold">@@ -3741,9 +3741,9 @@ switch_status_t config_sofia(int reload, char *profile_name)</span>
                                 if (!profile-&gt;rtpip[0]) {
                                         profile-&gt;rtpip[profile-&gt;rtpip_index++] = switch_core_strdup(profile-&gt;pool, mod_sofia_globals.guess_ip);
                                 }
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                if (switch_core_get_variable(&quot;nat_type&quot;)) {</span>
<span style="color: #A00000">-                                        const char *ip = switch_core_get_variable(&quot;nat_public_addr&quot;);</span>
<span style="color: #00A000">+                                </span>
<span style="color: #00A000">+                                if (switch_nat_get_type()) {</span>
<span style="color: #00A000">+                                        char *ip = switch_core_get_variable_dup(&quot;nat_public_addr&quot;);</span>
                                         if (ip &amp;&amp; !strchr(profile-&gt;sipip, &#39;:&#39;)) {
                                                 if (!profile-&gt;extrtpip) {
                                                         profile-&gt;extrtpip = switch_core_strdup(profile-&gt;pool, ip);
<span style="color: #800080; font-weight: bold">@@ -3754,6 +3754,7 @@ switch_status_t config_sofia(int reload, char *profile_name)</span>
                                                 sofia_set_pflag(profile, PFLAG_AUTO_NAT);
                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;NAT detected setting external ip to %s\n&quot;, ip);
                                         }
<span style="color: #00A000">+                                        switch_safe_free(ip);</span>
                                 }
 
                                 if (profile-&gt;nonce_ttl &lt; 60) {
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c</span>
<span style="color: #000080; font-weight: bold">index f3a2c92..1462e4e 100644</span>
<span style="color: #A00000">--- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c</span>
<span style="color: #00A000">+++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c</span>
<span style="color: #800080; font-weight: bold">@@ -2642,7 +2642,7 @@ static int config(void)</span>
                                 } else if (!strcmp(var, &quot;debug&quot;)) {
                                         globals.debug = atoi(val);
                                 } else if (!strcmp(var, &quot;nat-map&quot;)) {
<span style="color: #A00000">-                                        if (switch_true(val) &amp;&amp; switch_core_get_variable(&quot;nat_type&quot;)) {</span>
<span style="color: #00A000">+                                        if (switch_true(val) &amp;&amp; switch_nat_get_type()) {</span>
                                                 prefs.nat_map = 1;
                                         }
                                 } else if (!strcmp(var, &quot;listen-port&quot;)) {
<span style="color: #800080; font-weight: bold">@@ -2795,7 +2795,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime)</span>
 
         close_socket(&amp;listen_list.sock);
 
<span style="color: #A00000">-        if (prefs.nat_map &amp;&amp; switch_core_get_variable(&quot;nat_type&quot;)) {</span>
<span style="color: #00A000">+        if (prefs.nat_map &amp;&amp; switch_nat_get_type()) {</span>
                 switch_nat_del_mapping(prefs.port, SWITCH_NAT_TCP);
         }
 
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/formats/mod_file_string/mod_file_string.c b/src/mod/formats/mod_file_string/mod_file_string.c</span>
<span style="color: #000080; font-weight: bold">index ca86cbd..7e36c72 100644</span>
<span style="color: #A00000">--- a/src/mod/formats/mod_file_string/mod_file_string.c</span>
<span style="color: #00A000">+++ b/src/mod/formats/mod_file_string/mod_file_string.c</span>
<span style="color: #800080; font-weight: bold">@@ -77,7 +77,7 @@ static int next_file(switch_file_handle_t *handle)</span>
 
 
         if (!prefix) {
<span style="color: #A00000">-                if (!(prefix = switch_core_get_variable(&quot;sound_prefix&quot;))) {</span>
<span style="color: #00A000">+                if (!(prefix = switch_core_get_variable_pdup(&quot;sound_prefix&quot;, handle-&gt;memory_pool))) {</span>
                         prefix = SWITCH_GLOBAL_dirs.sounds_dir;
                 }
         }
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c</span>
<span style="color: #000080; font-weight: bold">index 9eb2636..1d6ee8d 100644</span>
<span style="color: #A00000">--- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c</span>
<span style="color: #00A000">+++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c</span>
<span style="color: #800080; font-weight: bold">@@ -3378,8 +3378,9 @@ static JSBool js_global_get(JSContext * cx, JSObject * obj, uintN argc, jsval *</span>
 
         if (argc &gt; 0) {
                 var_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
<span style="color: #A00000">-                val = switch_core_get_variable(var_name);</span>
<span style="color: #00A000">+                val = switch_core_get_variable_dup(var_name);</span>
                 *rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, val));
<span style="color: #00A000">+                free(val);</span>
                 return JS_TRUE;
         }
 
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c</span>
<span style="color: #000080; font-weight: bold">index 468190d..9e61312 100644</span>
<span style="color: #A00000">--- a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c</span>
<span style="color: #00A000">+++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c</span>
<span style="color: #800080; font-weight: bold">@@ -322,6 +322,7 @@ static abyss_bool http_directory_auth(TSession * r, char *domain_name)</span>
         int at = 0;
         char *dp;
         abyss_bool rval = FALSE;
<span style="color: #00A000">+        char *dup_domain = NULL;</span>
 
         p = RequestHeaderValue(r, &quot;authorization&quot;);
 
<span style="color: #800080; font-weight: bold">@@ -354,7 +355,9 @@ static abyss_bool http_directory_auth(TSession * r, char *domain_name)</span>
                                                 if (globals.default_domain) {
                                                         domain_name = globals.default_domain;
                                                 } else {
<span style="color: #A00000">-                                                        domain_name = switch_core_get_variable(&quot;domain&quot;);</span>
<span style="color: #00A000">+                                                        if ((dup_domain = switch_core_get_variable_dup(&quot;domain&quot;))) {</span>
<span style="color: #00A000">+                                                                domain_name = dup_domain;</span>
<span style="color: #00A000">+                                                        }</span>
                                                 }
                                         }
                                 }
<span style="color: #800080; font-weight: bold">@@ -465,6 +468,7 @@ static abyss_bool http_directory_auth(TSession * r, char *domain_name)</span>
         switch_safe_free(mypass1);
         switch_safe_free(mypass2);
         switch_safe_free(box);
<span style="color: #00A000">+        switch_safe_free(dup_domain);</span>
 
         return rval;
 }
<span style="color: #000080; font-weight: bold">diff --git a/src/switch_channel.c b/src/switch_channel.c</span>
<span style="color: #000080; font-weight: bold">index 70b1879..f750496 100644</span>
<span style="color: #A00000">--- a/src/switch_channel.c</span>
<span style="color: #00A000">+++ b/src/switch_channel.c</span>
<span style="color: #800080; font-weight: bold">@@ -672,7 +672,7 @@ SWITCH_DECLARE(const char *) switch_channel_get_hold_music_partner(switch_channe</span>
 
 SWITCH_DECLARE(const char *) switch_channel_get_variable_dup(switch_channel_t *channel, const char *varname, switch_bool_t dup)
 {
<span style="color: #A00000">-        const char *v = NULL, *r = NULL;</span>
<span style="color: #00A000">+        const char *v = NULL, *r = NULL, *vdup = NULL;</span>
         switch_assert(channel != NULL);
 
         switch_mutex_lock(channel-&gt;profile_mutex);
<span style="color: #800080; font-weight: bold">@@ -690,13 +690,16 @@ SWITCH_DECLARE(const char *) switch_channel_get_variable_dup(switch_channel_t *c</span>
                 }
 
                 if (!cp || !(v = switch_caller_get_field_by_name(cp, varname))) {
<span style="color: #A00000">-                        v = switch_core_get_variable(varname);</span>
<span style="color: #00A000">+                        if ((vdup = switch_core_get_variable_pdup(varname, switch_core_session_get_pool(channel-&gt;session)))) {</span>
<span style="color: #00A000">+                                v = vdup;</span>
<span style="color: #00A000">+                        }</span>
                 }
         }
 
<span style="color: #A00000">-        if (dup) {</span>
<span style="color: #A00000">-                if (v)</span>
<span style="color: #00A000">+        if (dup &amp;&amp; v != vdup) {</span>
<span style="color: #00A000">+                if (v) {</span>
                         r = switch_core_session_strdup(channel-&gt;session, v);
<span style="color: #00A000">+                }</span>
         } else {
                 r = v;
         }
<span style="color: #000080; font-weight: bold">diff --git a/src/switch_console.c b/src/switch_console.c</span>
<span style="color: #000080; font-weight: bold">index 41bbb91..c5d601b 100644</span>
<span style="color: #A00000">--- a/src/switch_console.c</span>
<span style="color: #00A000">+++ b/src/switch_console.c</span>
<span style="color: #800080; font-weight: bold">@@ -643,9 +643,9 @@ SWITCH_DECLARE_NONSTD(switch_status_t) switch_console_list_uuid(const char *line</span>
 
         if (!zstr(cursor)) {
                 sql = switch_mprintf(&quot;select distinct uuid from channels where uuid like &#39;%q%%&#39; and hostname=&#39;%q&#39; order by uuid&quot;,
<span style="color: #A00000">-                                                         cursor, switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                         cursor, switch_core_get_hostname());</span>
         } else {
<span style="color: #A00000">-                sql = switch_mprintf(&quot;select distinct uuid from channels where hostname=&#39;%q&#39; order by uuid&quot;, switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                sql = switch_mprintf(&quot;select distinct uuid from channels where hostname=&#39;%q&#39; order by uuid&quot;, switch_core_get_hostname());</span>
         }
 
         switch_cache_db_execute_sql_callback(db, sql, uuid_callback, &amp;h, &amp;errmsg);
<span style="color: #800080; font-weight: bold">@@ -764,7 +764,7 @@ SWITCH_DECLARE(unsigned char) switch_console_complete(const char *line, const ch</span>
 
         if (h.words == 0) {
                 sql = switch_mprintf(&quot;select distinct name from interfaces where type=&#39;api&#39; and name like &#39;%q%%&#39; and hostname=&#39;%q&#39; order by name&quot;,
<span style="color: #A00000">-                                                         buf, switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                         buf, switch_core_get_hostname());</span>
         }
 
         if (sql) {
<span style="color: #800080; font-weight: bold">@@ -792,7 +792,7 @@ SWITCH_DECLARE(unsigned char) switch_console_complete(const char *line, const ch</span>
 
                 if (h.words == 0) {
                         stream.write_function(&amp;stream, &quot;select distinct a1 from complete where &quot; &quot;a1 not in (select name from interfaces where hostname=&#39;%s&#39;) %s &quot;,
<span style="color: #A00000">-                                                                  switch_core_get_variable(&quot;hostname&quot;), argc ? &quot;and&quot; : &quot;&quot;);</span>
<span style="color: #00A000">+                                                                  switch_core_get_hostname(), argc ? &quot;and&quot; : &quot;&quot;);</span>
                 } else {
                         if (db-&gt;type == SCDB_TYPE_CORE_DB) {
                                 stream.write_function(&amp;stream, &quot;select distinct a%d,&#39;%q&#39;,&#39;%q&#39; from complete where &quot;, h.words + 1, switch_str_nil(dup), switch_str_nil(lp));
<span style="color: #800080; font-weight: bold">@@ -821,7 +821,7 @@ SWITCH_DECLARE(unsigned char) switch_console_complete(const char *line, const ch</span>
                         }
                 }
 
<span style="color: #A00000">-                stream.write_function(&amp;stream, &quot; and hostname=&#39;%s&#39; order by a%d&quot;, switch_core_get_variable(&quot;hostname&quot;), h.words + 1);</span>
<span style="color: #00A000">+                stream.write_function(&amp;stream, &quot; and hostname=&#39;%s&#39; order by a%d&quot;, switch_core_get_hostname(), h.words + 1);</span>
                 
                 switch_cache_db_execute_sql_callback(db, stream.data, comp_callback, &amp;h, &amp;errmsg);
 
<span style="color: #800080; font-weight: bold">@@ -1794,7 +1794,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string)</span>
                                                 }
                                         }
                                 }
<span style="color: #A00000">-                                mystream.write_function(&amp;mystream, &quot; &#39;%s&#39;)&quot;, switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                mystream.write_function(&amp;mystream, &quot; &#39;%s&#39;)&quot;, switch_core_get_hostname());</span>
                                 switch_cache_db_persistant_execute(db, mystream.data, 5);
                                 status = SWITCH_STATUS_SUCCESS;
                         } else if (!strcasecmp(argv[0], &quot;add&quot;)) {
<span style="color: #800080; font-weight: bold">@@ -1810,7 +1810,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string)</span>
                                                 }
                                         }
                                 }
<span style="color: #A00000">-                                mystream.write_function(&amp;mystream, &quot; &#39;%s&#39;)&quot;, switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                mystream.write_function(&amp;mystream, &quot; &#39;%s&#39;)&quot;, switch_core_get_hostname());</span>
 
                                 switch_cache_db_persistant_execute(db, mystream.data, 5);
                                 status = SWITCH_STATUS_SUCCESS;
<span style="color: #800080; font-weight: bold">@@ -1827,7 +1827,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string)</span>
                                                         mystream.write_function(&amp;mystream, &quot;a%d = &#39;%w&#39;%w&quot;, x + 1, switch_str_nil(argv[x + 1]), x == argc - 2 ? &quot;&quot; : &quot; and &quot;);
                                                 }
                                         }
<span style="color: #A00000">-                                        mystream.write_function(&amp;mystream, &quot; and hostname=&#39;%s&#39;&quot;, switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                        mystream.write_function(&amp;mystream, &quot; and hostname=&#39;%s&#39;&quot;, switch_core_get_hostname());</span>
                                         switch_cache_db_persistant_execute(db, mystream.data, 1);
                                 }
                                 status = SWITCH_STATUS_SUCCESS;
<span style="color: #800080; font-weight: bold">@@ -1863,38 +1863,38 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_alias(const char *string)</span>
                         }
                         
                         if (!strcasecmp(argv[0], &quot;stickyadd&quot;) &amp;&amp; argc == 3) {
<span style="color: #A00000">-                                sql = switch_mprintf(&quot;delete from aliases where alias=&#39;%q&#39; and hostname=&#39;%q&#39;&quot;, argv[1], switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                sql = switch_mprintf(&quot;delete from aliases where alias=&#39;%q&#39; and hostname=&#39;%q&#39;&quot;, argv[1], switch_core_get_hostname());</span>
                                 switch_cache_db_persistant_execute(db, sql, 5);
                                 switch_safe_free(sql);
                                 if (db-&gt;type == SCDB_TYPE_CORE_DB) {
                                         sql = switch_mprintf(&quot;insert into aliases (sticky, alias, command, hostname) values (1, &#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;)&quot;,
<span style="color: #A00000">-                                                                                 argv[1], argv[2], switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                 argv[1], argv[2], switch_core_get_hostname());</span>
                                 } else {
                                         sql = switch_mprintf(&quot;insert into aliases (sticky, alias, command, hostname) values (1, &#39;%w&#39;,&#39;%w&#39;,&#39;%w&#39;)&quot;,
<span style="color: #A00000">-                                                                                 argv[1], argv[2], switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                 argv[1], argv[2], switch_core_get_hostname());</span>
                                 }
                                 switch_cache_db_persistant_execute(db, sql, 5);
                                 status = SWITCH_STATUS_SUCCESS;
                         } else if (!strcasecmp(argv[0], &quot;add&quot;) &amp;&amp; argc == 3) {
<span style="color: #A00000">-                                sql = switch_mprintf(&quot;delete from aliases where alias=&#39;%q&#39; and hostname=&#39;%q&#39;&quot;, argv[1], switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                sql = switch_mprintf(&quot;delete from aliases where alias=&#39;%q&#39; and hostname=&#39;%q&#39;&quot;, argv[1], switch_core_get_hostname());</span>
                                 switch_cache_db_persistant_execute(db, sql, 5);
                                 switch_safe_free(sql);
                                 if (db-&gt;type == SCDB_TYPE_CORE_DB) {
                                         sql = switch_mprintf(&quot;insert into aliases (sticky, alias, command, hostname) values (0, &#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;)&quot;,
<span style="color: #A00000">-                                                                                 argv[1], argv[2], switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                 argv[1], argv[2], switch_core_get_hostname());</span>
                                 } else {
                                         sql = switch_mprintf(&quot;insert into aliases (sticky, alias, command, hostname) values (0, &#39;%w&#39;,&#39;%w&#39;,&#39;%w&#39;)&quot;,
<span style="color: #A00000">-                                                                                 argv[1], argv[2], switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                 argv[1], argv[2], switch_core_get_hostname());</span>
                                 }
                                 switch_cache_db_persistant_execute(db, sql, 5);
                                 status = SWITCH_STATUS_SUCCESS;
                         } else if (!strcasecmp(argv[0], &quot;del&quot;) &amp;&amp; argc == 2) {
                                 char *what = argv[1];
                                 if (!strcasecmp(what, &quot;*&quot;)) {
<span style="color: #A00000">-                                        sql = switch_mprintf(&quot;delete from aliases where hostname=&#39;%q&#39;&quot;, switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                        sql = switch_mprintf(&quot;delete from aliases where hostname=&#39;%q&#39;&quot;, switch_core_get_hostname());</span>
                                         switch_cache_db_persistant_execute(db, sql, 1);
                                 } else {
<span style="color: #A00000">-                                        sql = switch_mprintf(&quot;delete from aliases where alias=&#39;%q&#39; and hostname=&#39;%q&#39;&quot;, argv[1], switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                        sql = switch_mprintf(&quot;delete from aliases where alias=&#39;%q&#39; and hostname=&#39;%q&#39;&quot;, argv[1], switch_core_get_hostname());</span>
                                         switch_cache_db_persistant_execute(db, sql, 5);
                                 }
                                 status = SWITCH_STATUS_SUCCESS;
<span style="color: #000080; font-weight: bold">diff --git a/src/switch_core.c b/src/switch_core.c</span>
<span style="color: #000080; font-weight: bold">index 43fb36d..8754305 100644</span>
<span style="color: #A00000">--- a/src/switch_core.c</span>
<span style="color: #00A000">+++ b/src/switch_core.c</span>
<span style="color: #800080; font-weight: bold">@@ -261,6 +261,11 @@ SWITCH_DECLARE(void) switch_core_dump_variables(switch_stream_handle_t *stream)</span>
         switch_mutex_unlock(runtime.global_mutex);
 }
 
<span style="color: #00A000">+SWITCH_DECLARE(const char *) switch_core_get_hostname(void)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        return runtime.hostname;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
 SWITCH_DECLARE(char *) switch_core_get_variable(const char *varname)
 {
         char *val;
<span style="color: #800080; font-weight: bold">@@ -270,6 +275,32 @@ SWITCH_DECLARE(char *) switch_core_get_variable(const char *varname)</span>
         return val;
 }
 
<span style="color: #00A000">+SWITCH_DECLARE(char *) switch_core_get_variable_dup(const char *varname)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        char *val = NULL, *v;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        switch_mutex_lock(runtime.global_var_mutex);</span>
<span style="color: #00A000">+        if ((v = (char *) switch_event_get_header(runtime.global_vars, varname))) {</span>
<span style="color: #00A000">+                val = strdup(v);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        switch_mutex_unlock(runtime.global_var_mutex);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return val;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+SWITCH_DECLARE(char *) switch_core_get_variable_pdup(const char *varname, switch_memory_pool_t *pool)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        char *val = NULL, *v;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        switch_mutex_lock(runtime.global_var_mutex);</span>
<span style="color: #00A000">+        if ((v = (char *) switch_event_get_header(runtime.global_vars, varname))) {</span>
<span style="color: #00A000">+                val = switch_core_strdup(pool, v);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        switch_mutex_unlock(runtime.global_var_mutex);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return val;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
 static void switch_core_unset_variables(void)
 {
         switch_mutex_lock(runtime.global_var_mutex);
<span style="color: #800080; font-weight: bold">@@ -1202,12 +1233,18 @@ static void switch_core_set_serial(void)</span>
 
 
         if ((fd = open(path, O_RDONLY, 0)) &lt; 0) {
<span style="color: #A00000">-                char *ip = switch_core_get_variable(&quot;local_ip_v4&quot;);</span>
<span style="color: #00A000">+                char *ip = switch_core_get_variable_dup(&quot;local_ip_v4&quot;);</span>
                 uint32_t ipi = 0;
                 switch_byte_t *byte;
                 int i = 0;
 
<span style="color: #A00000">-                switch_inet_pton(AF_INET, ip, &amp;ipi);</span>
<span style="color: #00A000">+                if (ip) {</span>
<span style="color: #00A000">+                        switch_inet_pton(AF_INET, ip, &amp;ipi);</span>
<span style="color: #00A000">+                        free(ip);</span>
<span style="color: #00A000">+                        ip = NULL;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
                 byte = (switch_byte_t *) &amp; ipi;
 
                 for (i = 0; i &lt; 8; i += 2) {
<span style="color: #800080; font-weight: bold">@@ -1237,7 +1274,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc</span>
         char guess_ip[256];
         int mask = 0;
         struct in_addr in;
<span style="color: #A00000">-        char hostname[256] = &quot;&quot;;</span>
<span style="color: #00A000">+</span>
 
         if (runtime.runlevel &gt; 0) {
                 /* one per customer */
<span style="color: #800080; font-weight: bold">@@ -1310,8 +1347,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc</span>
                 runtime.console = stdout;
         }
 
<span style="color: #A00000">-        gethostname(hostname, sizeof(hostname));</span>
<span style="color: #A00000">-        switch_core_set_variable(&quot;hostname&quot;, hostname);</span>
<span style="color: #00A000">+        gethostname(runtime.hostname, sizeof(runtime.hostname));</span>
<span style="color: #00A000">+        switch_core_set_variable(&quot;hostname&quot;, runtime.hostname);</span>
 
         switch_find_local_ip(guess_ip, sizeof(guess_ip), &amp;mask, AF_INET);
         switch_core_set_variable(&quot;local_ip_v4&quot;, guess_ip);
<span style="color: #000080; font-weight: bold">diff --git a/src/switch_core_file.c b/src/switch_core_file.c</span>
<span style="color: #000080; font-weight: bold">index 19f2354..fc7d223 100644</span>
<span style="color: #A00000">--- a/src/switch_core_file.c</span>
<span style="color: #00A000">+++ b/src/switch_core_file.c</span>
<span style="color: #800080; font-weight: bold">@@ -102,7 +102,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,</span>
                         }
 
                         if (!spool_path) {
<span style="color: #A00000">-                                spool_path = switch_core_get_variable(SWITCH_AUDIO_SPOOL_PATH_VARIABLE);</span>
<span style="color: #00A000">+                                spool_path = switch_core_get_variable_pdup(SWITCH_AUDIO_SPOOL_PATH_VARIABLE, fh-&gt;memory_pool);</span>
                         }
 
                         file_path = fh-&gt;file_path;
<span style="color: #000080; font-weight: bold">diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c</span>
<span style="color: #000080; font-weight: bold">index 2db2a0d..73890a1 100644</span>
<span style="color: #A00000">--- a/src/switch_core_sqldb.c</span>
<span style="color: #00A000">+++ b/src/switch_core_sqldb.c</span>
<span style="color: #800080; font-weight: bold">@@ -1134,7 +1134,7 @@ static void core_event_handler(switch_event_t *event)</span>
                                 new_sql() = switch_mprintf(&quot;insert into tasks values(%q,&#39;%q&#39;,&#39;%q&#39;,%q, &#39;%q&#39;)&quot;,
                                                                                    id,
                                                                                    switch_event_get_header_nil(event, &quot;task-desc&quot;),
<span style="color: #A00000">-                                                                                   switch_event_get_header_nil(event, &quot;task-group&quot;), manager ? manager : &quot;0&quot;, switch_core_get_variable(&quot;hostname&quot;)</span>
<span style="color: #00A000">+                                                                                   switch_event_get_header_nil(event, &quot;task-group&quot;), manager ? manager : &quot;0&quot;, switch_core_get_hostname()</span>
                                                                                    );
                         }
                 }
<span style="color: #800080; font-weight: bold">@@ -1142,7 +1142,7 @@ static void core_event_handler(switch_event_t *event)</span>
         case SWITCH_EVENT_DEL_SCHEDULE:
         case SWITCH_EVENT_EXE_SCHEDULE:
                 new_sql() = switch_mprintf(&quot;delete from tasks where task_id=%q and hostname=&#39;%q&#39;&quot;,
<span style="color: #A00000">-                                                                   switch_event_get_header_nil(event, &quot;task-id&quot;), switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                   switch_event_get_header_nil(event, &quot;task-id&quot;), switch_core_get_hostname());</span>
                 break;
         case SWITCH_EVENT_RE_SCHEDULE:
                 {
<span style="color: #800080; font-weight: bold">@@ -1153,7 +1153,7 @@ static void core_event_handler(switch_event_t *event)</span>
                                 new_sql() = switch_mprintf(&quot;update tasks set task_desc=&#39;%q&#39;,task_group=&#39;%q&#39;, task_sql_manager=%q where task_id=%q and hostname=&#39;%q&#39;&quot;,
                                                                                    switch_event_get_header_nil(event, &quot;task-desc&quot;),
                                                                                    switch_event_get_header_nil(event, &quot;task-group&quot;), manager ? manager : &quot;0&quot;, id,
<span style="color: #A00000">-                                                                                   switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                   switch_core_get_hostname());</span>
                         }
                 }
                 break;
<span style="color: #800080; font-weight: bold">@@ -1163,10 +1163,10 @@ static void core_event_handler(switch_event_t *event)</span>
                         
                         if (uuid) {
                                 new_sql() = switch_mprintf(&quot;delete from channels where uuid=&#39;%q&#39; and hostname=&#39;%q&#39;&quot;,
<span style="color: #A00000">-                                                                                   uuid, switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                   uuid, switch_core_get_hostname());</span>
 
                                 new_sql() = switch_mprintf(&quot;delete from calls where (caller_uuid=&#39;%q&#39; or callee_uuid=&#39;%q&#39;) and hostname=&#39;%q&#39;&quot;,
<span style="color: #A00000">-                                                                                   uuid, uuid, switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                   uuid, uuid, switch_core_get_hostname());</span>
 
                         }
                 }
<span style="color: #800080; font-weight: bold">@@ -1178,12 +1178,12 @@ static void core_event_handler(switch_event_t *event)</span>
                                                                            &quot;update calls set callee_uuid=&#39;%q&#39; where callee_uuid=&#39;%q&#39; and hostname=&#39;%q&#39;&quot;,
                                                                            switch_event_get_header_nil(event, &quot;unique-id&quot;),
                                                                            switch_event_get_header_nil(event, &quot;old-unique-id&quot;),
<span style="color: #A00000">-                                                                           switch_core_get_variable(&quot;hostname&quot;),</span>
<span style="color: #00A000">+                                                                           switch_core_get_hostname(),</span>
                                                                            switch_event_get_header_nil(event, &quot;unique-id&quot;),
                                                                            switch_event_get_header_nil(event, &quot;old-unique-id&quot;),
<span style="color: #A00000">-                                                                           switch_core_get_variable(&quot;hostname&quot;),</span>
<span style="color: #00A000">+                                                                           switch_core_get_hostname(),</span>
                                                                            switch_event_get_header_nil(event, &quot;unique-id&quot;),
<span style="color: #A00000">-                                                                           switch_event_get_header_nil(event, &quot;old-unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;)</span>
<span style="color: #00A000">+                                                                           switch_event_get_header_nil(event, &quot;old-unique-id&quot;), switch_core_get_hostname()</span>
                                                                            );
                         break;
                 }
<span style="color: #800080; font-weight: bold">@@ -1198,7 +1198,7 @@ static void core_event_handler(switch_event_t *event)</span>
                                                                    switch_event_get_header_nil(event, &quot;channel-state&quot;),
                                                                    switch_event_get_header_nil(event, &quot;channel-call-state&quot;),
                                                                    switch_event_get_header_nil(event, &quot;caller-dialplan&quot;),
<span style="color: #A00000">-                                                                   switch_event_get_header_nil(event, &quot;caller-context&quot;), switch_core_get_variable(&quot;hostname&quot;)</span>
<span style="color: #00A000">+                                                                   switch_event_get_header_nil(event, &quot;caller-context&quot;), switch_core_get_hostname()</span>
                                                                    );
                 break;
         case SWITCH_EVENT_CODEC:
<span style="color: #800080; font-weight: bold">@@ -1211,7 +1211,7 @@ static void core_event_handler(switch_event_t *event)</span>
                          switch_event_get_header_nil(event, &quot;channel-write-codec-name&quot;),
                          switch_event_get_header_nil(event, &quot;channel-write-codec-rate&quot;),
                          switch_event_get_header_nil(event, &quot;channel-write-codec-bit-rate&quot;),
<span style="color: #A00000">-                         switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                         switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_hostname());</span>
                 break;
         case SWITCH_EVENT_CHANNEL_HOLD:
         case SWITCH_EVENT_CHANNEL_UNHOLD:
<span style="color: #800080; font-weight: bold">@@ -1223,7 +1223,7 @@ static void core_event_handler(switch_event_t *event)</span>
                                                                    switch_event_get_header_nil(event, &quot;application-data&quot;),
                                                                    switch_event_get_header_nil(event, &quot;channel-presence-id&quot;),
                                                                    switch_event_get_header_nil(event, &quot;channel-presence-data&quot;),
<span style="color: #A00000">-                                                                   switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;)</span>
<span style="color: #00A000">+                                                                   switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_hostname()</span>
                                                                    );
 
         }
<span style="color: #800080; font-weight: bold">@@ -1238,7 +1238,7 @@ static void core_event_handler(switch_event_t *event)</span>
                                                                                    switch_event_get_header_nil(event, &quot;channel-presence-data&quot;),
                                                                                    switch_event_get_header_nil(event, &quot;channel-call-uuid&quot;),
                                                                                    extra_cols,
<span style="color: #A00000">-                                                                                   switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                   switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_hostname());</span>
                                 free(extra_cols);
                         } else {
                                 new_sql() = switch_mprintf(&quot;update channels set &quot;
<span style="color: #800080; font-weight: bold">@@ -1246,7 +1246,7 @@ static void core_event_handler(switch_event_t *event)</span>
                                                                                    switch_event_get_header_nil(event, &quot;channel-presence-id&quot;),
                                                                                    switch_event_get_header_nil(event, &quot;channel-presence-data&quot;),
                                                                                    switch_event_get_header_nil(event, &quot;channel-call-uuid&quot;),
<span style="color: #A00000">-                                                                                   switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                   switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_hostname());</span>
                         }
 
                 }
<span style="color: #800080; font-weight: bold">@@ -1281,7 +1281,7 @@ static void core_event_handler(switch_event_t *event)</span>
                                                                                    switch_str_nil(name),
                                                                                    switch_str_nil(number),
                                                                                    switch_event_get_header_nil(event, &quot;direction&quot;),
<span style="color: #A00000">-                                                                                   switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                   switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_hostname());</span>
 
                                 name = switch_event_get_header(event, &quot;callee-name&quot;);
                                 number = switch_event_get_header(event, &quot;callee-number&quot;);
<span style="color: #800080; font-weight: bold">@@ -1298,7 +1298,7 @@ static void core_event_handler(switch_event_t *event)</span>
                 {
                         new_sql() = switch_mprintf(&quot;update channels set callstate=&#39;%q&#39; where uuid=&#39;%q&#39; and hostname=&#39;%q&#39;&quot;,
                                                                            switch_event_get_header_nil(event, &quot;channel-call-state&quot;),
<span style="color: #A00000">-                                                                           switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                           switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_hostname());</span>
 
                 }
                 break;
<span style="color: #800080; font-weight: bold">@@ -1330,7 +1330,7 @@ static void core_event_handler(switch_event_t *event)</span>
                                                                                            switch_event_get_header_nil(event, &quot;channel-presence-id&quot;),
                                                                                            switch_event_get_header_nil(event, &quot;channel-presence-data&quot;),
                                                                                            extra_cols,
<span style="color: #A00000">-                                                                                           switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                           switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_hostname());</span>
                                         free(extra_cols);
                                 } else {
                                         new_sql() = switch_mprintf(&quot;update channels set state=&#39;%s&#39;,cid_name=&#39;%q&#39;,cid_num=&#39;%q&#39;,&quot;
<span style="color: #800080; font-weight: bold">@@ -1345,13 +1345,13 @@ static void core_event_handler(switch_event_t *event)</span>
                                                                                            switch_event_get_header_nil(event, &quot;caller-context&quot;),
                                                                                            switch_event_get_header_nil(event, &quot;channel-presence-id&quot;),
                                                                                            switch_event_get_header_nil(event, &quot;channel-presence-data&quot;),
<span style="color: #A00000">-                                                                                           switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                           switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_hostname());</span>
                                 }
                                 break;
                         default:
                                 new_sql() = switch_mprintf(&quot;update channels set state=&#39;%s&#39; where uuid=&#39;%s&#39; and hostname=&#39;%q&#39;&quot;,
                                                                                    switch_event_get_header_nil(event, &quot;channel-state&quot;),
<span style="color: #A00000">-                                                                                   switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                   switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_hostname());</span>
                                 break;
                         }
 
<span style="color: #800080; font-weight: bold">@@ -1377,7 +1377,7 @@ static void core_event_handler(switch_event_t *event)</span>
 
                         new_sql() = switch_mprintf(&quot;update channels set call_uuid=&#39;%q&#39; where uuid=&#39;%s&#39; and hostname=&#39;%q&#39;&quot;,
                                                                            switch_event_get_header_nil(event, &quot;channel-call-uuid&quot;),
<span style="color: #A00000">-                                                                           switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                           switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_hostname());</span>
 
                         if (runtime.odbc_dbtype == DBTYPE_DEFAULT) {
                                 func_name = &quot;function&quot;;
<span style="color: #800080; font-weight: bold">@@ -1404,7 +1404,7 @@ static void core_event_handler(switch_event_t *event)</span>
                                                                            callee_cid_num,
                                                                            switch_event_get_header_nil(event, &quot;Other-Leg-destination-number&quot;),
                                                                            switch_event_get_header_nil(event, &quot;Other-Leg-channel-name&quot;),
<span style="color: #A00000">-                                                                           switch_event_get_header_nil(event, &quot;Other-Leg-unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;)</span>
<span style="color: #00A000">+                                                                           switch_event_get_header_nil(event, &quot;Other-Leg-unique-id&quot;), switch_core_get_hostname()</span>
                                                                            );
                 }
                 break;
<span style="color: #800080; font-weight: bold">@@ -1413,14 +1413,14 @@ static void core_event_handler(switch_event_t *event)</span>
                         char *uuid = switch_event_get_header_nil(event, &quot;caller-unique-id&quot;);
 
                         new_sql() = switch_mprintf(&quot;delete from calls where (caller_uuid=&#39;%q&#39; or callee_uuid=&#39;%q&#39;) and hostname=&#39;%q&#39;&quot;,
<span style="color: #A00000">-                                                                           uuid, uuid, switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                           uuid, uuid, switch_core_get_hostname());</span>
                         break;
                 }
         case SWITCH_EVENT_SHUTDOWN:
                 new_sql() = switch_mprintf(&quot;delete from channels where hostname=&#39;%q&#39;;&quot;
                                                                    &quot;delete from interfaces where hostname=&#39;%q&#39;;&quot;
                                                                    &quot;delete from calls where hostname=&#39;%q&#39;&quot;,
<span style="color: #A00000">-                                                                   switch_core_get_variable(&quot;hostname&quot;), switch_core_get_variable(&quot;hostname&quot;), switch_core_get_variable(&quot;hostname&quot;)</span>
<span style="color: #00A000">+                                                                   switch_core_get_hostname(), switch_core_get_hostname(), switch_core_get_hostname()</span>
                                                                    );
                 break;
         case SWITCH_EVENT_LOG:
<span style="color: #800080; font-weight: bold">@@ -1438,7 +1438,7 @@ static void core_event_handler(switch_event_t *event)</span>
                                         switch_mprintf
                                         (&quot;insert into interfaces (type,name,description,syntax,ikey,filename,hostname) values(&#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;,&#39;%q&#39;)&quot;, type, name,
                                          switch_str_nil(description), switch_str_nil(syntax), switch_str_nil(key), switch_str_nil(filename),
<span style="color: #A00000">-                                         switch_core_get_variable(&quot;hostname&quot;)</span>
<span style="color: #00A000">+                                         switch_core_get_hostname()</span>
                                          );
                         }
                         break;
<span style="color: #800080; font-weight: bold">@@ -1449,7 +1449,7 @@ static void core_event_handler(switch_event_t *event)</span>
                         const char *name = switch_event_get_header_nil(event, &quot;name&quot;);
                         if (!zstr(type) &amp;&amp; !zstr(name)) {
                                 new_sql() = switch_mprintf(&quot;delete from interfaces where type=&#39;%q&#39; and name=&#39;%q&#39; and hostname=&#39;%q&#39;&quot;, type, name,
<span style="color: #A00000">-                                                                                   switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                   switch_core_get_hostname());</span>
                         }
                         break;
                 }
<span style="color: #800080; font-weight: bold">@@ -1461,7 +1461,7 @@ static void core_event_handler(switch_event_t *event)</span>
                                 break;
                         }
                         new_sql() = switch_mprintf(&quot;update channels set secure=&#39;%s&#39; where uuid=&#39;%s&#39; and hostname=&#39;%q&#39;&quot;,
<span style="color: #A00000">-                                                                           type, switch_event_get_header_nil(event, &quot;caller-unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;)</span>
<span style="color: #00A000">+                                                                           type, switch_event_get_header_nil(event, &quot;caller-unique-id&quot;), switch_core_get_hostname()</span>
                                                                            );
                         break;
                 }
<span style="color: #800080; font-weight: bold">@@ -1472,12 +1472,12 @@ static void core_event_handler(switch_event_t *event)</span>
                         if (!strcmp(&quot;add&quot;, op)) {
                                 new_sql() = switch_mprintf(&quot;insert into nat (port, proto, sticky, hostname) values (%s, %s, %d,&#39;%q&#39;)&quot;,
                                                                                    switch_event_get_header_nil(event, &quot;port&quot;),
<span style="color: #A00000">-                                                                                   switch_event_get_header_nil(event, &quot;proto&quot;), sticky, switch_core_get_variable(&quot;hostname&quot;)</span>
<span style="color: #00A000">+                                                                                   switch_event_get_header_nil(event, &quot;proto&quot;), sticky, switch_core_get_hostname()</span>
                                                                                    );
                         } else if (!strcmp(&quot;del&quot;, op)) {
                                 new_sql() = switch_mprintf(&quot;delete from nat where port=%s and proto=%s and hostname=&#39;%q&#39;&quot;,
                                                                                    switch_event_get_header_nil(event, &quot;port&quot;),
<span style="color: #A00000">-                                                                                   switch_event_get_header_nil(event, &quot;proto&quot;), switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                                                                                   switch_event_get_header_nil(event, &quot;proto&quot;), switch_core_get_hostname());</span>
                         } else if (!strcmp(&quot;status&quot;, op)) {
                                 /* call show nat api */
                         } else if (!strcmp(&quot;status_response&quot;, op)) {
<span style="color: #800080; font-weight: bold">@@ -1664,7 +1664,7 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_</span>
                         char sql[512] = &quot;&quot;;
                         char *tables[] = { &quot;channels&quot;, &quot;calls&quot;, &quot;interfaces&quot;, &quot;tasks&quot;, NULL };
                         int i;
<span style="color: #A00000">-                        const char *hostname = switch_core_get_variable(&quot;hostname&quot;);</span>
<span style="color: #00A000">+                        const char *hostname = switch_core_get_hostname();</span>
 
                         for (i = 0; tables[i]; i++) {
                                 switch_snprintf(sql, sizeof(sql), &quot;delete from %s where hostname=&#39;%s&#39;&quot;, tables[i], hostname);
<span style="color: #000080; font-weight: bold">diff --git a/src/switch_event.c b/src/switch_event.c</span>
<span style="color: #000080; font-weight: bold">index 003fc82..3e12ea1 100644</span>
<span style="color: #A00000">--- a/src/switch_event.c</span>
<span style="color: #00A000">+++ b/src/switch_event.c</span>
<span style="color: #800080; font-weight: bold">@@ -1673,6 +1673,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const</span>
                                         int offset = 0;
                                         int ooffset = 0;
                                         char *ptr;
<span style="color: #00A000">+                                        char *gvar = NULL;</span>
 
                                         if ((expanded = switch_event_expand_headers(event, (char *) vname)) == vname) {
                                                 expanded = NULL;
<span style="color: #800080; font-weight: bold">@@ -1689,7 +1690,9 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const</span>
                                         }
 
                                         if (!(sub_val = switch_event_get_header(event, vname))) {
<span style="color: #A00000">-                                                sub_val = switch_core_get_variable(vname);</span>
<span style="color: #00A000">+                                                if ((gvar = switch_core_get_variable_dup(vname))) {</span>
<span style="color: #00A000">+                                                        sub_val = gvar;</span>
<span style="color: #00A000">+                                                }</span>
                                         }
 
                                         if (offset || ooffset) {
<span style="color: #800080; font-weight: bold">@@ -1710,6 +1713,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const</span>
                                                 }
                                         }
 
<span style="color: #00A000">+                                        switch_safe_free(gvar);</span>
                                         switch_safe_free(expanded);
                                 } else {
                                         switch_stream_handle_t stream = { 0 };
<span style="color: #000080; font-weight: bold">diff --git a/src/switch_nat.c b/src/switch_nat.c</span>
<span style="color: #000080; font-weight: bold">index 536baee..85b0247 100644</span>
<span style="color: #A00000">--- a/src/switch_nat.c</span>
<span style="color: #00A000">+++ b/src/switch_nat.c</span>
<span style="color: #800080; font-weight: bold">@@ -45,6 +45,7 @@</span>
 
 typedef struct {
         switch_nat_type_t nat_type;
<span style="color: #00A000">+        char nat_type_str[5];</span>
         struct UPNPUrls urls;
         struct IGDdatas data;
         char *descURL;
<span style="color: #800080; font-weight: bold">@@ -420,6 +421,7 @@ SWITCH_DECLARE(void) switch_nat_init(switch_memory_pool_t *pool)</span>
                 switch_core_set_variable(&quot;nat_public_addr&quot;, nat_globals.pub_addr);
                 switch_core_set_variable(&quot;nat_private_addr&quot;, nat_globals.pvt_addr);
                 switch_core_set_variable(&quot;nat_type&quot;, nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? &quot;pmp&quot; : &quot;upnp&quot;);
<span style="color: #00A000">+                strncpy(nat_globals.nat_type_str, nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? &quot;pmp&quot; : &quot;upnp&quot;, sizeof(nat_globals.nat_type_str) - 1);</span>
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;NAT detected type: %s, ExtIP: &#39;%s&#39;\n&quot;,
                                                   nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? &quot;pmp&quot; : &quot;upnp&quot;, nat_globals.pub_addr);
 
<span style="color: #800080; font-weight: bold">@@ -564,6 +566,11 @@ static switch_status_t switch_nat_del_mapping_upnp(switch_port_t port, switch_na</span>
         return status;
 }
 
<span style="color: #00A000">+SWITCH_DECLARE(const char *) switch_nat_get_type(void)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        return nat_globals.nat_type_str;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
 SWITCH_DECLARE(switch_status_t) switch_nat_add_mapping_internal(switch_port_t port, switch_nat_ip_proto_t proto, switch_port_t * external_port,
                                                                                                                                 switch_bool_t sticky, switch_bool_t publish)
 {
<span style="color: #000080; font-weight: bold">diff --git a/src/switch_rtp.c b/src/switch_rtp.c</span>
<span style="color: #000080; font-weight: bold">index 4acadfe..e8d7558 100644</span>
<span style="color: #A00000">--- a/src/switch_rtp.c</span>
<span style="color: #00A000">+++ b/src/switch_rtp.c</span>
<span style="color: #800080; font-weight: bold">@@ -791,8 +791,8 @@ static void zrtp_logger(int level, const char *data, int len, int offset)</span>
 SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool_t *pool)
 {
 #ifdef ENABLE_ZRTP
<span style="color: #A00000">-        const char *zid_string = switch_core_get_variable(&quot;switch_serial&quot;);</span>
<span style="color: #A00000">-        const char *zrtp_enabled = switch_core_get_variable(&quot;zrtp_enabled&quot;);</span>
<span style="color: #00A000">+        const char *zid_string = switch_core_get_variable_pdup(&quot;switch_serial&quot;, pool);</span>
<span style="color: #00A000">+        const char *zrtp_enabled = switch_core_get_variable_pdup(&quot;zrtp_enabled&quot;, pool);</span>
         zrtp_config_t zrtp_config;
         char zrtp_cache_path[256] = &quot;&quot;;
         zrtp_on = zrtp_enabled ? switch_true(zrtp_enabled) : 0;
<span style="color: #000080; font-weight: bold">diff --git a/src/switch_utils.c b/src/switch_utils.c</span>
<span style="color: #000080; font-weight: bold">index 850b07f..eb5ed7f 100644</span>
<span style="color: #A00000">--- a/src/switch_utils.c</span>
<span style="color: #00A000">+++ b/src/switch_utils.c</span>
<span style="color: #800080; font-weight: bold">@@ -1154,8 +1154,8 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int *ma</span>
 {
         switch_status_t status = SWITCH_STATUS_FALSE;
         char *base;
<span style="color: #A00000">-        const char *force_local_ip_v4 = switch_core_get_variable(&quot;force_local_ip_v4&quot;);</span>
<span style="color: #A00000">-        const char *force_local_ip_v6 = switch_core_get_variable(&quot;force_local_ip_v6&quot;);</span>
<span style="color: #00A000">+        char *force_local_ip_v4 = switch_core_get_variable_dup(&quot;force_local_ip_v4&quot;);</span>
<span style="color: #00A000">+        char *force_local_ip_v6 = switch_core_get_variable_dup(&quot;force_local_ip_v6&quot;);</span>
 
 #ifdef WIN32
         SOCKET tmp_socket;
<span style="color: #800080; font-weight: bold">@@ -1176,14 +1176,20 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int *ma</span>
         case AF_INET:
                 if (force_local_ip_v4) {
                         switch_copy_string(buf, force_local_ip_v4, len);
<span style="color: #00A000">+                        switch_safe_free(force_local_ip_v4);</span>
<span style="color: #00A000">+                        switch_safe_free(force_local_ip_v6);</span>
                         return SWITCH_STATUS_SUCCESS;
                 }
         case AF_INET6:
                 if (force_local_ip_v6) {
                         switch_copy_string(buf, force_local_ip_v6, len);
<span style="color: #00A000">+                        switch_safe_free(force_local_ip_v4);</span>
<span style="color: #00A000">+                        switch_safe_free(force_local_ip_v6);</span>
                         return SWITCH_STATUS_SUCCESS;
                 }
         default:
<span style="color: #00A000">+                switch_safe_free(force_local_ip_v4);</span>
<span style="color: #00A000">+                switch_safe_free(force_local_ip_v6);</span>
                 break;
         }
 
<span style="color: #000080; font-weight: bold">diff --git a/src/switch_xml.c b/src/switch_xml.c</span>
<span style="color: #000080; font-weight: bold">index 964a769..4c30d98 100644</span>
<span style="color: #A00000">--- a/src/switch_xml.c</span>
<span style="color: #00A000">+++ b/src/switch_xml.c</span>
<span style="color: #800080; font-weight: bold">@@ -1208,11 +1208,12 @@ static char *expand_vars(char *buf, char *ebuf, switch_size_t elen, switch_size_</span>
                                 var = rp;
                                 *e++ = &#39;\0&#39;;
                                 rp = e;
<span style="color: #A00000">-                                if ((val = switch_core_get_variable(var))) {</span>
<span style="color: #00A000">+                                if ((val = switch_core_get_variable_dup(var))) {</span>
                                         char *p;
                                         for (p = val; p &amp;&amp; *p &amp;&amp; wp &lt;= ep; p++) {
                                                 *wp++ = *p;
                                         }
<span style="color: #00A000">+                                        free(val);</span>
                                 }
                                 continue;
                         } else if (err) {
</pre></div>
<div class="highlight"><pre>committer: Brian West
comments: 
FS-3023

<span style="color: #000080; font-weight: bold">diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h</span>
<span style="color: #000080; font-weight: bold">index 0bd2a8b..f4a0922 100644</span>
<span style="color: #A00000">--- a/src/include/switch_cpp.h</span>
<span style="color: #00A000">+++ b/src/include/switch_cpp.h</span>
<span style="color: #800080; font-weight: bold">@@ -68,6 +68,10 @@ Note that the first parameter to the new operator is implicitly handled by c++..</span>
 SWITCH_DECLARE(void) consoleLog(char *level_str, char *msg);
 SWITCH_DECLARE(void) consoleCleanLog(char *msg);
 
<span style="color: #00A000">+SWITCH_DECLARE(bool) email(char *to, char *from, char *headers = NULL, char *body = NULL,</span>
<span style="color: #00A000">+    char *file = NULL, char *convert_cmd = NULL, char *convert_ext = NULL);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
          class CoreSession;
 
          class IVRMenu {
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx</span>
<span style="color: #000080; font-weight: bold">index e91de6d..71e9f99 100644</span>
<span style="color: #A00000">--- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx</span>
<span style="color: #00A000">+++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx</span>
<span style="color: #800080; font-weight: bold">@@ -33352,6 +33352,30 @@ SWIGEXPORT void SWIGSTDCALL CSharp_consoleCleanLog(char * jarg1) {</span>
 }
 
 
<span style="color: #00A000">+SWIGEXPORT unsigned int SWIGSTDCALL CSharp_email(char * jarg1, char * jarg2, char * jarg3, char * jarg4, char * jarg5, char * jarg6, char * jarg7) {</span>
<span style="color: #00A000">+  unsigned int jresult ;</span>
<span style="color: #00A000">+  char *arg1 = (char *) 0 ;</span>
<span style="color: #00A000">+  char *arg2 = (char *) 0 ;</span>
<span style="color: #00A000">+  char *arg3 = (char *) NULL ;</span>
<span style="color: #00A000">+  char *arg4 = (char *) NULL ;</span>
<span style="color: #00A000">+  char *arg5 = (char *) NULL ;</span>
<span style="color: #00A000">+  char *arg6 = (char *) NULL ;</span>
<span style="color: #00A000">+  char *arg7 = (char *) NULL ;</span>
<span style="color: #00A000">+  bool result;</span>
<span style="color: #00A000">+  </span>
<span style="color: #00A000">+  arg1 = (char *)jarg1; </span>
<span style="color: #00A000">+  arg2 = (char *)jarg2; </span>
<span style="color: #00A000">+  arg3 = (char *)jarg3; </span>
<span style="color: #00A000">+  arg4 = (char *)jarg4; </span>
<span style="color: #00A000">+  arg5 = (char *)jarg5; </span>
<span style="color: #00A000">+  arg6 = (char *)jarg6; </span>
<span style="color: #00A000">+  arg7 = (char *)jarg7; </span>
<span style="color: #00A000">+  result = (bool)email(arg1,arg2,arg3,arg4,arg5,arg6,arg7);</span>
<span style="color: #00A000">+  jresult = result; </span>
<span style="color: #00A000">+  return jresult;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
 SWIGEXPORT void * SWIGSTDCALL CSharp_new_IvrMenu(void * jarg1, char * jarg2, char * jarg3, char * jarg4, char * jarg5, char * jarg6, char * jarg7, char * jarg8, char * jarg9, char * jarg10, int jarg11, int jarg12, int jarg13, int jarg14, int jarg15, int jarg16) {
   void * jresult ;
   IVRMenu *arg1 = (IVRMenu *) 0 ;
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs</span>
<span style="color: #000080; font-weight: bold">index 1f02c3f..c640199 100644</span>
<span style="color: #A00000">--- a/src/mod/languages/mod_managed/managed/swig.cs</span>
<span style="color: #00A000">+++ b/src/mod/languages/mod_managed/managed/swig.cs</span>
<span style="color: #800080; font-weight: bold">@@ -5364,6 +5364,11 @@ public class freeswitch {</span>
     freeswitchPINVOKE.consoleCleanLog(msg);
   }
 
<span style="color: #00A000">+  public static bool email(string to, string from, string headers, string body, string file, string convert_cmd, string convert_ext) {</span>
<span style="color: #00A000">+    bool ret = freeswitchPINVOKE.email(to, from, headers, body, file, convert_cmd, convert_ext);</span>
<span style="color: #00A000">+    return ret;</span>
<span style="color: #00A000">+  }</span>
<span style="color: #00A000">+</span>
   public static void console_log(string level_str, string msg) {
     freeswitchPINVOKE.console_log(level_str, msg);
   }
<span style="color: #800080; font-weight: bold">@@ -13588,6 +13593,9 @@ class freeswitchPINVOKE {</span>
   [DllImport(&quot;mod_managed&quot;, EntryPoint=&quot;CSharp_consoleCleanLog&quot;)]
   public static extern void consoleCleanLog(string jarg1);
 
<span style="color: #00A000">+  [DllImport(&quot;mod_managed&quot;, EntryPoint=&quot;CSharp_email&quot;)]</span>
<span style="color: #00A000">+  public static extern bool email(string jarg1, string jarg2, string jarg3, string jarg4, string jarg5, string jarg6, string jarg7);</span>
<span style="color: #00A000">+</span>
   [DllImport(&quot;mod_managed&quot;, EntryPoint=&quot;CSharp_new_IvrMenu&quot;)]
   public static extern IntPtr new_IvrMenu(HandleRef jarg1, string jarg2, string jarg3, string jarg4, string jarg5, string jarg6, string jarg7, string jarg8, string jarg9, string jarg10, int jarg11, int jarg12, int jarg13, int jarg14, int jarg15, int jarg16);
 
<span style="color: #000080; font-weight: bold">diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp</span>
<span style="color: #000080; font-weight: bold">index bbcd05d..c62946b 100644</span>
<span style="color: #A00000">--- a/src/switch_cpp.cpp</span>
<span style="color: #00A000">+++ b/src/switch_cpp.cpp</span>
<span style="color: #800080; font-weight: bold">@@ -1195,6 +1195,13 @@ SWITCH_DECLARE(void) console_clean_log(char *msg)</span>
     switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN,SWITCH_LOG_DEBUG, &quot;%s&quot;, switch_str_nil(msg));
 }
 
<span style="color: #00A000">+SWITCH_DECLARE(bool) email(char *to, char *from, char *headers, char *body, char *file, char *convert_cmd, char *convert_ext)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+    if (switch_simple_email(to, from, headers, body, file, convert_cmd, convert_ext) == SWITCH_TRUE) {</span>
<span style="color: #00A000">+      return true;</span>
<span style="color: #00A000">+    }</span>
<span style="color: #00A000">+    return false;</span>
<span style="color: #00A000">+}</span>
 
 SWITCH_DECLARE(void) msleep(unsigned ms)
 {
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
FS-3024

<span style="color: #000080; font-weight: bold">diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c</span>
<span style="color: #000080; font-weight: bold">index 35311c9..2db2a0d 100644</span>
<span style="color: #A00000">--- a/src/switch_core_sqldb.c</span>
<span style="color: #00A000">+++ b/src/switch_core_sqldb.c</span>
<span style="color: #800080; font-weight: bold">@@ -1409,9 +1409,13 @@ static void core_event_handler(switch_event_t *event)</span>
                 }
                 break;
         case SWITCH_EVENT_CHANNEL_UNBRIDGE:
<span style="color: #A00000">-                new_sql() = switch_mprintf(&quot;delete from calls where (caller_uuid=&#39;%s&#39; or callee_uuid=&#39;%q&#39;) and hostname=&#39;%q&#39;&quot;,</span>
<span style="color: #A00000">-                                                                   switch_event_get_header_nil(event, &quot;caller-unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #A00000">-                break;</span>
<span style="color: #00A000">+                {</span>
<span style="color: #00A000">+                        char *uuid = switch_event_get_header_nil(event, &quot;caller-unique-id&quot;);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        new_sql() = switch_mprintf(&quot;delete from calls where (caller_uuid=&#39;%q&#39; or callee_uuid=&#39;%q&#39;) and hostname=&#39;%q&#39;&quot;,</span>
<span style="color: #00A000">+                                                                           uuid, uuid, switch_core_get_variable(&quot;hostname&quot;));</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                }</span>
         case SWITCH_EVENT_SHUTDOWN:
                 new_sql() = switch_mprintf(&quot;delete from channels where hostname=&#39;%q&#39;;&quot;
                                                                    &quot;delete from interfaces where hostname=&#39;%q&#39;;&quot;
</pre></div>
========================================================================<pre>

Summary of changes:
 Freeswitch.2010.sln                                |   24 +-
 build/modules.conf.in                              |    1 +
 conf/autoload_configs/modules.conf.xml             |    1 +
 conf/autoload_configs/switch.conf.xml              |    4 +
 fscomm/widgets/codecwidget.cpp                     |    2 +
 libs/esl/fs_cli.c                                  |   44 +-
 libs/freetdm/mod_freetdm/mod_freetdm.c             |    7 +
 libs/ilbc/src/iLBC_decode.c                        |    2 +
 libs/openzap/mod_openzap/mod_openzap.c             |    6 +-
 libs/portaudio/build/msvc/portaudio.2010.vcxproj   |  136 +--
 .../sofia/libsofia_sip_ua_static.2010.vcxproj      |    6 +
 src/include/private/switch_core_pvt.h              |    1 +
 src/include/switch_core.h                          |    3 +
 src/include/switch_cpp.h                           |    4 +
 src/include/switch_nat.h                           |    2 +-
 src/mod/applications/mod_commands/mod_commands.c   |   29 +-
 src/mod/applications/mod_dptools/mod_dptools.c     |   25 +-
 src/mod/applications/mod_fsk/mod_fsk.c             |    4 +-
 src/mod/applications/mod_redis/mod_redis.c         |   10 +-
 src/mod/applications/mod_voicemail/mod_voicemail.c |    6 +-
 src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c          |   51 +-
 src/mod/codecs/mod_opus/Makefile                   |   28 +
 .../{mod_celt/mod_celt.c => mod_opus/mod_opus.c}   |  153 ++--
 .../mod_dialplan_asterisk/mod_dialplan_asterisk.c  |    6 +-
 src/mod/endpoints/mod_dingaling/mod_dingaling.c    |    4 +-
 src/mod/endpoints/mod_khomp/src/khomp_pvt.cpp      |    3 +-
 src/mod/endpoints/mod_portaudio/mod_portaudio.c    | 1046 +++++++++++++-------
 src/mod/endpoints/mod_sofia/mod_sofia.c            |    4 +-
 src/mod/endpoints/mod_sofia/sofia.c                |   11 +-
 src/mod/endpoints/mod_sofia/sofia_glue.c           |   27 +-
 src/mod/endpoints/mod_sofia/sofia_presence.c       |   62 +-
 .../mod_event_socket/mod_event_socket.c            |    4 +-
 src/mod/formats/mod_file_string/mod_file_string.c  |    2 +-
 src/mod/languages/mod_managed/freeswitch_wrap.cxx  |   24 +
 src/mod/languages/mod_managed/managed/swig.cs      |    8 +
 .../languages/mod_spidermonkey/mod_spidermonkey.c  |    3 +-
 src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c          |    6 +-
 src/switch_channel.c                               |   11 +-
 src/switch_console.c                               |   32 +-
 src/switch_core.c                                  |   49 +-
 src/switch_core_file.c                             |    2 +-
 src/switch_core_session.c                          |   15 +
 src/switch_core_sqldb.c                            |   64 +-
 src/switch_cpp.cpp                                 |    7 +
 src/switch_event.c                                 |    7 +-
 src/switch_nat.c                                   |    7 +
 src/switch_rtp.c                                   |    8 +-
 src/switch_utils.c                                 |   10 +-
 src/switch_xml.c                                   |    3 +-
 49 files changed, 1294 insertions(+), 680 deletions(-)
 create mode 100644 src/mod/codecs/mod_opus/Makefile
 copy src/mod/codecs/{mod_celt/mod_celt.c => mod_opus/mod_opus.c} (52%)
</pre>
<p>this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email<br />
For more info, see <a href="http://blog.chomperstomp.com/?p=630">http://blog.chomperstomp.com/?p=630</a>
-- <br />
FreeSWITCH Source</p>