patch for FSCORE-205
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10202 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
93b20b8dc9
commit
623ba5c271
|
@ -308,10 +308,30 @@ static switch_status_t channel_on_execute(switch_core_session_t *session)
|
||||||
static void deactivate_audio_device(void)
|
static void deactivate_audio_device(void)
|
||||||
{
|
{
|
||||||
switch_mutex_lock(globals.device_lock);
|
switch_mutex_lock(globals.device_lock);
|
||||||
|
/* LOCKED ************************************************************************************************** */
|
||||||
|
|
||||||
if (globals.audio_stream) {
|
if (globals.audio_stream) {
|
||||||
CloseAudioStream(globals.audio_stream);
|
CloseAudioStream(globals.audio_stream);
|
||||||
globals.audio_stream = NULL;
|
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);
|
switch_mutex_unlock(globals.device_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1142,13 +1162,17 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
|
||||||
codec_ms = globals.codec_ms;
|
codec_ms = globals.codec_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!globals.read_codec.implementation) {
|
||||||
if (switch_core_codec_init(&globals.read_codec,
|
if (switch_core_codec_init(&globals.read_codec,
|
||||||
"L16",
|
"L16",
|
||||||
NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
|
NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
|
||||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!globals.write_codec.implementation) {
|
||||||
if (switch_core_codec_init(&globals.write_codec,
|
if (switch_core_codec_init(&globals.write_codec,
|
||||||
"L16",
|
"L16",
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1160,6 +1184,7 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!globals.timer.timer_interface) {
|
||||||
if (switch_core_timer_init(&globals.timer,
|
if (switch_core_timer_init(&globals.timer,
|
||||||
globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet,
|
globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet,
|
||||||
module_pool) != SWITCH_STATUS_SUCCESS) {
|
module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
@ -1168,7 +1193,9 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
|
||||||
switch_core_codec_destroy(&globals.write_codec);
|
switch_core_codec_destroy(&globals.write_codec);
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!globals.hold_timer.timer_interface) {
|
||||||
if (switch_core_timer_init(&globals.hold_timer,
|
if (switch_core_timer_init(&globals.hold_timer,
|
||||||
globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet,
|
globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet,
|
||||||
module_pool) != SWITCH_STATUS_SUCCESS) {
|
module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
@ -1178,6 +1205,7 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
|
||||||
switch_core_timer_destroy(&globals.timer);
|
switch_core_timer_destroy(&globals.timer);
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
globals.read_frame.rate = sample_rate;
|
globals.read_frame.rate = sample_rate;
|
||||||
globals.read_frame.codec = &globals.read_codec;
|
globals.read_frame.codec = &globals.read_codec;
|
||||||
|
@ -1204,7 +1232,8 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open audio device!\n");
|
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.read_codec);
|
||||||
switch_core_codec_destroy(&globals.write_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;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,6 +285,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_close(switch_file_handle_t *fh)
|
||||||
switch_core_destroy_memory_pool(&fh->memory_pool);
|
switch_core_destroy_memory_pool(&fh->memory_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(fh, 0, sizeof(*fh));
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_timer_destroy(switch_timer_t *timer)
|
||||||
switch_core_destroy_memory_pool(&timer->memory_pool);
|
switch_core_destroy_memory_pool(&timer->memory_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(timer, 0, sizeof(*timer));
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue