<h1>Project "FreeSWITCH Source" received a push.</h1>
<h2>branch: master updated</h2>
<pre>
via: 804fc61a6c28f85321614ab74ba3986e2cd7a771 (commit)
via: f64b03bd8b25deb191fd456a1854b02fd73626fc (commit)
via: bcb2262fdc48b36bd2e6bfe45adcbaecd1d091ee (commit)
via: f0a31e1bfff2d49d97bc0ee83627c426fa311bfc (commit)
via: 526e6fe48cadc9418d64f2b639bad68d8883dcdd (commit)
via: 8c12162a9d92ceac55c6305f2336efcf7157b923 (commit)
via: bab7a2392f955facbb91d0f30512682e2b38773e (commit)
via: 12c13e115b96e9e036bd65655c1f12a72a83510e (commit)
via: cf83f9c381a6abb988efc41b8711271b4665b79e (commit)
via: 080c5ae98167e590bebf698439c550bdb656925e (commit)
via: 0806c3880104fff154802adb010713365ef6a0ed (commit)
via: d4b5b07b2a76404ed8bf5adf8bc2bc9c0cbd9f04 (commit)
via: 2b4f163826132cf55698008a22c065374320796a (commit)
via: 7386b9f8f55e6b2648bcfb3f9dafaf62dccd772e (commit)
via: 0d5fcf65a0fef932f32874da6f4bdddb69279c53 (commit)
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: 673678509f0f3ea0464ea45798c0cdbc4843946b (commit)
via: 45ec088753031fc60b1b1abeb25536b7ac042374 (commit)
via: 53aeb1c1a71e6546950721d9f79f4a6131eb3071 (commit)
via: 4371d3c804d890315ca623e2930286154d80a9a8 (commit)
via: 231a7ffaa19886653705c217a73d8e25b705503c (commit)
via: 9a8eea27feb6f300d5adeb078cad82974681bca7 (commit)
via: f37390f0a7f1ca636d54c23d6873510fcf26e91e (commit)
via: 1388ed811a2369b26778c4cce158691f285c45b4 (commit)
from: 428ef9666734805fa7f97f8291c06252a4f1b798 (commit)
</pre>= COMMIT LOG ===========================================================
<div class="highlight"><pre>committer: David Yat Sin
comments:
Merge branch 'master' of git.sangoma.com:smg_freeswitch
</pre></div>
<div class="highlight"><pre>committer: Moises Silva
comments:
Merge remote branch 'fsorig/master'
</pre></div>
<div class="highlight"><pre>committer: Daniel Swarbrick
comments:
major factor of pgsql field handling
<span style="color: #000080; font-weight: bold">diff --git a/conf/autoload_configs/cdr_pg_csv.conf.xml b/conf/autoload_configs/cdr_pg_csv.conf.xml</span>
<span style="color: #000080; font-weight: bold">index 427bf2d..4fec817 100644</span>
<span style="color: #A00000">--- a/conf/autoload_configs/cdr_pg_csv.conf.xml</span>
<span style="color: #00A000">+++ b/conf/autoload_configs/cdr_pg_csv.conf.xml</span>
<span style="color: #800080; font-weight: bold">@@ -16,10 +16,25 @@</span>
<!-- This is like the info app but after the call is hung up -->
<!--<param name="debug" value="true"/>-->
<span style="color: #A00000">-</span>
<span style="color: #A00000">- <param name="default-template" value="example"/></span>
</settings>
<span style="color: #A00000">- <templates></span>
<span style="color: #A00000">- <template name="example">"${local_ip_v4}","${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}","${accountcode}","${read_codec}","${write_codec}","${sip_hangup_disposition}","${ani}"</template></span>
<span style="color: #A00000">- </templates></span>
<span style="color: #00A000">+ <schema></span>
<span style="color: #00A000">+ <field var="local_ip_v4"/></span>
<span style="color: #00A000">+ <field var="caller_id_name"/></span>
<span style="color: #00A000">+ <field var="caller_id_number"/></span>
<span style="color: #00A000">+ <field var="destination_number"/></span>
<span style="color: #00A000">+ <field var="context"/></span>
<span style="color: #00A000">+ <field var="start_stamp"/></span>
<span style="color: #00A000">+ <field var="answer_stamp"/></span>
<span style="color: #00A000">+ <field var="end_stamp"/></span>
<span style="color: #00A000">+ <field var="duration" quote="false"/></span>
<span style="color: #00A000">+ <field var="billsec" quote="false"/></span>
<span style="color: #00A000">+ <field var="hangup_cause"/></span>
<span style="color: #00A000">+ <field var="uuid"/></span>
<span style="color: #00A000">+ <field var="bleg_uuid"/></span>
<span style="color: #00A000">+ <field var="accountcode"/></span>
<span style="color: #00A000">+ <field var="read_codec"/></span>
<span style="color: #00A000">+ <field var="write_codec"/></span>
<span style="color: #00A000">+ <!-- <field var="sip_hangup_disposition"/> --></span>
<span style="color: #00A000">+ <!-- <field var="ani"/> --></span>
<span style="color: #00A000">+ </schema></span>
</configuration>
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c b/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c</span>
<span style="color: #000080; font-weight: bold">index 1ec56bd..51194f4 100644</span>
<span style="color: #A00000">--- a/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c</span>
<span style="color: #00A000">+++ b/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c</span>
<span style="color: #800080; font-weight: bold">@@ -59,28 +59,34 @@ typedef struct {</span>
        switch_mutex_t *mutex;
} cdr_fd_t;
<span style="color: #A00000">-const char *default_template =</span>
<span style="color: #A00000">-        "\"${local_ip_v4}\",\"${caller_id_name}\",\"${caller_id_number}\",\"${destination_number}\",\"${context}\",\"${start_stamp}\","</span>
<span style="color: #A00000">-        "\"${answer_stamp}\",\"${end_stamp}\",\"${duration}\",\"${billsec}\",\"${hangup_cause}\",\"${uuid}\",\"${bleg_uuid}\",\"${accountcode}\","</span>
<span style="color: #A00000">-        "\"${read_codec}\",\"${write_codec}\"";</span>
<span style="color: #00A000">+typedef struct {</span>
<span style="color: #00A000">+        char *col_name;</span>
<span style="color: #00A000">+        char *var_name;</span>
<span style="color: #00A000">+        switch_bool_t quote;</span>
<span style="color: #00A000">+        switch_bool_t not_null;</span>
<span style="color: #00A000">+} cdr_field_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+typedef struct {</span>
<span style="color: #00A000">+        char *columns;</span>
<span style="color: #00A000">+        cdr_field_t fields[1];</span>
<span style="color: #00A000">+} db_schema_t;</span>
static struct {
        switch_memory_pool_t *pool;
        switch_hash_t *fd_hash;
<span style="color: #A00000">-        switch_hash_t *template_hash;</span>
        int shutdown;
        char *db_info;
        char *db_table;
<span style="color: #00A000">+        db_schema_t *db_schema;</span>
        PGconn *db_connection;
<span style="color: #00A000">+        switch_mutex_t *db_mutex;</span>
        int db_online;
        cdr_leg_t legs;
        char *spool_dir;
        spool_format_t spool_format;
        int rotate;
        int debug;
<span style="color: #A00000">-        char *default_template;</span>
<span style="color: #A00000">-        switch_mutex_t *db_mutex;</span>
<span style="color: #A00000">-} globals = { 0 };</span>
<span style="color: #00A000">+} globals;</span>
static switch_xml_config_enum_item_t config_opt_cdr_leg_enum[] = {
{"a", CDR_LEG_A},
<span style="color: #800080; font-weight: bold">@@ -110,7 +116,6 @@ static switch_xml_config_item_t config_settings[] = {</span>
        /* key, type, flags, ptr, default_value, data, syntax, helptext */
        SWITCH_CONFIG_ITEM_STRING_STRDUP("db-info", CONFIG_RELOADABLE, &globals.db_info, "dbname=cdr", NULL, NULL),
        SWITCH_CONFIG_ITEM_STRING_STRDUP("db-table", CONFIG_RELOADABLE, &globals.db_table, "cdr", NULL, NULL),
<span style="color: #A00000">-        SWITCH_CONFIG_ITEM_STRING_STRDUP("default-template", CONFIG_RELOADABLE, &globals.default_template, "default", NULL, NULL),</span>
        SWITCH_CONFIG_ITEM("legs", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &globals.legs, (void *) CDR_LEG_A, &config_opt_cdr_leg_enum, "a|b|ab", NULL),
        SWITCH_CONFIG_ITEM("spool-format", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &globals.spool_format, (void *) SPOOL_FORMAT_CSV, &config_opt_spool_format_enum, "csv|sql", "Disk spool format to use if SQL insert fails."),
        SWITCH_CONFIG_ITEM("rotate-on-hup", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &globals.rotate, SWITCH_FALSE, NULL, NULL, NULL),
<span style="color: #800080; font-weight: bold">@@ -239,135 +244,13 @@ static void spool_cdr(const char *path, const char *log_line)</span>
        switch_safe_free(log_line_lf);
}
<span style="color: #A00000">-static switch_status_t insert_cdr(const char * const template, const char * const cdr)</span>
<span style="color: #00A000">+static switch_status_t insert_cdr(const char *values)</span>
{
<span style="color: #A00000">-        char *columns, *values;</span>
<span style="color: #A00000">-        char *p, *q;</span>
<span style="color: #A00000">-        unsigned vlen;</span>
<span style="color: #A00000">-        char *nullValues, *temp, *tp;</span>
<span style="color: #A00000">-        int nullCounter = 0, charCounter = 0;</span>
        char *sql = NULL, *path = NULL;
        PGresult *res;
<span style="color: #A00000">-        if (!template || !*template || !cdr || !*cdr) {</span>
<span style="color: #A00000">-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Bad parameter\n");</span>
<span style="color: #A00000">-                return SWITCH_STATUS_FALSE;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        /* Build comma-separated list of field names by dropping $ { } ; chars */</span>
<span style="color: #A00000">-        switch_strdup(columns, template);</span>
<span style="color: #A00000">-        for (p = columns, q = columns; *p; ++p) {</span>
<span style="color: #A00000">-                switch (*p) {</span>
<span style="color: #A00000">-                        case '$': case '"': case '{': case '}': case ';':</span>
<span style="color: #A00000">-                                break;</span>
<span style="color: #A00000">-                        default:</span>
<span style="color: #A00000">-                                *q++ = *p;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        *q = '\0';</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        /*</span>
<span style="color: #A00000">-         * In the expanded vars, replace double quotes (") with single quotes (')</span>
<span style="color: #A00000">-         * for correct PostgreSQL syntax, and replace semi-colon with space to</span>
<span style="color: #A00000">-         * prevent SQL injection attacks</span>
<span style="color: #A00000">-         */</span>
<span style="color: #A00000">-        switch_strdup(values, cdr);</span>
<span style="color: #A00000">-        for (p = values; *p; ++p) {</span>
<span style="color: #A00000">-                switch(*p) {</span>
<span style="color: #A00000">-                        case '"':</span>
<span style="color: #A00000">-                                *p = '\'';</span>
<span style="color: #A00000">-                                break;</span>
<span style="color: #A00000">-                        case ';':</span>
<span style="color: #A00000">-                                *p = ' ';</span>
<span style="color: #A00000">-                                break;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        vlen = p - values;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        /*</span>
<span style="color: #A00000">-         * Patch for changing empty strings ('') in the expanded variables to</span>
<span style="color: #A00000">-         * PostgreSQL null</span>
<span style="color: #A00000">-         */</span>
<span style="color: #A00000">-        for (p = values; *p; ++p) {</span>
<span style="color: #A00000">-                if (*p == ',') {</span>
<span style="color: #A00000">-                        if (charCounter == 0) {</span>
<span style="color: #A00000">-                                nullCounter++;</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                        charCounter = 0;</span>
<span style="color: #A00000">-                } else if (*p != ' ' && *p != '\'') {</span>
<span style="color: #A00000">-                        charCounter++;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (charCounter == 0) {</span>
<span style="color: #A00000">-                nullCounter++;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        nullCounter *= 4;</span>
<span style="color: #A00000">-        vlen += nullCounter;</span>
<span style="color: #A00000">-        switch_zmalloc(nullValues, strlen(values) + nullCounter + 1);</span>
<span style="color: #A00000">-        charCounter = 0;</span>
<span style="color: #A00000">-        temp = nullValues;</span>
<span style="color: #A00000">-        tp = nullValues;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        for (p = values; *p; ++tp, ++p) {</span>
<span style="color: #A00000">-                if (*p == ',') {</span>
<span style="color: #A00000">-                        if (charCounter == 0) {</span>
<span style="color: #A00000">-                                temp++;</span>
<span style="color: #A00000">-                                *temp = 'n';</span>
<span style="color: #A00000">-                                temp++;</span>
<span style="color: #A00000">-                                if (temp == tp) tp++;</span>
<span style="color: #A00000">-                                *temp = 'u';</span>
<span style="color: #A00000">-                                temp++;</span>
<span style="color: #A00000">-                                if (temp == tp) tp++;</span>
<span style="color: #A00000">-                                *temp = 'l';</span>
<span style="color: #A00000">-                                temp++;</span>
<span style="color: #A00000">-                                if (temp == tp) tp++;</span>
<span style="color: #A00000">-                                *temp = 'l';</span>
<span style="color: #A00000">-                                temp++;</span>
<span style="color: #A00000">-                                while (temp != tp) {</span>
<span style="color: #A00000">-                                        *temp = ' ';</span>
<span style="color: #A00000">-                                        temp++;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                        charCounter = 0;</span>
<span style="color: #A00000">-                        temp = tp;</span>
<span style="color: #A00000">-                } else if (*p != ' ' && *p != '\'') {</span>
<span style="color: #A00000">-                        charCounter++;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                *tp = *p;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (charCounter == 0) {</span>
<span style="color: #A00000">-                temp++;</span>
<span style="color: #A00000">-                *temp = 'n';</span>
<span style="color: #A00000">-                temp++;</span>
<span style="color: #A00000">-                if (temp == tp) tp++;</span>
<span style="color: #A00000">-                *temp = 'u';</span>
<span style="color: #A00000">-                temp++;</span>
<span style="color: #A00000">-                if (temp == tp) tp++;</span>
<span style="color: #A00000">-                *temp = 'l';</span>
<span style="color: #A00000">-                temp++;</span>
<span style="color: #A00000">-                if (temp == tp) tp++;</span>
<span style="color: #A00000">-                *temp = 'l';</span>
<span style="color: #A00000">-                temp++;</span>
<span style="color: #A00000">-                while (temp != tp) {</span>
<span style="color: #A00000">-                        *temp = ' ';</span>
<span style="color: #A00000">-                        temp++;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        charCounter = 0;</span>
<span style="color: #A00000">-        temp = tp;</span>
<span style="color: #A00000">-        *tp = 0;</span>
<span style="color: #A00000">-        tp = values;</span>
<span style="color: #A00000">-        values = nullValues;</span>
<span style="color: #A00000">-        switch_safe_free(tp);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        sql = switch_mprintf("INSERT INTO %s (%s) VALUES (%s);", globals.db_table, columns, values);</span>
<span style="color: #00A000">+        sql = switch_mprintf("INSERT INTO %s (%s) VALUES (%s);", globals.db_table, globals.db_schema->columns, values);</span>
        assert(sql);
<span style="color: #A00000">-        switch_safe_free(columns);</span>
<span style="color: #A00000">-        switch_safe_free(values);</span>
        if (globals.debug) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Query: \"%s\"\n", sql);
<span style="color: #800080; font-weight: bold">@@ -415,7 +298,7 @@ static switch_status_t insert_cdr(const char * const template, const char * cons</span>
        } else {
                path = switch_mprintf("%s%scdr-spool.csv", globals.spool_dir, SWITCH_PATH_SEPARATOR);
                assert(path);
<span style="color: #A00000">-                spool_cdr(path, cdr);</span>
<span style="color: #00A000">+                spool_cdr(path, values);</span>
        }
        switch_safe_free(path);
<span style="color: #800080; font-weight: bold">@@ -428,8 +311,10 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)</span>
{
        switch_channel_t *channel = switch_core_session_get_channel(session);
        switch_status_t status = SWITCH_STATUS_SUCCESS;
<span style="color: #A00000">-        const char *template_str = NULL;</span>
<span style="color: #A00000">-        char *expanded_vars = NULL;</span>
<span style="color: #00A000">+        char *values = NULL, *tmp = NULL, *pq_var = NULL;</span>
<span style="color: #00A000">+        const char *var = NULL;</span>
<span style="color: #00A000">+        cdr_field_t *cdr_field = NULL;</span>
<span style="color: #00A000">+        switch_size_t len, offset;</span>
        if (globals.shutdown) {
                return SWITCH_STATUS_SUCCESS;
<span style="color: #800080; font-weight: bold">@@ -465,24 +350,40 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)</span>
                }
        }
<span style="color: #A00000">-        template_str = (const char *) switch_core_hash_find(globals.template_hash, globals.default_template);</span>
<span style="color: #00A000">+        switch_zmalloc(values, 1);</span>
<span style="color: #00A000">+        offset = 0;</span>
<span style="color: #A00000">-        if (!template_str) {</span>
<span style="color: #A00000">-                template_str = default_template;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        for (cdr_field = globals.db_schema->fields; cdr_field->var_name; cdr_field++) {</span>
<span style="color: #00A000">+                if ((var = switch_channel_get_variable(channel, cdr_field->var_name))) {</span>
<span style="color: #00A000">+                        /* Allocate sufficient buffer for PQescapeString */</span>
<span style="color: #00A000">+                        len = strlen(var);</span>
<span style="color: #00A000">+                        tmp = switch_core_session_alloc(session, len * 2 + 1);</span>
<span style="color: #00A000">+                        PQescapeString(tmp, var, len);</span>
<span style="color: #00A000">+                        var = tmp;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #A00000">-        expanded_vars = switch_channel_expand_variables(channel, template_str);</span>
<span style="color: #00A000">+                if (cdr_field->quote) {</span>
<span style="color: #00A000">+                        if ((cdr_field->not_null == SWITCH_FALSE) && zstr(var)) {</span>
<span style="color: #00A000">+                                pq_var = switch_mprintf("null,", var);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                pq_var = switch_mprintf("'%s',", var);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        pq_var = switch_mprintf("%s,", var);</span>
<span style="color: #00A000">+                }</span>
<span style="color: #A00000">-        if (!expanded_vars) {</span>
<span style="color: #A00000">-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error expanding CDR variables.\n");</span>
<span style="color: #A00000">-                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+                /* Resize values buffer to accomodate next var */</span>
<span style="color: #00A000">+                len = strlen(pq_var);</span>
<span style="color: #00A000">+                tmp = realloc(values, offset + len);</span>
<span style="color: #00A000">+                values = tmp;</span>
<span style="color: #00A000">+                memcpy(values + offset, pq_var, len);</span>
<span style="color: #00A000">+                switch_safe_free(pq_var);</span>
<span style="color: #00A000">+                offset += len;</span>
        }
<span style="color: #00A000">+        *(values + --offset) = '\0';</span>
<span style="color: #A00000">-        insert_cdr(template_str, expanded_vars);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (expanded_vars != template_str) {</span>
<span style="color: #A00000">-                switch_safe_free(expanded_vars);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        insert_cdr(values);</span>
<span style="color: #00A000">+        switch_safe_free(values);</span>
        return status;
}
<span style="color: #800080; font-weight: bold">@@ -532,9 +433,13 @@ static switch_state_handler_table_t state_handlers = {</span>
static switch_status_t load_config(switch_memory_pool_t *pool)
{
<span style="color: #A00000">-        char *cf = "cdr_pg_csv.conf";</span>
<span style="color: #A00000">-        switch_xml_t cfg, xml, settings, param;</span>
        switch_status_t status = SWITCH_STATUS_SUCCESS;
<span style="color: #00A000">+        char *cf = "cdr_pg_csv.conf", *ptr;</span>
<span style="color: #00A000">+        switch_xml_t cfg, xml, schema, field;</span>
<span style="color: #00A000">+        const char *attr;</span>
<span style="color: #00A000">+        int num_fields = 0;</span>
<span style="color: #00A000">+        switch_size_t len = 0;</span>
<span style="color: #00A000">+        cdr_field_t *cdr_field;</span>
        if (globals.db_online) {
                PQfinish(globals.db_connection);
<span style="color: #800080; font-weight: bold">@@ -544,32 +449,69 @@ static switch_status_t load_config(switch_memory_pool_t *pool)</span>
        memset(&globals, 0, sizeof(globals));
        switch_core_hash_init(&globals.fd_hash, pool);
<span style="color: #A00000">-        switch_core_hash_init(&globals.template_hash, pool);</span>
        switch_mutex_init(&globals.db_mutex, SWITCH_MUTEX_NESTED, pool);
        globals.pool = pool;
<span style="color: #A00000">-        switch_core_hash_insert(globals.template_hash, "default", default_template);</span>
<span style="color: #A00000">-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding default template.\n");</span>
<span style="color: #A00000">-        globals.legs = CDR_LEG_A;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (switch_xml_config_parse_module_settings("cdr_pg_csv.conf", SWITCH_FALSE, config_settings) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+        if (switch_xml_config_parse_module_settings(cf, SWITCH_FALSE, config_settings) != SWITCH_STATUS_SUCCESS) {</span>
                return SWITCH_STATUS_FALSE;
        }
        if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
<span style="color: #A00000">-                if ((settings = switch_xml_child(cfg, "templates"))) {</span>
<span style="color: #A00000">-                        for (param = switch_xml_child(settings, "template"); param; param = param->next) {</span>
<span style="color: #A00000">-                                char *var = (char *) switch_xml_attr(param, "name");</span>
<span style="color: #A00000">-                                if (var) {</span>
<span style="color: #A00000">-                                        char *tpl;</span>
<span style="color: #A00000">-                                        tpl = switch_core_strdup(pool, param->txt);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                        switch_core_hash_insert(globals.template_hash, var, tpl);</span>
<span style="color: #A00000">-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding template %s.\n", var);</span>
<span style="color: #00A000">+                if ((schema = switch_xml_child(cfg, "schema"))) {</span>
<span style="color: #00A000">+                        /* Count fields in schema so we can calculate required buffer size */</span>
<span style="color: #00A000">+                        for (field = switch_xml_child(schema, "field"); field; field = field->next) {</span>
<span style="color: #00A000">+                                if (switch_xml_attr(field, "var")) {</span>
<span style="color: #00A000">+                                        num_fields++;</span>
                                }
                        }
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        globals.db_schema = switch_core_alloc(pool, (num_fields + 1) * sizeof(cdr_field_t));</span>
<span style="color: #00A000">+                        cdr_field = globals.db_schema->fields;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        for (field = switch_xml_child(schema, "field"); field; field = field->next) {</span>
<span style="color: #00A000">+                                if ((attr = switch_xml_attr(field, "var"))) {</span>
<span style="color: #00A000">+                                        cdr_field->var_name = switch_core_strdup(pool, attr);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                        /* Assume SQL column name is the same as FreeSWITCH channel var name, unless specified otherwise */</span>
<span style="color: #00A000">+                                        if ((attr = switch_xml_attr(field, "column"))) {</span>
<span style="color: #00A000">+                                                cdr_field->col_name = switch_core_strdup(pool, attr);</span>
<span style="color: #00A000">+                                        } else {</span>
<span style="color: #00A000">+                                                cdr_field->col_name = switch_core_strdup(pool, cdr_field->var_name);</span>
<span style="color: #00A000">+                                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                        /* Assume all fields should be quoted (treated as strings), unless specified otherwise */</span>
<span style="color: #00A000">+                                        if ((attr = switch_xml_attr(field, "quote")) && !strncmp(attr, "false", 5)) {</span>
<span style="color: #00A000">+                                                cdr_field->quote = SWITCH_FALSE;</span>
<span style="color: #00A000">+                                        } else {</span>
<span style="color: #00A000">+                                                cdr_field->quote = SWITCH_TRUE;</span>
<span style="color: #00A000">+                                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                        /* Assume all fields allow SQL nulls, unless specified otherwise */</span>
<span style="color: #00A000">+                                        if ((attr = switch_xml_attr(field, "not-null")) && !strncmp(attr, "true", 4)) {</span>
<span style="color: #00A000">+                                                cdr_field->not_null = SWITCH_TRUE;</span>
<span style="color: #00A000">+                                        } else {</span>
<span style="color: #00A000">+                                                cdr_field->not_null = SWITCH_FALSE;</span>
<span style="color: #00A000">+                                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                        len += strlen(cdr_field->col_name) + 1;</span>
<span style="color: #00A000">+                                        cdr_field++;</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                        cdr_field->var_name = 0;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        globals.db_schema->columns = switch_core_alloc(pool, len);</span>
<span style="color: #00A000">+                        ptr = globals.db_schema->columns;</span>
<span style="color: #00A000">+                        for (cdr_field = globals.db_schema->fields; cdr_field->col_name; cdr_field++) {</span>
<span style="color: #00A000">+                                len = strlen(cdr_field->col_name);</span>
<span style="color: #00A000">+                                memcpy(ptr, cdr_field->col_name, len);</span>
<span style="color: #00A000">+                                ptr += len;</span>
<span style="color: #00A000">+                                *ptr = ',';</span>
<span style="color: #00A000">+                                ptr++;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                        *--ptr = '\0';</span>
                }
<span style="color: #00A000">+</span>
                switch_xml_free(xml);
        }
<span style="color: #800080; font-weight: bold">@@ -596,7 +538,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_pg_csv_load)</span>
        switch_core_add_state_handler(&state_handlers);
        *module_interface = switch_loadable_module_create_module_interface(pool, modname);
<span style="color: #A00000">-</span>
        return status;
}
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments:
default to 10
<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 c78aac7..c683203 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">@@ -3708,7 +3708,7 @@ SWITCH_STANDARD_API(sofia_function)</span>
                                if (argc > 2) {
                                        if (strstr(argv[2], "presence")) {
<span style="color: #A00000">-                                                mod_sofia_globals.debug_presence = 1;</span>
<span style="color: #00A000">+                                                mod_sofia_globals.debug_presence = 10;</span>
                                                stream->write_function(stream, "+OK Debugging presence\n");
                                        }
                                        
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments:
FS-3038
<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 807770a..f34042a 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">@@ -4439,19 +4439,23 @@ SWITCH_STANDARD_API(strftime_tz_api_function)</span>
                if ((format = strchr(mycmd, ' '))) {
                        *format++ = '\0';
<span style="color: #A00000">-                }</span>
                
<span style="color: #A00000">-                if ((p = strchr(format, '|'))) {</span>
<span style="color: #A00000">-                        *p++ = '\0';</span>
<span style="color: #A00000">-                        when = atol(format);</span>
<span style="color: #A00000">-                        format = p;</span>
<span style="color: #00A000">+                        if (format && (p = strchr(format, '|'))) {</span>
<span style="color: #00A000">+                                *p++ = '\0';</span>
<span style="color: #00A000">+                                when = atol(format);</span>
<span style="color: #00A000">+                                format = p;</span>
<span style="color: #00A000">+                        }</span>
                }
        }
<span style="color: #A00000">-        if (switch_strftime_tz(tz_name, format, date, sizeof(date), when * 1000000) == SWITCH_STATUS_SUCCESS) {        /* The lookup of the zone may fail. */</span>
<span style="color: #00A000">+        if (zstr(format)) {</span>
<span style="color: #00A000">+                format = "%Y-%m-%d";</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        if (format && switch_strftime_tz(tz_name, format, date, sizeof(date), when * 1000000) == SWITCH_STATUS_SUCCESS) {        /* The lookup of the zone may fail. */</span>
                stream->write_function(stream, "%s", date);
        } else {
<span style="color: #A00000">-                stream->write_function(stream, "-ERR Invalid Timezone\n");</span>
<span style="color: #00A000">+                stream->write_function(stream, "-ERR Invalid Timezone/Format\n");</span>
        }
        switch_safe_free(mycmd);
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments:
FS-3040
<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 f829e57..bea8214 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">@@ -1277,9 +1277,14 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *</span>
        myid = resolve_id(id_in, domain_name, "message-count");
<span style="color: #A00000">-        switch_snprintf(sql, sizeof(sql), "select 1, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' "</span>
<span style="color: #A00000">-                                                                         "and read_epoch=0 group by read_flags union select 0, read_flags, count(read_epoch) from voicemail_msgs where username='%s' "</span>
<span style="color: #A00000">-                                                                         "and domain='%s' and in_folder='%s' and read_epoch<>0 group by read_flags;", myid, domain_name, myfolder);</span>
<span style="color: #00A000">+        switch_snprintf(sql, sizeof(sql), "select 1, read_flags, count(read_epoch) from voicemail_msgs where "</span>
<span style="color: #00A000">+                                        "username='%s' and domain='%s' and in_folder='%s' "</span>
<span style="color: #00A000">+                                        "and read_epoch=0 group by read_flags union select 0, read_flags, count(read_epoch) from voicemail_msgs where username='%s' "</span>
<span style="color: #00A000">+                                        "and domain='%s' and in_folder='%s' and read_epoch<>0 group by read_flags;", </span>
<span style="color: #00A000">+                                        myid, domain_name, myfolder, myid, domain_name, myfolder);</span>
<span style="color: #00A000">+                                        </span>
<span style="color: #00A000">+                                 </span>
<span style="color: #00A000">+</span>
        vm_execute_sql_callback(profile, profile->mutex, sql, message_count_callback, &cbt);
        *total_new_messages = cbt.total_new_messages + cbt.total_new_urgent_messages;
</pre></div>
<div class="highlight"><pre>committer: Daniel Swarbrick
comments:
refactor config parsing
<span style="color: #000080; font-weight: bold">diff --git a/conf/autoload_configs/cdr_pg_csv.conf.xml b/conf/autoload_configs/cdr_pg_csv.conf.xml</span>
<span style="color: #000080; font-weight: bold">index 2f2efa9..427bf2d 100644</span>
<span style="color: #A00000">--- a/conf/autoload_configs/cdr_pg_csv.conf.xml</span>
<span style="color: #00A000">+++ b/conf/autoload_configs/cdr_pg_csv.conf.xml</span>
<span style="color: #800080; font-weight: bold">@@ -1,19 +1,23 @@</span>
<configuration name="cdr_pg_csv.conf" description="CDR PG CSV Format">
<settings>
<span style="color: #A00000">- <!-- Log a-leg (a), b-leg (b) or both (ab) --></span>
<span style="color: #A00000">- <param name="legs" value="a"/></span>
<!-- See parameters for PQconnectdb() at http://www.postgresql.org/docs/8.4/static/libpq-connect.html -->
<param name="db-info" value="host=localhost dbname=cdr connect_timeout=10" />
<!-- CDR table name -->
<!--<param name="db-table" value="cdr"/>-->
<span style="color: #A00000">- <param name="default-template" value="example"/></span>
<span style="color: #A00000">- <!-- 'cdr-pg-csv' will always be appended to log-base --></span>
<span style="color: #A00000">- <!--<param name="log-base" value="/var/log"/>--></span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+ <!-- Log a-leg (a), b-leg (b) or both (ab) --></span>
<span style="color: #00A000">+ <param name="legs" value="a"/></span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+ <!-- Directory in which to spool failed SQL inserts --></span>
<span style="color: #00A000">+ <!-- <param name="spool-dir" value="$${base_dir}/log/cdr-pg-csv"/> --></span>
<!-- Disk spool format if DB connection/insert fails - csv (default) or sql -->
<param name="spool-format" value="csv"/>
<param name="rotate-on-hup" value="true"/>
<span style="color: #00A000">+</span>
<!-- This is like the info app but after the call is hung up -->
<!--<param name="debug" value="true"/>-->
<span style="color: #00A000">+</span>
<span style="color: #00A000">+ <param name="default-template" value="example"/></span>
</settings>
<templates>
<template name="example">"${local_ip_v4}","${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}","${accountcode}","${read_codec}","${write_codec}","${sip_hangup_disposition}","${ani}"</template>
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c b/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c</span>
<span style="color: #000080; font-weight: bold">index 5227161..1ec56bd 100644</span>
<span style="color: #A00000">--- a/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c</span>
<span style="color: #00A000">+++ b/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c</span>
<span style="color: #800080; font-weight: bold">@@ -37,18 +37,27 @@</span>
#include <switch.h>
#include <libpq-fe.h>
<span style="color: #00A000">+SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_pg_csv_load);</span>
<span style="color: #00A000">+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cdr_pg_csv_shutdown);</span>
<span style="color: #00A000">+SWITCH_MODULE_DEFINITION(mod_cdr_pg_csv, mod_cdr_pg_csv_load, mod_cdr_pg_csv_shutdown, NULL);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
typedef enum {
        CDR_LEG_A = (1 << 0),
        CDR_LEG_B = (1 << 1)
} cdr_leg_t;
<span style="color: #A00000">-struct cdr_fd {</span>
<span style="color: #00A000">+typedef enum {</span>
<span style="color: #00A000">+        SPOOL_FORMAT_CSV,</span>
<span style="color: #00A000">+        SPOOL_FORMAT_SQL</span>
<span style="color: #00A000">+} spool_format_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+typedef struct {</span>
        int fd;
        char *path;
        int64_t bytes;
        switch_mutex_t *mutex;
<span style="color: #A00000">-};</span>
<span style="color: #A00000">-typedef struct cdr_fd cdr_fd_t;</span>
<span style="color: #00A000">+} cdr_fd_t;</span>
const char *default_template =
        "\"${local_ip_v4}\",\"${caller_id_name}\",\"${caller_id_number}\",\"${destination_number}\",\"${context}\",\"${start_stamp}\","
<span style="color: #800080; font-weight: bold">@@ -59,23 +68,59 @@ static struct {</span>
        switch_memory_pool_t *pool;
        switch_hash_t *fd_hash;
        switch_hash_t *template_hash;
<span style="color: #A00000">-        char *log_dir;</span>
<span style="color: #A00000">-        char *default_template;</span>
        int shutdown;
<span style="color: #A00000">-        int rotate;</span>
<span style="color: #A00000">-        int debug;</span>
<span style="color: #A00000">-        cdr_leg_t legs;</span>
        char *db_info;
        char *db_table;
<span style="color: #A00000">-        char *spool_format;</span>
        PGconn *db_connection;
        int db_online;
<span style="color: #00A000">+        cdr_leg_t legs;</span>
<span style="color: #00A000">+        char *spool_dir;</span>
<span style="color: #00A000">+        spool_format_t spool_format;</span>
<span style="color: #00A000">+        int rotate;</span>
<span style="color: #00A000">+        int debug;</span>
<span style="color: #00A000">+        char *default_template;</span>
        switch_mutex_t *db_mutex;
} globals = { 0 };
<span style="color: #A00000">-SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_pg_csv_load);</span>
<span style="color: #A00000">-SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cdr_pg_csv_shutdown);</span>
<span style="color: #A00000">-SWITCH_MODULE_DEFINITION(mod_cdr_pg_csv, mod_cdr_pg_csv_load, mod_cdr_pg_csv_shutdown, NULL);</span>
<span style="color: #00A000">+static switch_xml_config_enum_item_t config_opt_cdr_leg_enum[] = {</span>
<span style="color: #00A000">+ {"a", CDR_LEG_A},</span>
<span style="color: #00A000">+ {"b", CDR_LEG_B},</span>
<span style="color: #00A000">+ {"ab", CDR_LEG_A | CDR_LEG_B},</span>
<span style="color: #00A000">+ {NULL, 0}</span>
<span style="color: #00A000">+};</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_xml_config_enum_item_t config_opt_spool_format_enum[] = {</span>
<span style="color: #00A000">+ {"csv", SPOOL_FORMAT_CSV},</span>
<span style="color: #00A000">+ {"sql", SPOOL_FORMAT_SQL},</span>
<span style="color: #00A000">+ {NULL, 0}</span>
<span style="color: #00A000">+};</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t config_validate_spool_dir(switch_xml_config_item_t *item, const char *newvalue, switch_config_callback_type_t callback_type, switch_bool_t changed)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        if ((callback_type == CONFIG_LOAD || callback_type == CONFIG_RELOAD)) {</span>
<span style="color: #00A000">+                if (zstr(newvalue)) {</span>
<span style="color: #00A000">+                        globals.spool_dir = switch_core_sprintf(globals.pool, "%s%scdr-pg-csv", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR);</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</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_xml_config_item_t config_settings[] = {</span>
<span style="color: #00A000">+        /* key, type, flags, ptr, default_value, data, syntax, helptext */</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM_STRING_STRDUP("db-info", CONFIG_RELOADABLE, &globals.db_info, "dbname=cdr", NULL, NULL),</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM_STRING_STRDUP("db-table", CONFIG_RELOADABLE, &globals.db_table, "cdr", NULL, NULL),</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM_STRING_STRDUP("default-template", CONFIG_RELOADABLE, &globals.default_template, "default", NULL, NULL),</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM("legs", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &globals.legs, (void *) CDR_LEG_A, &config_opt_cdr_leg_enum, "a|b|ab", NULL),</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM("spool-format", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &globals.spool_format, (void *) SPOOL_FORMAT_CSV, &config_opt_spool_format_enum, "csv|sql", "Disk spool format to use if SQL insert fails."),</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM("rotate-on-hup", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &globals.rotate, SWITCH_FALSE, NULL, NULL, NULL),</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM("debug", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &globals.debug, SWITCH_FALSE, NULL, NULL, NULL),</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* key, type, flags, ptr, defaultvalue, function, functiondata, syntax, helptext */</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM_CALLBACK("spool-dir", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &globals.spool_dir, NULL, config_validate_spool_dir, NULL, NULL, NULL),</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM_END()</span>
<span style="color: #00A000">+};</span>
<span style="color: #00A000">+</span>
static off_t fd_size(int fd)
{
<span style="color: #800080; font-weight: bold">@@ -363,12 +408,12 @@ static switch_status_t insert_cdr(const char * const template, const char * cons</span>
        switch_mutex_unlock(globals.db_mutex);
        /* SQL INSERT failed for whatever reason. Spool the attempted query to disk */
<span style="color: #A00000">-        if (!strcasecmp(globals.spool_format, "sql")) {</span>
<span style="color: #A00000">-                path = switch_mprintf("%s%scdr-spool.sql", globals.log_dir, SWITCH_PATH_SEPARATOR);</span>
<span style="color: #00A000">+        if (globals.spool_format == SPOOL_FORMAT_SQL) {</span>
<span style="color: #00A000">+                path = switch_mprintf("%s%scdr-spool.sql", globals.spool_dir, SWITCH_PATH_SEPARATOR);</span>
                assert(path);
                spool_cdr(path, sql);
        } else {
<span style="color: #A00000">-                path = switch_mprintf("%s%scdr-spool.csv", globals.log_dir, SWITCH_PATH_SEPARATOR);</span>
<span style="color: #00A000">+                path = switch_mprintf("%s%scdr-spool.csv", globals.spool_dir, SWITCH_PATH_SEPARATOR);</span>
                assert(path);
                spool_cdr(path, cdr);
        }
<span style="color: #800080; font-weight: bold">@@ -402,8 +447,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)</span>
                }
        }
<span style="color: #A00000">-        if (switch_dir_make_recursive(globals.log_dir, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #A00000">-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", globals.log_dir);</span>
<span style="color: #00A000">+        if (switch_dir_make_recursive(globals.spool_dir, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", globals.spool_dir);</span>
                return SWITCH_STATUS_FALSE;
        }
<span style="color: #800080; font-weight: bold">@@ -485,7 +530,6 @@ static switch_state_handler_table_t state_handlers = {</span>
};
<span style="color: #A00000">-</span>
static switch_status_t load_config(switch_memory_pool_t *pool)
{
        char *cf = "cdr_pg_csv.conf";
<span style="color: #800080; font-weight: bold">@@ -509,40 +553,11 @@ static switch_status_t load_config(switch_memory_pool_t *pool)</span>
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding default template.\n");
        globals.legs = CDR_LEG_A;
<span style="color: #A00000">-        if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) {</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                if ((settings = switch_xml_child(cfg, "settings"))) {</span>
<span style="color: #A00000">-                        for (param = switch_xml_child(settings, "param"); param; param = param->next) {</span>
<span style="color: #A00000">-                                char *var = (char *) switch_xml_attr_soft(param, "name");</span>
<span style="color: #A00000">-                                char *val = (char *) switch_xml_attr_soft(param, "value");</span>
<span style="color: #A00000">-                                if (!strcasecmp(var, "debug")) {</span>
<span style="color: #A00000">-                                        globals.debug = switch_true(val);</span>
<span style="color: #A00000">-                                } else if (!strcasecmp(var, "legs")) {</span>
<span style="color: #A00000">-                                        globals.legs = 0;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                        if (strchr(val, 'a')) {</span>
<span style="color: #A00000">-                                                globals.legs |= CDR_LEG_A;</span>
<span style="color: #A00000">-                                        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                        if (strchr(val, 'b')) {</span>
<span style="color: #A00000">-                                                globals.legs |= CDR_LEG_B;</span>
<span style="color: #A00000">-                                        }</span>
<span style="color: #A00000">-                                } else if (!strcasecmp(var, "log-base")) {</span>
<span style="color: #A00000">-                                        globals.log_dir = switch_core_sprintf(pool, "%s%scdr-pg-csv", val, SWITCH_PATH_SEPARATOR);</span>
<span style="color: #A00000">-                                } else if (!strcasecmp(var, "rotate-on-hup")) {</span>
<span style="color: #A00000">-                                        globals.rotate = switch_true(val);</span>
<span style="color: #A00000">-                                } else if (!strcasecmp(var, "db-info")) {</span>
<span style="color: #A00000">-                                        globals.db_info = switch_core_strdup(pool, val);</span>
<span style="color: #A00000">-                                } else if (!strcasecmp(var, "db-table") || !strcasecmp(var, "g-table")) {</span>
<span style="color: #A00000">-                                        globals.db_table = switch_core_strdup(pool, val);</span>
<span style="color: #A00000">-                                } else if (!strcasecmp(var, "default-template")) {</span>
<span style="color: #A00000">-                                        globals.default_template = switch_core_strdup(pool, val);</span>
<span style="color: #A00000">-                                } else if (!strcasecmp(var, "spool-format")) {</span>
<span style="color: #A00000">-                                        globals.spool_format = switch_core_strdup(pool, val);</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                }</span>
<span style="color: #00A000">+        if (switch_xml_config_parse_module_settings("cdr_pg_csv.conf", SWITCH_FALSE, config_settings) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) {</span>
                if ((settings = switch_xml_child(cfg, "templates"))) {
                        for (param = switch_xml_child(settings, "template"); param; param = param->next) {
                                char *var = (char *) switch_xml_attr(param, "name");
<span style="color: #800080; font-weight: bold">@@ -558,26 +573,6 @@ static switch_status_t load_config(switch_memory_pool_t *pool)</span>
                switch_xml_free(xml);
        }
<span style="color: #A00000">-        if (!globals.log_dir) {</span>
<span style="color: #A00000">-                globals.log_dir = switch_core_sprintf(pool, "%s%scdr-pg-csv", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (zstr(globals.db_info)) {</span>
<span style="color: #A00000">-                globals.db_info = switch_core_strdup(pool, "dbname=cdr");</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (zstr(globals.db_table)) {</span>
<span style="color: #A00000">-                globals.db_table = switch_core_strdup(pool, "cdr");</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (zstr(globals.default_template)) {</span>
<span style="color: #A00000">-                globals.default_template = switch_core_strdup(pool, "default");</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (zstr(globals.spool_format)) {</span>
<span style="color: #A00000">-                globals.spool_format = switch_core_strdup(pool, "csv");</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
        return status;
}
<span style="color: #800080; font-weight: bold">@@ -588,8 +583,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_pg_csv_load)</span>
        load_config(pool);
<span style="color: #A00000">-        if ((status = switch_dir_make_recursive(globals.log_dir, SWITCH_DEFAULT_DIR_PERMS, pool)) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #A00000">-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", globals.log_dir);</span>
<span style="color: #00A000">+        if ((status = switch_dir_make_recursive(globals.spool_dir, SWITCH_DEFAULT_DIR_PERMS, pool)) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", globals.spool_dir);</span>
                return status;
        }
</pre></div>
<div class="highlight"><pre>committer: cypromis
comments:
more formatting mistakes *sigh*
<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 1684127..f829e57 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">@@ -1277,9 +1277,9 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *</span>
        myid = resolve_id(id_in, domain_name, "message-count");
<span style="color: #A00000">-        switch_snprintf(sql, sizeof(sql), "select 1, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch=0 group by read_flags union </span>
<span style="color: #A00000">-        select 0, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch<>0 group by read_flags;",        myid, domain_name, myfolder);</span>
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        switch_snprintf(sql, sizeof(sql), "select 1, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' "</span>
<span style="color: #00A000">+                                                                         "and read_epoch=0 group by read_flags union select 0, read_flags, count(read_epoch) from voicemail_msgs where username='%s' "</span>
<span style="color: #00A000">+                                                                         "and domain='%s' and in_folder='%s' and read_epoch<>0 group by read_flags;", myid, domain_name, myfolder);</span>
        vm_execute_sql_callback(profile, profile->mutex, sql, message_count_callback, &cbt);
        *total_new_messages = cbt.total_new_messages + cbt.total_new_urgent_messages;
</pre></div>
<div class="highlight"><pre>committer: cypromis
comments:
seems whitespaces are unpopular on some linux/gcc combinations
<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 f868c3a..1684127 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">@@ -1277,11 +1277,8 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *</span>
        myid = resolve_id(id_in, domain_name, "message-count");
<span style="color: #A00000">-        switch_snprintf(sql, sizeof(sql),</span>
<span style="color: #A00000">-                                        "select 1, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch=0 group by read_flags </span>
<span style="color: #A00000">-                                        union </span>
<span style="color: #A00000">-                                        select 0, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch<>0 group by read_flags;",        </span>
<span style="color: #A00000">-                                        myid, domain_name, myfolder);</span>
<span style="color: #00A000">+        switch_snprintf(sql, sizeof(sql), "select 1, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch=0 group by read_flags union </span>
<span style="color: #00A000">+        select 0, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch<>0 group by read_flags;",        myid, domain_name, myfolder);</span>
        vm_execute_sql_callback(profile, profile->mutex, sql, message_count_callback, &cbt);
</pre></div>
<div class="highlight"><pre>committer: cypromis
comments:
FS-1742 - Make Voicemail use 1 SQL query instead of 4 to get the message count use in MWI - Now also working on your more favourite and less favourite databases
<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 80b011e..f868c3a 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">@@ -1278,7 +1278,9 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *</span>
        myid = resolve_id(id_in, domain_name, "message-count");
        switch_snprintf(sql, sizeof(sql),
<span style="color: #A00000">-                                        "select read_epoch=0, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' group by read_epoch=0,read_flags;",</span>
<span style="color: #00A000">+                                        "select 1, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch=0 group by read_flags </span>
<span style="color: #00A000">+                                        union </span>
<span style="color: #00A000">+                                        select 0, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch<>0 group by read_flags;",        </span>
                                        myid, domain_name, myfolder);
        vm_execute_sql_callback(profile, profile->mutex, sql, message_count_callback, &cbt);
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments:
Merge branch 'master' of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments:
reswig mod_lua for freeswitch.email
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/languages/mod_lua/mod_lua_wrap.cpp b/src/mod/languages/mod_lua/mod_lua_wrap.cpp</span>
<span style="color: #000080; font-weight: bold">index 1d84a39..559d403 100644</span>
<span style="color: #A00000">--- a/src/mod/languages/mod_lua/mod_lua_wrap.cpp</span>
<span style="color: #00A000">+++ b/src/mod/languages/mod_lua/mod_lua_wrap.cpp</span>
<span style="color: #800080; font-weight: bold">@@ -1582,6 +1582,55 @@ fail:</span>
}
<span style="color: #00A000">+static int _wrap_email(lua_State* L) {</span>
<span style="color: #00A000">+ int SWIG_arg = -1;</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">+ SWIG_check_num_args("email",2,7)</span>
<span style="color: #00A000">+ if(!lua_isstring(L,1)) SWIG_fail_arg("email",1,"char *");</span>
<span style="color: #00A000">+ if(!lua_isstring(L,2)) SWIG_fail_arg("email",2,"char *");</span>
<span style="color: #00A000">+ if(lua_gettop(L)>=3 && !lua_isstring(L,3)) SWIG_fail_arg("email",3,"char *");</span>
<span style="color: #00A000">+ if(lua_gettop(L)>=4 && !lua_isstring(L,4)) SWIG_fail_arg("email",4,"char *");</span>
<span style="color: #00A000">+ if(lua_gettop(L)>=5 && !lua_isstring(L,5)) SWIG_fail_arg("email",5,"char *");</span>
<span style="color: #00A000">+ if(lua_gettop(L)>=6 && !lua_isstring(L,6)) SWIG_fail_arg("email",6,"char *");</span>
<span style="color: #00A000">+ if(lua_gettop(L)>=7 && !lua_isstring(L,7)) SWIG_fail_arg("email",7,"char *");</span>
<span style="color: #00A000">+ arg1 = (char *)lua_tostring(L, 1);</span>
<span style="color: #00A000">+ arg2 = (char *)lua_tostring(L, 2);</span>
<span style="color: #00A000">+ if(lua_gettop(L)>=3){</span>
<span style="color: #00A000">+ arg3 = (char *)lua_tostring(L, 3);</span>
<span style="color: #00A000">+ }</span>
<span style="color: #00A000">+ if(lua_gettop(L)>=4){</span>
<span style="color: #00A000">+ arg4 = (char *)lua_tostring(L, 4);</span>
<span style="color: #00A000">+ }</span>
<span style="color: #00A000">+ if(lua_gettop(L)>=5){</span>
<span style="color: #00A000">+ arg5 = (char *)lua_tostring(L, 5);</span>
<span style="color: #00A000">+ }</span>
<span style="color: #00A000">+ if(lua_gettop(L)>=6){</span>
<span style="color: #00A000">+ arg6 = (char *)lua_tostring(L, 6);</span>
<span style="color: #00A000">+ }</span>
<span style="color: #00A000">+ if(lua_gettop(L)>=7){</span>
<span style="color: #00A000">+ arg7 = (char *)lua_tostring(L, 7);</span>
<span style="color: #00A000">+ }</span>
<span style="color: #00A000">+ result = (bool)email(arg1,arg2,arg3,arg4,arg5,arg6,arg7);</span>
<span style="color: #00A000">+ SWIG_arg=0;</span>
<span style="color: #00A000">+ lua_pushboolean(L,(int)(result==true)); SWIG_arg++;</span>
<span style="color: #00A000">+ return SWIG_arg;</span>
<span style="color: #00A000">+ </span>
<span style="color: #00A000">+ if(0) SWIG_fail;</span>
<span style="color: #00A000">+ </span>
<span style="color: #00A000">+fail:</span>
<span style="color: #00A000">+ lua_error(L);</span>
<span style="color: #00A000">+ return SWIG_arg;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
static int _wrap_new_IVRMenu(lua_State* L) {
int SWIG_arg = -1;
IVRMenu *arg1 = (IVRMenu *) 0 ;
<span style="color: #800080; font-weight: bold">@@ -7525,6 +7574,7 @@ static swig_lua_class _wrap_class_LUA_Dbh = { "Dbh", &SWIGTYPE_p_LUA__Dbh,_wrap_</span>
static const struct luaL_reg swig_commands[] = {
{ "consoleLog", _wrap_consoleLog},
{ "consoleCleanLog", _wrap_consoleCleanLog},
<span style="color: #00A000">+ { "email", _wrap_email},</span>
{ "console_log", _wrap_console_log},
{ "console_clean_log", _wrap_console_clean_log},
{ "msleep", _wrap_msleep},
</pre></div>
<div class="highlight"><pre>committer: Mathieu Rene
comments:
Add libjpeg-dev to apt prereqs
<span style="color: #000080; font-weight: bold">diff --git a/support-d/prereq.sh b/support-d/prereq.sh</span>
<span style="color: #000080; font-weight: bold">index 4e214cf..8bc454d 100755</span>
<span style="color: #A00000">--- a/support-d/prereq.sh</span>
<span style="color: #00A000">+++ b/support-d/prereq.sh</span>
<span style="color: #800080; font-weight: bold">@@ -2,7 +2,7 @@ UNAME=`uname`</span>
NEEDED_PACKAGES_YUM='automake autoconf libtool screen gdb gcc-c++ compat-gcc-32 compat-gcc-32-c++ subversion ncurses-devel unixODBC-devel make wget'
<span style="color: #A00000">-NEEDED_PACAKGES_APT='automake autoconf libtool screen gdb libncurses5-dev unixodbc-dev subversion emacs22-nox gcc g++ make'</span>
<span style="color: #00A000">+NEEDED_PACAKGES_APT='automake autoconf libtool screen gdb libncurses5-dev unixodbc-dev subversion emacs22-nox gcc g++ make libjpeg-dev'</span>
NEEDED_PACKAGES_PKG_ADD=''
</pre></div>
<div class="highlight"><pre>committer: Mathieu Rene
comments:
Add session.ringReady() to check for CF_RING_READY
<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 1d6ee8d..a818c1d 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">@@ -2126,6 +2126,15 @@ static JSBool session_media_ready(JSContext * cx, JSObject * obj, uintN argc, js</span>
}
<span style="color: #00A000">+static JSBool session_ring_ready(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        struct js_session *jss = JS_GetPrivate(cx, obj);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        *rval = BOOLEAN_TO_JSVAL((jss && jss->session && switch_channel_test_flag(switch_core_session_get_channel(jss->session), CF_RING_READY)) ? JS_TRUE : JS_FALSE);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return JS_TRUE;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
static JSBool session_answered(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
        struct js_session *jss = JS_GetPrivate(cx, obj);
<span style="color: #800080; font-weight: bold">@@ -2673,6 +2682,7 @@ static JSFunctionSpec session_methods[] = {</span>
        {"ready", session_ready, 0},
        {"answered", session_answered, 0},
        {"mediaReady", session_media_ready, 0},
<span style="color: #00A000">+        {"ringReady", session_ring_ready, 0},</span>
        {"waitForAnswer", session_wait_for_answer, 0},
        {"waitForMedia", session_wait_for_media, 0},
        {"getEvent", session_get_event, 0},
</pre></div>
<div class="highlight"><pre>committer: Mathieu Rene
comments:
xml_config: change min/max enforcements to >= instead of >
<span style="color: #000080; font-weight: bold">diff --git a/src/switch_xml_config.c b/src/switch_xml_config.c</span>
<span style="color: #000080; font-weight: bold">index b6b37bd..5ade057 100644</span>
<span style="color: #A00000">--- a/src/switch_xml_config.c</span>
<span style="color: #00A000">+++ b/src/switch_xml_config.c</span>
<span style="color: #800080; font-weight: bold">@@ -177,7 +177,7 @@ SWITCH_DECLARE(switch_status_t) switch_xml_config_parse_event(switch_event_t *ev</span>
                                        if (int_options) {
                                                /* Enforce validation options */
<span style="color: #A00000">-                                                if ((int_options->enforce_min && !(intval > int_options->min)) || (int_options->enforce_max && !(intval < int_options->max))) {</span>
<span style="color: #00A000">+                                                if ((int_options->enforce_min && !(intval >= int_options->min)) || (int_options->enforce_max && !(intval <= int_options->max))) {</span>
                                                        /* Validation failed, set default */
                                                        intval = (int) (intptr_t) item->defaultvalue;
                                                        /* Then complain */
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments:
Merge branch 'master' of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments:
nm 40 doesn'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, "OPUS (BETA 0.9.0)");
<span style="color: #A00000">-        for (x = 0; x < 3; x++) {</span>
<span style="color: #00A000">+        for (x = 0; x < 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 */
                                                                                         "Opus-0.9.0",/* 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, "OPUS (BETA 0.9.0)");
<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">-                                                                                 "Opus-0.9.0",/* 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">-                                                                                 "Opus-0.9.0",        /* 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 < 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">+                                                                                         "Opus-0.9.0",/* 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, "OPUS (BETA)");</span>
<span style="color: #00A000">+        SWITCH_ADD_CODEC(codec_interface, "OPUS (BETA 0.9.0)");</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">-                                                                                 "OPUS",        /* the IANA code name */</span>
<span style="color: #00A000">+                                                                                 "Opus-0.9.0",/* 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">-                                                                                 "OPUS",        /* the IANA code name */</span>
<span style="color: #00A000">+                                                                                 "Opus-0.9.0",        /* 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>
<load module="mod_h26x"/>
<load module="mod_siren"/>
<!--<load module="mod_celt"/>-->
<span style="color: #00A000">+ <!--<load module="mod_opus"/>--></span>
<!-- File Format Interfaces -->
<load module="mod_sndfile"/>
<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) && $(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) && $(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 <anthm@freeswitch.org></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 "License"); 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 "AS IS" 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 <anthm@freeswitch.org></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 <brian@freeswitch.org></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 "switch.h"</span>
<span style="color: #00A000">+#include "opus.h"</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 & SWITCH_CODEC_FLAG_ENCODE);</span>
<span style="color: #00A000">+        int decoding = (flags & SWITCH_CODEC_FLAG_DECODE);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->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->frame_size = codec->implementation->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->implementation->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->encoder_object = opus_encoder_create(codec->implementation->actual_samples_per_second, codec->implementation->number_of_channels);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                opus_encoder_ctl(context->encoder_object, OPUS_SET_MODE(mode));</span>
<span style="color: #00A000">+                opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(bitrate_bps));</span>
<span style="color: #00A000">+                opus_encoder_ctl(context->encoder_object, OPUS_SET_BANDWIDTH(bandwidth));</span>
<span style="color: #00A000">+                opus_encoder_ctl(context->encoder_object, OPUS_SET_VBR_FLAG(use_vbr));</span>
<span style="color: #00A000">+                opus_encoder_ctl(context->encoder_object, OPUS_SET_COMPLEXITY(complexity));</span>
<span style="color: #00A000">+                opus_encoder_ctl(context->encoder_object, OPUS_SET_INBAND_FEC_FLAG(use_inbandfec));</span>
<span style="color: #00A000">+                opus_encoder_ctl(context->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->decoder_object = opus_decoder_create(codec->implementation->actual_samples_per_second, codec->implementation->number_of_channels);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        codec->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->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->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 > 1275) len = 1275;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        bytes = opus_encode(context->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 > 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, "Encoder Error!\n");</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->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->decoder_object, encoded_data, encoded_data_len, decoded_data, *decoded_data_len);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (samples < 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, "OPUS (BETA)");</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">+                                                                                 "OPUS",        /* 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">+                                                                                 "OPUS",        /* 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, "(%s) %s stopped\n", schannel->name, speech_channel_type_to_string(schannel->type));
<span style="color: #00A000">+        } else if (schannel->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->mutex);
#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
<span style="color: #A00000">-        switch_size_t len = *data_len;</span>
        if (queue->file_write) {
                switch_file_write(queue->file_write, data, &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->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, "(%s) audio queue read total = %ld\tread = %ld\trequested = %ld\n", queue->name,
                                         queue->read_bytes, *data_len, requested);
<span style="color: #A00000">-        switch_size_t len = *data_len;</span>
        if (queue->file_read) {
                switch_file_write(queue->file_read, data, &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->mutex);</span>
<span style="color: #00A000">+        switch_thread_cond_signal(queue->cond);</span>
<span style="color: #00A000">+        switch_mutex_unlock(queue->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->mutex);
<span style="color: #A00000">-        if (schannel->state == SPEECH_CHANNEL_PROCESSING) {</span>
<span style="color: #00A000">+        switch (schannel->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->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->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->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 "READY";
        case SPEECH_CHANNEL_PROCESSING:
                return "PROCESSING";
<span style="color: #00A000">+        case SPEECH_CHANNEL_DONE:</span>
<span style="color: #00A000">+                return "DONE";</span>
        case SPEECH_CHANNEL_ERROR:
                return "ERROR";
        }
<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->state == SPEECH_CHANNEL_PROCESSING && state != SPEECH_CHANNEL_PROCESSING) {
                /* wake anyone waiting for audio data */
<span style="color: #A00000">-                audio_queue_clear(schannel->audio_queue);</span>
<span style="color: #00A000">+                audio_queue_signal(schannel->audio_queue);</span>
        }
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s ==> %s\n", schannel->name, speech_channel_state_to_string(schannel->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->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->start_line.request_state == MRCP_REQUEST_STATE_COMPLETE) {
                                /* got COMPLETE */
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) COMPLETE\n", schannel->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, "(%s) unexpected STOP response, request_state = %d\n", schannel->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->start_line.method_id == SYNTHESIZER_SPEAK_COMPLETE) {
                        /* got SPEAK-COMPLETE */
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) SPEAK-COMPLETE\n", schannel->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, "(%s) unexpected event, method_id = %d\n", schannel->name,
                                                         (int) message->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>
<settings>
<!--Colorize the Console -->
<param name="colorize-console" value="true"/>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+ <!-- minimum idle CPU before refusing calls --></span>
<span style="color: #00A000">+ <param name="min-idle-cpu" value="25"/></span>
<span style="color: #00A000">+</span>
<!--
        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] = "";
        char *sql;
        
<span style="color: #A00000">-        sql = switch_mprintf("select count(*) from sip_subscriptions where profile_name='%q' and contact_str='%q'", profile->name, contact_str);</span>
<span style="color: #00A000">+        sql = switch_mprintf("select count(*) from sip_subscriptions where profile_name='%q' and contact='%q'", profile->name, contact_str);</span>
        
        sofia_glue_execute_sql2str(profile, profile->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>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'" Label="Configuration">
<span style="color: #A00000">- <ConfigurationType>DynamicLibrary</ConfigurationType></span>
<span style="color: #00A000">+ <ConfigurationType>StaticLibrary</ConfigurationType></span>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'" Label="Configuration">
<span style="color: #A00000">- <ConfigurationType>DynamicLibrary</ConfigurationType></span>
<span style="color: #00A000">+ <ConfigurationType>StaticLibrary</ConfigurationType></span>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<span style="color: #800080; font-weight: bold">@@ -57,11 +57,11 @@</span>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'" Label="Configuration">
<span style="color: #A00000">- <ConfigurationType>DynamicLibrary</ConfigurationType></span>
<span style="color: #00A000">+ <ConfigurationType>StaticLibrary</ConfigurationType></span>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'" Label="Configuration">
<span style="color: #A00000">- <ConfigurationType>DynamicLibrary</ConfigurationType></span>
<span style="color: #00A000">+ <ConfigurationType>StaticLibrary</ConfigurationType></span>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<span style="color: #800080; font-weight: bold">@@ -77,9 +77,11 @@</span>
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<span style="color: #00A000">+ <Import Project="..\..\..\..\w32\extlib.props" /></span>
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<span style="color: #00A000">+ <Import Project="..\..\..\..\w32\extlib.props" /></span>
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<span style="color: #800080; font-weight: bold">@@ -92,10 +94,12 @@</span>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
<span style="color: #00A000">+ <Import Project="..\..\..\..\w32\extlib.props" /></span>
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
<span style="color: #00A000">+ <Import Project="..\..\..\..\w32\extlib.props" /></span>
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<span style="color: #800080; font-weight: bold">@@ -110,18 +114,6 @@</span>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<span style="color: #A00000">- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">$(Configuration)\</OutDir></span>
<span style="color: #A00000">- <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">$(Configuration)\</IntDir></span>
<span style="color: #A00000">- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">true</LinkIncremental></span>
<span style="color: #A00000">- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">$(Platform)\$(Configuration)\</OutDir></span>
<span style="color: #A00000">- <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">$(Platform)\$(Configuration)\</IntDir></span>
<span style="color: #A00000">- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">true</LinkIncremental></span>
<span style="color: #A00000">- <OutDir Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">$(Configuration)\</OutDir></span>
<span style="color: #A00000">- <IntDir Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">$(Configuration)\</IntDir></span>
<span style="color: #A00000">- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">false</LinkIncremental></span>
<span style="color: #A00000">- <OutDir Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">$(Platform)\$(Configuration)\</OutDir></span>
<span style="color: #A00000">- <IntDir Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">$(Platform)\$(Configuration)\</IntDir></span>
<span style="color: #A00000">- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">false</LinkIncremental></span>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Midl>
<span style="color: #800080; font-weight: bold">@@ -231,45 +223,23 @@</span>
<MkTypLibCompatible>true</MkTypLibCompatible>
<SuppressStartupBanner>true</SuppressStartupBanner>
<TargetEnvironment>Win32</TargetEnvironment>
<span style="color: #A00000">- <TypeLibraryName>.\Debug_x86/portaudio.tlb</TypeLibraryName></span>
<span style="color: #A00000">- <HeaderFileName></span>
<span style="color: #A00000">- </HeaderFileName></span>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\src\common;..\..\include;.\;..\..\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<span style="color: #A00000">- <PreprocessorDefinitions>WIN32;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PAWIN_USE_WDMKS_DEVICE_INFO;%(PreprocessorDefinitions)</PreprocessorDefinitions></span>
<span style="color: #00A000">+ <PreprocessorDefinitions>WIN32;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PA_NO_WMME;PAWIN_USE_WDMKS_DEVICE_INFO;%(PreprocessorDefinitions)</PreprocessorDefinitions></span>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<span style="color: #A00000">- <PrecompiledHeaderOutputFile>$(Platform)\$(Configuration)/portaudio.pch</PrecompiledHeaderOutputFile></span>
<span style="color: #A00000">- <AssemblerListingLocation>$(Platform)\$(Configuration)\</AssemblerListingLocation></span>
<span style="color: #A00000">- <ObjectFileName>$(Platform)\$(Configuration)\</ObjectFileName></span>
<span style="color: #A00000">- <ProgramDataBaseFileName>$(Platform)\$(Configuration)\</ProgramDataBaseFileName></span>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<span style="color: #A00000">- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat></span>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<span style="color: #A00000">- <Link></span>
<span style="color: #A00000">- <AdditionalDependencies>ksuser.lib;%(AdditionalDependencies)</AdditionalDependencies></span>
<span style="color: #A00000">- <OutputFile>$(Platform)\$(Configuration)\portaudio_x86.dll</OutputFile></span>
<span style="color: #A00000">- <SuppressStartupBanner>true</SuppressStartupBanner></span>
<span style="color: #A00000">- <ModuleDefinitionFile>.\portaudio.def</ModuleDefinitionFile></span>
<span style="color: #A00000">- <GenerateDebugInformation>true</GenerateDebugInformation></span>
<span style="color: #A00000">- <ProgramDatabaseFile>$(Platform)\$(Configuration)\portaudio_x86.pdb</ProgramDatabaseFile></span>
<span style="color: #A00000">- <RandomizedBaseAddress>false</RandomizedBaseAddress></span>
<span style="color: #A00000">- <DataExecutionPrevention></span>
<span style="color: #A00000">- </DataExecutionPrevention></span>
<span style="color: #A00000">- <ImportLibrary>$(Platform)\$(Configuration)\portaudio_x86.lib</ImportLibrary></span>
<span style="color: #A00000">- <TargetMachine>MachineX86</TargetMachine></span>
<span style="color: #A00000">- </Link></span>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<span style="color: #A00000">- <OutputFile>$(Platform)\$(Configuration)\portaudio.bsc</OutputFile></span>
</Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">
<span style="color: #800080; font-weight: bold">@@ -278,45 +248,23 @@</span>
<MkTypLibCompatible>true</MkTypLibCompatible>
<SuppressStartupBanner>true</SuppressStartupBanner>
<TargetEnvironment>X64</TargetEnvironment>
<span style="color: #A00000">- <TypeLibraryName>.\Debug_x86/portaudio.tlb</TypeLibraryName></span>
<span style="color: #A00000">- <HeaderFileName></span>
<span style="color: #A00000">- </HeaderFileName></span>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\src\common;..\..\include;.\;..\..\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<span style="color: #A00000">- <PreprocessorDefinitions>WIN32;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PAWIN_USE_WDMKS_DEVICE_INFO;%(PreprocessorDefinitions)</PreprocessorDefinitions></span>
<span style="color: #00A000">+ <PreprocessorDefinitions>WIN32;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PA_NO_WMME;PAWIN_USE_WDMKS_DEVICE_INFO;%(PreprocessorDefinitions)</PreprocessorDefinitions></span>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<span style="color: #A00000">- <PrecompiledHeaderOutputFile>$(Platform)\$(Configuration)\portaudio.pch</PrecompiledHeaderOutputFile></span>
<span style="color: #A00000">- <AssemblerListingLocation>$(Platform)\$(Configuration)\</AssemblerListingLocation></span>
<span style="color: #A00000">- <ObjectFileName>$(Platform)\$(Configuration)\</ObjectFileName></span>
<span style="color: #A00000">- <ProgramDataBaseFileName>$(Platform)\$(Configuration)\</ProgramDataBaseFileName></span>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<span style="color: #A00000">- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat></span>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<span style="color: #A00000">- <Link></span>
<span style="color: #A00000">- <AdditionalDependencies>ksuser.lib;%(AdditionalDependencies)</AdditionalDependencies></span>
<span style="color: #A00000">- <OutputFile>$(Platform)\$(Configuration)\portaudio_x64.dll</OutputFile></span>
<span style="color: #A00000">- <SuppressStartupBanner>true</SuppressStartupBanner></span>
<span style="color: #A00000">- <ModuleDefinitionFile>.\portaudio.def</ModuleDefinitionFile></span>
<span style="color: #A00000">- <GenerateDebugInformation>true</GenerateDebugInformation></span>
<span style="color: #A00000">- <ProgramDatabaseFile>$(Platform)\$(Configuration)/portaudio_x64.pdb</ProgramDatabaseFile></span>
<span style="color: #A00000">- <RandomizedBaseAddress>false</RandomizedBaseAddress></span>
<span style="color: #A00000">- <DataExecutionPrevention></span>
<span style="color: #A00000">- </DataExecutionPrevention></span>
<span style="color: #A00000">- <ImportLibrary>$(Platform)\$(Configuration)\portaudio_x64.lib</ImportLibrary></span>
<span style="color: #A00000">- <TargetMachine>MachineX64</TargetMachine></span>
<span style="color: #A00000">- </Link></span>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<span style="color: #A00000">- <OutputFile>$(Platform)\$(Configuration)/portaudio_x64.bsc</OutputFile></span>
</Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">
<span style="color: #800080; font-weight: bold">@@ -325,22 +273,15 @@</span>
<MkTypLibCompatible>true</MkTypLibCompatible>
<SuppressStartupBanner>true</SuppressStartupBanner>
<TargetEnvironment>Win32</TargetEnvironment>
<span style="color: #A00000">- <TypeLibraryName>.\Release_x86/portaudio.tlb</TypeLibraryName></span>
<span style="color: #A00000">- <HeaderFileName></span>
<span style="color: #A00000">- </HeaderFileName></span>
</Midl>
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<span style="color: #A00000">- <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion></span>
<span style="color: #00A000">+ <InlineFunctionExpansion>Default</InlineFunctionExpansion></span>
<AdditionalIncludeDirectories>..\..\src\common;..\..\include;.\;..\..\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<span style="color: #A00000">- <PreprocessorDefinitions>WIN32;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;%(PreprocessorDefinitions)</PreprocessorDefinitions></span>
<span style="color: #00A000">+ <PreprocessorDefinitions>WIN32;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PA_NO_WMME;%(PreprocessorDefinitions)</PreprocessorDefinitions></span>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<span style="color: #A00000">- <PrecompiledHeaderOutputFile>$(Platform)\$(Configuration)/portaudio.pch</PrecompiledHeaderOutputFile></span>
<span style="color: #A00000">- <AssemblerListingLocation>$(Platform)\$(Configuration)\</AssemblerListingLocation></span>
<span style="color: #A00000">- <ObjectFileName>$(Platform)\$(Configuration)\</ObjectFileName></span>
<span style="color: #A00000">- <ProgramDataBaseFileName>$(Platform)\$(Configuration)\</ProgramDataBaseFileName></span>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
</ClCompile>
<span style="color: #800080; font-weight: bold">@@ -348,20 +289,8 @@</span>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<span style="color: #A00000">- <Link></span>
<span style="color: #A00000">- <OutputFile>$(Platform)\$(Configuration)\portaudio_x86.dll</OutputFile></span>
<span style="color: #A00000">- <SuppressStartupBanner>true</SuppressStartupBanner></span>
<span style="color: #A00000">- <ModuleDefinitionFile>.\portaudio.def</ModuleDefinitionFile></span>
<span style="color: #A00000">- <ProgramDatabaseFile>$(Platform)\$(Configuration)\portaudio_x86.pdb</ProgramDatabaseFile></span>
<span style="color: #A00000">- <RandomizedBaseAddress>false</RandomizedBaseAddress></span>
<span style="color: #A00000">- <DataExecutionPrevention></span>
<span style="color: #A00000">- </DataExecutionPrevention></span>
<span style="color: #A00000">- <ImportLibrary>$(Platform)\$(Configuration)\portaudio_x86.lib</ImportLibrary></span>
<span style="color: #A00000">- <TargetMachine>MachineX86</TargetMachine></span>
<span style="color: #A00000">- </Link></span>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<span style="color: #A00000">- <OutputFile>$(Platform)\$(Configuration)\portaudio.bsc</OutputFile></span>
</Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">
<span style="color: #800080; font-weight: bold">@@ -370,22 +299,15 @@</span>
<MkTypLibCompatible>true</MkTypLibCompatible>
<SuppressStartupBanner>true</SuppressStartupBanner>
<TargetEnvironment>X64</TargetEnvironment>
<span style="color: #A00000">- <TypeLibraryName>.\Release_x86/portaudio.tlb</TypeLibraryName></span>
<span style="color: #A00000">- <HeaderFileName></span>
<span style="color: #A00000">- </HeaderFileName></span>
</Midl>
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<span style="color: #A00000">- <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion></span>
<span style="color: #A00000">- <AdditionalIncludeDirectories>..\..\src\common;..\..\include;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories></span>
<span style="color: #A00000">- <PreprocessorDefinitions>WIN32;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions></span>
<span style="color: #00A000">+ <InlineFunctionExpansion>Default</InlineFunctionExpansion></span>
<span style="color: #00A000">+ <AdditionalIncludeDirectories>..\..\src\common;..\..\include;.\;..\..\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories></span>
<span style="color: #00A000">+ <PreprocessorDefinitions>WIN32;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PA_NO_WMME;%(PreprocessorDefinitions)</PreprocessorDefinitions></span>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<span style="color: #A00000">- <PrecompiledHeaderOutputFile>$(Platform)\$(Configuration)\portaudio.pch</PrecompiledHeaderOutputFile></span>
<span style="color: #A00000">- <AssemblerListingLocation>$(Platform)\$(Configuration)\</AssemblerListingLocation></span>
<span style="color: #A00000">- <ObjectFileName>$(Platform)\$(Configuration)\</ObjectFileName></span>
<span style="color: #A00000">- <ProgramDataBaseFileName>$(Platform)\$(Configuration)\</ProgramDataBaseFileName></span>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
</ClCompile>
<span style="color: #800080; font-weight: bold">@@ -393,20 +315,8 @@</span>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<span style="color: #A00000">- <Link></span>
<span style="color: #A00000">- <OutputFile>$(Platform)\$(Configuration)\portaudio_x64.dll</OutputFile></span>
<span style="color: #A00000">- <SuppressStartupBanner>true</SuppressStartupBanner></span>
<span style="color: #A00000">- <ModuleDefinitionFile>.\portaudio.def</ModuleDefinitionFile></span>
<span style="color: #A00000">- <ProgramDatabaseFile>$(Platform)\$(Configuration)/portaudio_x64.pdb</ProgramDatabaseFile></span>
<span style="color: #A00000">- <RandomizedBaseAddress>false</RandomizedBaseAddress></span>
<span style="color: #A00000">- <DataExecutionPrevention></span>
<span style="color: #A00000">- </DataExecutionPrevention></span>
<span style="color: #A00000">- <ImportLibrary>$(Platform)\$(Configuration)/portaudio_x64.lib</ImportLibrary></span>
<span style="color: #A00000">- <TargetMachine>MachineX64</TargetMachine></span>
<span style="color: #A00000">- </Link></span>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<span style="color: #A00000">- <OutputFile>$(Platform)\$(Configuration)\portaudio_x64.bsc</OutputFile></span>
</Bscmake>
</ItemDefinitionGroup>
<ItemGroup>
<span style="color: #800080; font-weight: bold">@@ -594,6 +504,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -605,6 +516,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -618,6 +530,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -629,6 +542,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -642,6 +556,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -653,6 +568,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -666,6 +582,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -677,6 +594,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -690,6 +608,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -701,6 +620,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -714,6 +634,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -725,6 +646,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -738,6 +660,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -749,6 +672,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -762,6 +686,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<span style="color: #800080; font-weight: bold">@@ -773,6 +698,7 @@</span>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">true</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<span style="color: #00A000">+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">true</ExcludedFromBuild></span>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release DirectSound|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</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->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 && handle->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("Type control-D or /exit or /quit or /bye to exit.\n\n");</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, "Disconnected.\n");</span>
<span style="color: #00A000">+                        if (aok) esl_log(ESL_LOG_WARNING, "Disconnected.\n");</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(&to, 0, sizeof(to));</span>
<span style="color: #00A000">+                        FD_ZERO(&can_write);</span>
<span style="color: #00A000">+                        FD_SET(fd, &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, &can_write, NULL, &to) > 0) {</span>
<span style="color: #00A000">+                                aok = FD_ISSET(fd, &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->last_event) {
                                const char *type = esl_event_get_header(handle->last_event, "content-type");
                                int known = 0;
                                if (!esl_strlen_zero(type)) {
<span style="color: #A00000">-                                        if (!strcasecmp(type, "log/data")) {</span>
<span style="color: #00A000">+                                        if (aok && !strcasecmp(type, "log/data")) {</span>
                                                const char *userdata = esl_event_get_header(handle->last_event, "user-data");
                                                
                                                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, "text/disconnect-notice")) {
                                                running = -1; thread_running = 0;
                                                known++;
<span style="color: #A00000">-                                        } else if (!strcasecmp(type, "text/event-plain")) {</span>
<span style="color: #00A000">+                                        } else if (aok && !strcasecmp(type, "text/event-plain")) {</span>
                                                char *foo;
                                                esl_event_serialize(handle->last_ievent, &foo, ESL_FALSE);
                                                printf("RECV EVENT\n%s\n", 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 && !known) {</span>
                                        char *foo;
                                        printf("INCOMING DATA [%s]\n%s\n", type, handle->last_event->body ? handle->last_event->body : "");
                                        esl_event_serialize(handle->last_event, &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("Type control-D or /exit or /quit or /bye to exit.\n\n");</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++ = '\0';
        } else {
                domain = switch_core_get_variable_pdup("domain", 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), "sip_profile");
        } else {
<span style="color: #A00000">-                profile = switch_core_get_variable_pdup("sip_profile", switch_core_session_get_pool(session));</span>
<span style="color: #00A000">+                dup_profile = switch_core_get_variable_dup("sip_profile");</span>
<span style="color: #00A000">+                profile = dup_profile;</span>
        }
        if (zstr(profile)) {
                profile = "default";
<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, "sofia", 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, '@'))) {
                *domain++ = '\0';
        } else {
<span style="color: #A00000">-                domain = switch_core_get_variable_pdup("domain", switch_core_session_get_pool(session));</span>
<span style="color: #00A000">+                domain = switch_core_get_variable_dup("domain");</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 <intrin.h>
</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 <signal.h>
#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 && handle->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("Type control-D or /exit or /quit or /bye to exit.\n\n");</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, "Disconnected.\n");
                        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(&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 && val) {
<span style="color: #00A000">+                                                total++;</span>
                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s setting FSK var [%s][%s]\n",
                                                                                 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, "execute_on_fsk"))) {</span>
<span style="color: #00A000">+                                if (total && (app_var = switch_channel_get_variable(channel, "execute_on_fsk"))) {</span>
                                        char *app_arg;
                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s processing execute_on_fsk [%s]\n",
</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 && strstr(app, "::")) {</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, "::"))) {</span>
<span style="color: #00A000">+                        *arp = '\0';</span>
<span style="color: #00A000">+                        arg = arp + 2;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
        
        if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
                switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute");
<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 && strstr(app, "::")) {</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->channel)) {
                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel is hungup, aborting execution of application: %s\n", 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 "portaudio::ringing"
#define MY_EVENT_MAKE_CALL "portaudio::makecall"
<span style="color: #00A000">+#define MY_EVENT_CALL_HELD "portaudio::callheld"</span>
<span style="color: #00A000">+#define MY_EVENT_CALL_RESUMED "portaudio::callresumed"</span>
#define MY_EVENT_ERROR_AUDIO_DEV "portaudio::audio_dev_error"
#define SWITCH_PA_CALL_ID_VARIABLE "pa_call_id"
<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->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->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, "Ring Error!\n");
                                                switch_core_file_close(&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 && !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 >= 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(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_RINGING) == SWITCH_STATUS_SUCCESS) {
                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_info", buf);
<span style="color: #A00000">-                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call_id", tech_pvt->call_id);</span>
<span style="color: #00A000">+                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call_id", tech_pvt->call_id); /* left behind for backwards compatability */</span>
<span style="color: #00A000">+                                        switch_channel_set_variable(channel, SWITCH_PA_CALL_ID_VARIABLE, tech_pvt->call_id);</span>
                                        switch_channel_event_set_data(channel, event);
                                        switch_event_fire(&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(&globals.read_timer) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                                if (switch_core_timer_next(&globals.readfile_timer) != SWITCH_STATUS_SUCCESS) {</span>
                                        switch_core_file_close(&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(&fh, &pos, 0, SEEK_SET);
                                }
<span style="color: #A00000">-                                if (globals.ring_stream) {</span>
<span style="color: #A00000">-                                        WriteAudioStream(globals.ring_stream, abuf, (long) olen, &globals.write_timer);</span>
<span style="color: #00A000">+                                if (globals.ring_stream && (! switch_test_flag(globals.call_list, TFLAG_MASTER) || </span>
<span style="color: #00A000">+                                                        ( !globals.no_ring_during_call && 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->stream, abuf, (long) olen, &globals.ring_stream->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(&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, "Stop audio device.\n");</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->outdev == outdev) {</span>
<span style="color: #00A000">+                        if (indev == -1 || cur_stream->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->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 && 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->indev, globals.stream_list->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(&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->write_timer.timer_interface) {</span>
<span style="color: #00A000">+                        switch_core_timer_sync(&(globals.main_stream->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->write_timer.timer_interface) {</span>
<span style="color: #00A000">+                        switch_core_timer_sync(&(globals.ring_stream->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->stream);</span>
<span style="color: #00A000">+        stream->stream = NULL;</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        if (stream->write_timer.timer_interface) {</span>
<span style="color: #00A000">+                switch_core_timer_destroy(&stream->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(&globals.read_timer);
        }
<span style="color: #A00000">-        if (globals.write_timer.timer_interface) {</span>
<span style="color: #A00000">-                switch_core_timer_destroy(&globals.write_timer);</span>
<span style="color: #00A000">+        if (globals.readfile_timer.timer_interface) {</span>
<span style="color: #00A000">+                switch_core_timer_destroy(&globals.readfile_timer);</span>
        }
        if (globals.hold_timer.timer_interface) {
                switch_core_timer_destroy(&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, "Stop ring device.\n");</span>
<span style="color: #A00000">-        switch_mutex_lock(globals.device_lock);</span>
<span style="color: #A00000">-        if (globals.ring_stream && 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(&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->session), event);</span>
<span style="color: #00A000">+                switch_event_fire(&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 && last->next; last = last->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->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->next;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                for (previous = globals.stream_list; previous && previous->next && previous->next != stream; previous = previous->next) {</span>
<span style="color: #00A000">+                        </span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                previous->next = stream->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 && 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->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->next = tp->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 && ! 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->samples_per_packet, &globals.read_timer);</span>
<span style="color: #00A000">+        samples = ReadAudioStream(globals.main_stream->stream, globals.read_frame.data, globals.read_codec.implementation->samples_per_packet, &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((&globals), GFLAG_EAR)) {
<span style="color: #A00000">-                        WriteAudioStream(globals.audio_stream, (short *) frame->data, (int) (frame->datalen / sizeof(SAMPLE)), &globals.write_timer);</span>
<span style="color: #00A000">+                        WriteAudioStream(globals.main_stream->stream, (short *) frame->data, (int) (frame->datalen / sizeof(SAMPLE)), &(globals.main_stream->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->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, "Hey where is my memory pool?\n");
                        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(&globals.call_hash, module_pool);
        switch_mutex_init(&globals.device_lock, SWITCH_MUTEX_NESTED, module_pool);
        switch_mutex_init(&globals.pvt_lock, SWITCH_MUTEX_NESTED, module_pool);
<span style="color: #00A000">+        switch_mutex_init(&globals.streams_lock, SWITCH_MUTEX_NESTED, module_pool);</span>
        switch_mutex_init(&globals.flag_mutex, SWITCH_MUTEX_NESTED, module_pool);
        switch_mutex_init(&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((&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, "Couldn't register subclass!\n");
                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, "Couldn't register subclass!\n");</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, "Couldn't register subclass!\n");</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, "Couldn't register subclass!\n");
<span style="color: #800080; font-weight: bold">@@ -861,9 +1047,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load)</span>
        switch_console_set_complete("add pa devlist");
        switch_console_set_complete("add pa indev");
        switch_console_set_complete("add pa outdev");
<span style="color: #00A000">+        switch_console_set_complete("add pa preparestream");</span>
<span style="color: #00A000">+        switch_console_set_complete("add pa switchstream");</span>
<span style="color: #00A000">+        switch_console_set_complete("add pa closestreams");</span>
        switch_console_set_complete("add pa ringdev");
        switch_console_set_complete("add pa ringfile");
        switch_console_set_complete("add pa play");
<span style="color: #00A000">+        switch_console_set_complete("add pa playdev");</span>
        switch_console_set_complete("add pa looptest");
        /* 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, "Open of %s failed\n", 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, "ring-interval")) {
                                globals.ring_interval = atoi(val);
<span style="color: #00A000">+                        } else if (!strcmp(var, "no-auto-resume-call")) {</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, "no-ring-during-call")) {</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, "live-stream-switch")) {</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, "ring-file")) {
                                set_global_ring_file(val);
                        } else if (!strcmp(var, "hold-file")) {
<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, "ringtest")) {</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->write_function(stream, "Invalid output audio device\n");</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(&fh,        file,</span>
<span style="color: #00A000">+                globals.read_codec.implementation->number_of_channels,</span>
<span style="color: #00A000">+                globals.read_codec.implementation->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->write_function(stream, "Cannot play requested file %s\n", 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->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 >= 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) && globals.main_stream->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->write_function(stream, "Failed to engage audio device\n");</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->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(&fh, abuf, &olen) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                if (globals.destroying_streams || ! audio_stream->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->stream, abuf, (long) olen, &(audio_stream->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 <= 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->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(&fh);</span>
<span style="color: #00A000">+        if (! globals.call_list && ( ! no_close || strcasecmp(no_close, "no_close"))) {</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->actual_samples_per_second;</span>
<span style="color: #00A000">+        stream->write_function(stream, "playback test [%s] %d second(s) %d samples @%dkhz",</span>
<span style="color: #00A000">+                file, seconds, wrote, globals.read_codec.implementation->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 < 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 > 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(&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(&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(&globals.write_timer,</span>
<span style="color: #00A000">+        if (!globals.readfile_timer.timer_interface) {</span>
<span style="color: #00A000">+                if (switch_core_timer_init(&globals.readfile_timer,</span>
                                                                 globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet,
                                                                 module_pool) != SWITCH_STATUS_SUCCESS) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
                        switch_core_codec_destroy(&globals.read_codec);
                        switch_core_codec_destroy(&globals.write_codec);
<span style="color: #A00000">-                        switch_core_timer_destroy(&globals.read_timer);</span>
                        return SWITCH_STATUS_FALSE;
                }
        }
<span style="color: #00A000">+</span>
        if (!globals.hold_timer.timer_interface) {
                if (switch_core_timer_init(&globals.hold_timer,
                                                                 globals.timer_name, codec_ms, globals.read_codec.implementation->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(&globals.read_codec);
                        switch_core_codec_destroy(&globals.write_codec);
                        switch_core_timer_destroy(&globals.read_timer);
<span style="color: #A00000">-                        switch_core_timer_destroy(&globals.write_timer);</span>
<span style="color: #00A000">+                        switch_core_timer_destroy(&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 = &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 = &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)->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->device != -1) {</span>
<span style="color: #00A000">+                return OpenAudioStream(stream, inputParameters, outputParameters, globals.sample_rate, paClipOff, globals.read_codec.implementation->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->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, "Unable to alloc memory\n");</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->next = NULL;</span>
<span style="color: #00A000">+        stream->stream = NULL;</span>
<span style="color: #00A000">+        stream->indev = indev;</span>
<span style="color: #00A000">+        stream->outdev = outdev;</span>
<span style="color: #00A000">+        if (!stream->write_timer.timer_interface) {</span>
<span style="color: #00A000">+                if (switch_core_timer_init(&(stream->write_timer),</span>
<span style="color: #00A000">+                                                                 globals.timer_name, globals.codec_ms, globals.read_codec.implementation->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, "setup timer failed!\n");</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)->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)->defaultLowOutputLatency;
        outputParameters.hostApiSpecificStreamInfo = NULL;
<span style="color: #A00000">-        //err = OpenAudioStream(&globals.audio_stream, NULL/*&inputParameters*/, &outputParameters, sample_rate, paClipOff,</span>
<span style="color: #A00000">-        //globals.read_codec.implementation->samples_per_packet);</span>
<span style="color: #A00000">-        err = OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters, sample_rate, paClipOff,</span>
<span style="color: #A00000">-                                                 globals.read_codec.implementation->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(&(stream->stream), &inputParameters, &outputParameters);</span>
        if (err != paNoError) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening audio device retrying\n");
                switch_yield(1000000);
<span style="color: #A00000">-                err = OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters, sample_rate, paClipOff,</span>
<span style="color: #A00000">-                                                         globals.read_codec.implementation->samples_per_packet, globals.dual_streams);</span>
<span style="color: #00A000">+                err = open_audio_stream(&(stream->stream), &inputParameters, &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, "Can't open audio device\n");
<span style="color: #A00000">-                switch_core_codec_destroy(&globals.read_codec);</span>
<span style="color: #A00000">-                switch_core_codec_destroy(&globals.write_codec);</span>
<span style="color: #A00000">-                switch_core_timer_destroy(&globals.read_timer);</span>
<span style="color: #A00000">-                switch_core_timer_destroy(&globals.write_timer);</span>
<span style="color: #A00000">-                switch_core_timer_destroy(&globals.hold_timer);</span>
                if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_ERROR_AUDIO_DEV) == SWITCH_STATUS_SUCCESS) {
                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Reason", Pa_GetErrorText(err));
                        switch_event_fire(&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, "Engage audio device rate: %d channels %d\n", 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, "Created audio stream: %d channels %d\n", 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, "Error invalid output audio device\n");</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)->defaultLowOutputLatency;</span>
<span style="color: #A00000">-                outputParameters.hostApiSpecificStreamInfo = NULL;</span>
<span style="color: #A00000">-                err = OpenAudioStream(&globals.ring_stream, NULL,</span>
<span style="color: #A00000">-                                                         &outputParameters, sample_rate, paClipOff, globals.read_codec.implementation->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, "Engage ring device rate: %d channels %d\n", 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, "Can't open ring device\n");</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, "ERROR: Cannot use this command this while a call is in progress\n");</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->write_function(stream, "closestreams all open streams closed\n");</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 && ! globals.live_stream_switch) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ERROR: Cannot use this command this while a call is in progress\n");</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (*argv[0] == '#') {</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 < 0) {</span>
<span style="color: #00A000">+                stream->write_function(stream, "indev not set (invalid value)\n");</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->write_function(stream, "indev set to %d\n", 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 && ! globals.live_stream_switch) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ERROR: Cannot use this command this while a call is in progress\n");</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (*argv[0] == '#') {</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 < 0) {</span>
<span style="color: #00A000">+                stream->write_function(stream, "outdev not set (invalid value)\n");</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->write_function(stream, "outdev set to %d\n", 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], "#-1")) {</span>
<span style="color: #00A000">+                devval = -1;</span>
<span style="color: #00A000">+        } else if (*argv[0] == '#') {</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->write_function(stream, "preparestream not prepared as indev has (invalid value)\n");</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (*argv[1] == '#') {</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->write_function(stream, "preparestream not prepared as outdev has (invalid value)\n");</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->write_function(stream, "preparestream not prepared received an invalid stream back\n");</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        stream->write_function(stream, "preparestream prepared indev: %d outdev: %d\n", 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 && ! globals.live_stream_switch) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ERROR: Cannot use this command this while a call is in progress\n");</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (*argv[0] == '#') {</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->write_function(stream, "switchstream not prepared as indev has (invalid value)\n");</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (*argv[1] == '#') {</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->write_function(stream, "switchstream not prepared as outdev has (invalid value)\n");</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->write_function(stream, "switchstream was unable to switch\n");</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        stream->write_function(stream, "switchstream switched to indev: %d outdev: %d\n", 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 && ! globals.live_stream_switch) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ERROR: Cannot use this command this while a call is in progress\n");</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (! strcmp(argv[0], "#-1")) {</span>
<span style="color: #00A000">+                globals.ring_stream = NULL;</span>
<span style="color: #00A000">+                globals.ringdev = -1;</span>
<span style="color: #00A000">+                stream->write_function(stream, "ringdev set to %d\n", globals.ringdev);</span>
<span style="color: #00A000">+                return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+        } else if (*argv[0] == '#') {</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->write_function(stream, "ringdev not set as dev has (invalid value)\n");</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->write_function(stream, "ringdev set to %d\n", 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, "ERROR: Cannot use this command this while a call is in progress\n");</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->write_function(stream, "looptest Failed to engage audio device\n");</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 < 400; i++) {</span>
<span style="color: #00A000">+                if (globals.destroying_streams || ! globals.main_stream->stream) {</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                if ((samples = ReadAudioStream(globals.main_stream->stream, globals.read_frame.data, globals.read_codec.implementation->samples_per_packet, &globals.read_timer))) {</span>
<span style="color: #00A000">+                        WriteAudioStream(globals.main_stream->stream, globals.read_frame.data, (long) samples, &(globals.main_stream->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->write_function(stream, "Failed to read any bytes from indev\n");</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->write_function(stream, "looptest complete\n");</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->write_function(stream, "%s", 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(&fh,</span>
<span style="color: #00A000">+                                                                 argv[0],</span>
<span style="color: #00A000">+                                                                 globals.read_codec.implementation->number_of_channels,</span>
<span style="color: #00A000">+                                                                 globals.read_codec.implementation->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(&fh);</span>
<span style="color: #00A000">+                        set_global_ring_file(argv[0]);</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        stream->write_function(stream, "ringfile Unable to open ring file %s\n", 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->write_function(stream, "ringfile Failed to init codecs device\n");</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        stream->write_function(stream, "ringfile set to %s", 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, "none")) {
                for (tp = globals.call_list; tp; tp = tp->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->write_function(stream, "OK\n");
                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->write_function(stream, "OK\n");
        } else {
                stream->write_function(stream, "NO SUCH CALL\n");
<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->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->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->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, "Hey where is my memory pool?\n");
                        switch_core_session_destroy(&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->caller_profile);
                }
                tech_pvt->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->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] = "";
        char *http = NULL;
<span style="color: #800080; font-weight: bold">@@ -1878,9 +2378,15 @@ SWITCH_STANDARD_API(pa_cmd)</span>
                "pa devlist [xml]\n"
                "pa indev #<num>|<partial name>\n"
                "pa outdev #<num>|<partial name>\n"
<span style="color: #00A000">+                "pa preparestream #<indev_num> #<outdev_num>\n"</span>
<span style="color: #00A000">+                "pa switchstream #<indev_num> #<outdev_num>\n"</span>
<span style="color: #00A000">+                "pa closestreams\n"</span>
                "pa ringdev #<num>|<partial name>\n"
<span style="color: #A00000">-                "pa play [ringtest|<filename>]\n"</span>
<span style="color: #A00000">-                "pa ringfile [filename]\n" "pa looptest\n" "--------------------------------------------------------------------------------\n";</span>
<span style="color: #00A000">+                "pa play [ringtest|<filename>] [seconds] [no_close]\n"</span>
<span style="color: #00A000">+                "pa playdev #<num> [ringtest|<filename>] [seconds] [no_close]\n"</span>
<span style="color: #00A000">+                "pa ringfile [filename]\n"</span>
<span style="color: #00A000">+                "pa looptest\n"</span>
<span style="color: #00A000">+                "--------------------------------------------------------------------------------\n";</span>
        if (stream->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], "dtmf")) {
                func = dtmf_call;
<span style="color: #00A000">+        } else if (!strcasecmp(argv[0], "closestreams")) {</span>
<span style="color: #00A000">+                func = close_streams;</span>
        } else if (argv[1] && !strcmp(argv[0], "indev")) {
<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, "ERROR: Cannot use this command this while a call is in progress\n");</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] == '#') {</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 = "indev";</span>
<span style="color: #A00000">-                if (devval > -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] && !strcmp(argv[0], "outdev")) {
<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, "ERROR: Cannot use this command this while a call is in progress\n");</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] == '#') {</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 = "outdev";</span>
<span style="color: #A00000">-                if (devval > -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] && argv[2] && !strcmp(argv[0], "preparestream")) {</span>
<span style="color: #00A000">+                func = prepare_stream;        </span>
<span style="color: #00A000">+        } else if (argv[1] && argv[2] && !strcmp(argv[0], "switchstream")) {</span>
<span style="color: #00A000">+                func = switch_stream;        </span>
        } else if (argv[1] && !strcmp(argv[0], "ringdev")) {
<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, "ERROR: Cannot use this command this while a call is in progress\n");</span>
<span style="color: #A00000">-                        goto done;</span>
<span style="color: #00A000">+                func = set_ringdev;</span>
<span style="color: #00A000">+        } else if ((argv[1] && !strcmp(argv[0], "play"))) {</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->outdev : -1,argv[1],argv[2], argv[3]);</span>
<span style="color: #00A000">+                }else{</span>
<span style="color: #00A000">+                        stream->write_function(stream, "Failed to engage audio device\n");</span>
                }
<span style="color: #A00000">-</span>
<span style="color: #00A000">+                goto done;</span>
<span style="color: #00A000">+        } else if ((argv[1] && argv[2] && !strcmp(argv[0], "playdev"))) {</span>
                if (*argv[1] == '#') {
                        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 = "ringdev";</span>
<span style="color: #A00000">-                if (devval > -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] && !strcasecmp(argv[0], "play"))) {</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, "ERROR: Cannot use this command this while a call is in progress\n");</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], "ringtest")) {</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(&fh,</span>
<span style="color: #A00000">-                                                                         playfile,</span>
<span style="color: #A00000">-                                                                         globals.read_codec.implementation->number_of_channels,</span>
<span style="color: #A00000">-                                                                         globals.read_codec.implementation->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->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 >= 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->actual_samples_per_second * seconds;</span>
<span style="color: #A00000">-                                while (switch_core_file_read(&fh, abuf, &olen) == SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #A00000">-                                        WriteAudioStream(globals.audio_stream, abuf, (long) olen, &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 <= 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->samples_per_packet;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                switch_core_file_close(&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->actual_samples_per_second;</span>
<span style="color: #A00000">-                                stream->write_function(stream, "playback test [%s] %d second(s) %d samples @%dkhz",</span>
<span style="color: #A00000">-                                                                         playfile, seconds, wrote, globals.read_codec.implementation->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->write_function(stream, "Cannot play requested file %s\n", argv[1]);</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        stream->write_function(stream, "Failed to engage audio device\n");</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], "looptest")) {
<span style="color: #A00000">-                if (globals.call_list) {</span>
<span style="color: #A00000">-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ERROR: Cannot use this command this while a call is in progress\n");</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 < 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->samples_per_packet, &globals.read_timer))) {</span>
<span style="color: #A00000">-                                        WriteAudioStream(globals.audio_stream, globals.read_frame.data, (long) samples, &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->write_function(stream, "Failed to read any bytes from indev\n");</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->write_function(stream, "Failed to engage audio device\n");</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], "ringfile")) {
<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(&fh,</span>
<span style="color: #A00000">-                                                                                 argv[1],</span>
<span style="color: #A00000">-                                                                                 globals.read_codec.implementation->number_of_channels,</span>
<span style="color: #A00000">-                                                                                 globals.read_codec.implementation->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(&fh);</span>
<span style="color: #A00000">-                                        set_global_ring_file(argv[1]);</span>
<span style="color: #A00000">-                                } else {</span>
<span style="color: #A00000">-                                        stream->write_function(stream, "Unable to open ring file %s\n", argv[1]);</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                stream->write_function(stream, "Failed to engage audio device\n");</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        stream->write_function(stream, "%s", 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->write_function(stream, "Unknown Command or not enough args [%s]\n", argv[0]);</span>
        }
<span style="color: #00A000">+</span>
        if (func) {
                if (http) {
                        stream->write_function(stream, "<pre>");
<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(&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->write_function(stream, "\n\n</pre>");
                }
<span style="color: #A00000">-        } else {</span>
<span style="color: #A00000">-                if (devname) {</span>
<span style="color: #A00000">-                        if (devval > -1) {</span>
<span style="color: #A00000">-                                stream->write_function(stream, "%s set to %d\n", devname, devval);</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                stream->write_function(stream, "%s not set (invalid value)\n", devname);</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        stream->write_function(stream, "Unknown Command [%s]\n", 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>
                                                         "<input name=action type=submit value=\"switch\"> "
                                                         "<input name=action type=submit value=\"mute\"> "
                                                         "<input name=action type=submit value=\"unmute\"> "
<span style="color: #00A000">+                                                         "<input name=action type=submit value=\"indev\"> "</span>
<span style="color: #00A000">+                                                         "<input name=action type=submit value=\"outdev\"> "</span>
<span style="color: #00A000">+                                                         "<input name=action type=submit value=\"preparestream\"> "</span>
<span style="color: #00A000">+                                                         "<input name=action type=submit value=\"switchstream\"> "</span>
<span style="color: #00A000">+                                                         "<input name=action type=submit value=\"closestreams\"> "</span>
<span style="color: #00A000">+                                                         "<input name=action type=submit value=\"ringdev\"> "</span>
<span style="color: #00A000">+                                                         "<input name=action type=submit value=\"play\"> "</span>
<span style="color: #00A000">+                                                         "<input name=action type=submit value=\"playdev\"> "</span>
                                                         "<input name=action type=submit value=\"answer\"> <br><br>"
                                                         "<table border=1>\n"
                                                         "<tr><td><input name=action type=submit value=\"1\"></td>"
</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->iananame) ? 0 : 1;
                                        }
<span style="color: #A00000">-                                        if (match && bit_rate && map_bit_rate && map_bit_rate != bit_rate) {</span>
<span style="color: #00A000">+                                        if (match && bit_rate && map_bit_rate && map_bit_rate != bit_rate && strcasecmp(map->rm_encoding, "ilbc")) {</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, "ilbc", &d_30);</span>
<span style="color: #00A000">+        switch_core_hash_insert(runtime.ptimes, "ilbc", &d_30);</span>
        switch_core_hash_insert(runtime.ptimes, "G723", &d_30);
        if ((xml = switch_xml_open_cfg(file, &cfg, NULL))) {
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments:
Merge branch 'master' of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments:
Merge branch 'master' of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments:
Merge branch 'master' of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments:
Merge branch 'master' of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments:
Merge branch 'master' of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments:
Merge branch 'master' of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments:
enter
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/languages/mod_lua/mod_lua_extra.c b/src/mod/languages/mod_lua/mod_lua_extra.c</span>
<span style="color: #000080; font-weight: bold">index 38776f9..821cc60 100644</span>
<span style="color: #A00000">--- a/src/mod/languages/mod_lua/mod_lua_extra.c</span>
<span style="color: #00A000">+++ b/src/mod/languages/mod_lua/mod_lua_extra.c</span>
<span style="color: #800080; font-weight: bold">@@ -1,6 +1,8 @@</span>
using namespace LUA;
<span style="color: #A00000">-SWITCH_BEGIN_EXTERN_C void mod_lua_conjure_event(lua_State * L, switch_event_t *event, const char *name, int destroy_me)</span>
<span style="color: #00A000">+SWITCH_BEGIN_EXTERN_C</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+void mod_lua_conjure_event(lua_State * L, switch_event_t *event, const char *name, int destroy_me)</span>
{
        Event *result = new Event(event);
        SWIG_NewPointerObj(L, result, SWIGTYPE_p_Event, destroy_me);
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments:
enter
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/languages/mod_lua/mod_lua_extra.h b/src/mod/languages/mod_lua/mod_lua_extra.h</span>
<span style="color: #000080; font-weight: bold">index b96adc3..3fca994 100644</span>
<span style="color: #A00000">--- a/src/mod/languages/mod_lua/mod_lua_extra.h</span>
<span style="color: #00A000">+++ b/src/mod/languages/mod_lua/mod_lua_extra.h</span>
<span style="color: #800080; font-weight: bold">@@ -1,6 +1,8 @@</span>
#ifndef MOD_LUA_EXTRA
#define MOD_LUA_EXTRA
<span style="color: #A00000">-SWITCH_BEGIN_EXTERN_C void mod_lua_conjure_event(lua_State * L, switch_event_t *event, const char *name, int destroy_me);</span>
<span style="color: #00A000">+SWITCH_BEGIN_EXTERN_C</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+void mod_lua_conjure_event(lua_State * L, switch_event_t *event, const char *name, int destroy_me);</span>
void mod_lua_conjure_stream(lua_State * L, switch_stream_handle_t *stream, const char *name, int destroy_me);
void mod_lua_conjure_session(lua_State * L, switch_core_session_t *session, const char *name, int destroy_me);
</pre></div>
========================================================================<pre>
Summary of changes:
Freeswitch.2010.sln | 24 +-
build/modules.conf.in | 1 +
conf/autoload_configs/cdr_pg_csv.conf.xml | 35 +-
conf/autoload_configs/modules.conf.xml | 1 +
conf/autoload_configs/switch.conf.xml | 4 +
libs/esl/fs_cli.c | 44 +-
libs/ilbc/src/iLBC_decode.c | 2 +
libs/portaudio/build/msvc/portaudio.2010.vcxproj | 136 +--
src/mod/applications/mod_commands/mod_commands.c | 18 +-
src/mod/applications/mod_dptools/mod_dptools.c | 10 +-
src/mod/applications/mod_fsk/mod_fsk.c | 4 +-
src/mod/applications/mod_voicemail/mod_voicemail.c | 10 +-
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_portaudio/mod_portaudio.c | 1046 +++++++++++++-------
src/mod/endpoints/mod_sofia/mod_sofia.c | 2 +-
src/mod/endpoints/mod_sofia/sofia_glue.c | 2 +-
src/mod/endpoints/mod_sofia/sofia_presence.c | 2 +-
.../event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c | 396 ++++-----
src/mod/languages/mod_lua/mod_lua_extra.c | 4 +-
src/mod/languages/mod_lua/mod_lua_extra.h | 4 +-
src/mod/languages/mod_lua/mod_lua_wrap.cpp | 50 +
.../languages/mod_spidermonkey/mod_spidermonkey.c | 10 +
src/switch_core.c | 2 +-
src/switch_core_session.c | 15 +
src/switch_rtp.c | 4 +
src/switch_xml_config.c | 2 +-
support-d/prereq.sh | 2 +-
30 files changed, 1267 insertions(+), 801 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>