diff --git a/src/fs_encode.c b/src/fs_encode.c index 626601d9d6..49895390ef 100644 --- a/src/fs_encode.c +++ b/src/fs_encode.c @@ -129,6 +129,7 @@ int main(int argc, char *argv[]) switch_loadable_module_init(SWITCH_FALSE); switch_loadable_module_load_module("", "CORE_PCM_MODULE", SWITCH_TRUE, &err); switch_loadable_module_load_module("", "CORE_SPEEX_MODULE", SWITCH_TRUE, &err); + switch_loadable_module_load_module("", "CORE_SOFTTIMER_MODULE", SWITCH_TRUE, &err); for (i = 0; i < extra_modules_count; i++) { if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) extra_modules[i], SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index 02187db92d..c2fc659187 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -190,6 +190,13 @@ static void *SWITCH_THREAD_FUNC timer_thread_run(switch_thread_t *thread, void * pvt_t *pvt; int samples = 160; int ms = 20; + int r = 0; + + if (switch_core_timer_init(&timer, "soft", ms, samples, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "timer init failed.\n"); + r = -1; + goto end; + } switch_mutex_lock(t38_state_list.mutex); t38_state_list.thread_running = 1; @@ -197,15 +204,9 @@ static void *SWITCH_THREAD_FUNC timer_thread_run(switch_thread_t *thread, void * switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FAX timer thread started.\n"); - if (switch_core_timer_init(&timer, "soft", ms, samples, NULL) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "timer init failed.\n"); - t38_state_list.thread_running = -1; - goto end; - } - switch_mutex_lock(spandsp_globals.cond_mutex); - while(t38_state_list.thread_running > 0) { + while(t38_state_list.thread_running == 1) { switch_mutex_lock(t38_state_list.mutex); @@ -234,7 +235,7 @@ static void *SWITCH_THREAD_FUNC timer_thread_run(switch_thread_t *thread, void * switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FAX timer thread ended.\n"); switch_mutex_lock(t38_state_list.mutex); - t38_state_list.thread_running = 0; + t38_state_list.thread_running = r; switch_mutex_unlock(t38_state_list.mutex); if (timer.timer_interface) {