[commit] r10202 - in freeswitch/trunk/src: . mod/endpoints/mod_portaudio
Author: anthm Date: Thu Oct 30 08:46:09 2008 New Revision: 10202 Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c freeswitch/trunk/src/switch_core_file.c freeswitch/trunk/src/switch_core_timer.c Log: patch for FSCORE-205 Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c Thu Oct 30 08:46:09 2008 @@ -308,10 +308,30 @@ static void deactivate_audio_device(void) { switch_mutex_lock(globals.device_lock); + /* LOCKED ************************************************************************************************** */ + if (globals.audio_stream) { CloseAudioStream(globals.audio_stream); globals.audio_stream = NULL; } + + if (globals.read_codec.implementation) { + switch_core_codec_destroy(&globals.read_codec); + } + + if (globals.write_codec.implementation) { + switch_core_codec_destroy(&globals.write_codec); + } + + if (globals.timer.timer_interface) { + switch_core_timer_destroy(&globals.timer); + } + + if (globals.hold_timer.timer_interface) { + switch_core_timer_destroy(&globals.hold_timer); + } + + /* UNLOCKED ************************************************************************************************* */ switch_mutex_unlock(globals.device_lock); } @@ -1142,13 +1162,17 @@ codec_ms = globals.codec_ms; } - if (switch_core_codec_init(&globals.read_codec, - "L16", - NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, - NULL) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - return SWITCH_STATUS_FALSE; - } else { + if (!globals.read_codec.implementation) { + if (switch_core_codec_init(&globals.read_codec, + "L16", + NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, + NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); + return SWITCH_STATUS_FALSE; + } + } + + if (!globals.write_codec.implementation) { if (switch_core_codec_init(&globals.write_codec, "L16", NULL, @@ -1160,25 +1184,29 @@ } } - if (switch_core_timer_init(&globals.timer, - 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); - return SWITCH_STATUS_FALSE; + if (!globals.timer.timer_interface) { + if (switch_core_timer_init(&globals.timer, + 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); + return SWITCH_STATUS_FALSE; + } } - if (switch_core_timer_init(&globals.hold_timer, + 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, - module_pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup hold timer failed!\n"); - switch_core_codec_destroy(&globals.read_codec); - switch_core_codec_destroy(&globals.write_codec); - switch_core_timer_destroy(&globals.timer); - return SWITCH_STATUS_FALSE; + module_pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup hold timer failed!\n"); + switch_core_codec_destroy(&globals.read_codec); + switch_core_codec_destroy(&globals.write_codec); + switch_core_timer_destroy(&globals.timer); + return SWITCH_STATUS_FALSE; + } } - + globals.read_frame.rate = sample_rate; globals.read_frame.codec = &globals.read_codec; @@ -1204,7 +1232,8 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open audio device!\n"); switch_core_codec_destroy(&globals.read_codec); switch_core_codec_destroy(&globals.write_codec); - + switch_core_timer_destroy(&globals.timer); + switch_core_timer_destroy(&globals.hold_timer); return SWITCH_STATUS_FALSE; } } Modified: freeswitch/trunk/src/switch_core_file.c ============================================================================== --- freeswitch/trunk/src/switch_core_file.c (original) +++ freeswitch/trunk/src/switch_core_file.c Thu Oct 30 08:46:09 2008 @@ -285,6 +285,8 @@ switch_core_destroy_memory_pool(&fh->memory_pool); } + memset(fh, 0, sizeof(*fh)); + return status; } Modified: freeswitch/trunk/src/switch_core_timer.c ============================================================================== --- freeswitch/trunk/src/switch_core_timer.c (original) +++ freeswitch/trunk/src/switch_core_timer.c Thu Oct 30 08:46:09 2008 @@ -125,6 +125,8 @@ switch_core_destroy_memory_pool(&timer->memory_pool); } + memset(timer, 0, sizeof(*timer)); + return SWITCH_STATUS_SUCCESS; }
participants (1)
-
Freeswitch SVN