FSCORE-349 add flag to denote if a codec is init or not

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12961 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2009-04-09 17:17:12 +00:00
parent 2840f826f0
commit 68b0359cfb
25 changed files with 90 additions and 78 deletions
@@ -4489,7 +4489,7 @@ static int setup_media(conference_member_t *member, conference_obj_t *conference
switch_core_session_reset(member->session, SWITCH_TRUE, SWITCH_FALSE);
if (member->read_codec.implementation) {
if (switch_core_codec_ready(&member->read_codec)) {
switch_core_codec_destroy(&member->read_codec);
}
+1 -1
View File
@@ -242,7 +242,7 @@ SWITCH_STANDARD_APP(bcast_function)
fail:
switch_core_session_set_read_codec(session, NULL);
if (codec.implementation) {
if (switch_core_codec_ready(&codec)) {
switch_core_codec_destroy(&codec);
}
+2 -2
View File
@@ -678,11 +678,11 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
switch_core_session_set_read_codec(session, NULL);
if (read_codec.implementation) {
if (switch_core_codec_ready(&read_codec)) {
switch_core_codec_destroy(&read_codec);
}
if (write_codec.implementation) {
if (switch_core_codec_ready(&write_codec)) {
switch_core_codec_destroy(&write_codec);
}
+2 -2
View File
@@ -346,11 +346,11 @@ SWITCH_STANDARD_APP(play_fsv_function)
switch_core_session_set_read_codec(session, read_codec);
}
if (codec.implementation) {
if (switch_core_codec_ready(&codec)) {
switch_core_codec_destroy(&codec);
}
if (vid_codec.implementation) {
if (switch_core_codec_ready(&vid_codec)) {
switch_core_codec_destroy(&vid_codec);
}
+2 -2
View File
@@ -931,11 +931,11 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_alsa_shutdown)
{
deactivate_audio_device();
if (globals.read_codec.implementation) {
if (switch_core_codec_ready(&globals.read_codec)) {
switch_core_codec_destroy(&globals.read_codec);
}
if (globals.write_codec.implementation) {
if (switch_core_codec_ready(&globals.write_codec)) {
switch_core_codec_destroy(&globals.write_codec);
}
switch_core_hash_destroy(&globals.call_hash);
@@ -1244,11 +1244,11 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
tech_pvt->rtp_session = NULL;
}
if (tech_pvt->read_codec.implementation) {
if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
if (tech_pvt->write_codec.implementation) {
if (switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
@@ -1440,7 +1440,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
}
}
if (!tech_pvt->read_codec.implementation) {
if (!switch_core_codec_ready(&tech_pvt->read_codec) || !tech_pvt->read_codec.implementation) {
return SWITCH_STATUS_GENERR;
}
+4 -3
View File
@@ -498,11 +498,11 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
switch_clear_flag_locked(tech_pvt, TFLAG_CODEC);
if (tech_pvt->read_codec.implementation) {
if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
if (tech_pvt->write_codec.implementation) {
if (!switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
@@ -1084,7 +1084,8 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
if (channel && switch_channel_up(channel)) {
int bytes = 0, frames = 1;
if (!switch_test_flag(tech_pvt, TFLAG_CODEC) || !tech_pvt->read_codec.implementation) {
if (!switch_test_flag(tech_pvt, TFLAG_CODEC) || !tech_pvt->read_codec.implementation ||
!switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
break;
}
@@ -113,11 +113,11 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses
interval = codec->implementation->microseconds_per_packet / 1000;
}
if (tech_pvt->read_codec.implementation) {
if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
if (tech_pvt->write_codec.implementation) {
if (switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
@@ -133,7 +133,7 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses
NULL,
switch_core_session_get_pool(session));
if (status != SWITCH_STATUS_SUCCESS || !tech_pvt->read_codec.implementation) {
if (status != SWITCH_STATUS_SUCCESS || !tech_pvt->read_codec.implementation || !switch_core_codec_ready(&tech_pvt->read_codec)) {
goto end;
}
@@ -373,11 +373,11 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
switch_core_timer_destroy(&tech_pvt->timer);
if (tech_pvt->read_codec.implementation) {
if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
if (tech_pvt->write_codec.implementation) {
if (switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
@@ -348,11 +348,11 @@ static void deactivate_audio_device(void)
static void destroy_codecs(void)
{
if (globals.read_codec.implementation) {
if (switch_core_codec_ready(&globals.read_codec)) {
switch_core_codec_destroy(&globals.read_codec);
}
if (globals.write_codec.implementation) {
if (switch_core_codec_ready(&globals.write_codec)) {
switch_core_codec_destroy(&globals.write_codec);
}
@@ -1294,7 +1294,7 @@ static switch_status_t engage_device(int restart)
return SWITCH_STATUS_SUCCESS;
}
if (!globals.read_codec.implementation) {
if (!switch_core_codec_ready(&globals.read_codec))) {
if (switch_core_codec_init(&globals.read_codec,
"L16",
NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
@@ -1306,7 +1306,7 @@ static switch_status_t engage_device(int restart)
switch_assert(globals.read_codec.implementation);
if (!globals.write_codec.implementation) {
if (!switch_core_codec_ready(&globals.write_codec)) {
if (switch_core_codec_init(&globals.write_codec,
"L16",
NULL,
@@ -200,11 +200,11 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
//switch_thread_cond_signal(tech_pvt->cond);
if (tech_pvt->read_codec.implementation) {
if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
if (tech_pvt->write_codec.implementation) {
if (switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
+4 -4
View File
@@ -205,12 +205,12 @@ static switch_status_t channel_on_hangup(switch_core_session_t * session)
skypiax_signaling_write(tech_pvt, msg_to_skype);
}
if (tech_pvt->read_codec.implementation) {
switch_core_codec_destroy(&tech_pvt->read_codec);
if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
if (tech_pvt->write_codec.implementation) {
switch_core_codec_destroy(&tech_pvt->write_codec);
if (switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
memset(tech_pvt->session_uuid_str, '\0', sizeof(tech_pvt->session_uuid_str));
+7 -6
View File
@@ -379,11 +379,11 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
sofia_clear_flag(tech_pvt, TFLAG_IO);
if (tech_pvt->read_codec.implementation) {
if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
if (tech_pvt->write_codec.implementation) {
if (switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
@@ -665,7 +665,8 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
tech_pvt->read_frame.datalen = 0;
sofia_set_flag_locked(tech_pvt, TFLAG_READING);
if (sofia_test_flag(tech_pvt, TFLAG_HUP) || sofia_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation) {
if (sofia_test_flag(tech_pvt, TFLAG_HUP) || sofia_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation ||
!switch_core_codec_ready(&tech_pvt->read_codec)) {
return SWITCH_STATUS_FALSE;
}
@@ -711,7 +712,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
int frames = 1;
if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
if (!tech_pvt->read_codec.implementation) {
if (!tech_pvt->read_codec.implementation || !switch_core_codec_ready(&tech_pvt->read_codec)) {
*frame = NULL;
return SWITCH_STATUS_GENERR;
}
@@ -872,7 +873,7 @@ static switch_status_t sofia_write_frame(switch_core_session_t *session, switch_
}
}
if (!tech_pvt->read_codec.implementation) {
if (!tech_pvt->read_codec.implementation || !switch_core_codec_ready(&tech_pvt->read_codec)) {
return SWITCH_STATUS_GENERR;
}
@@ -888,7 +889,7 @@ static switch_status_t sofia_write_frame(switch_core_session_t *session, switch_
return SWITCH_STATUS_SUCCESS;
}
if (sofia_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation) {
if (sofia_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation || !switch_core_codec_ready(&tech_pvt->read_codec)) {
return SWITCH_STATUS_FALSE;
}
+3 -3
View File
@@ -1752,7 +1752,7 @@ void sofia_glue_deactivate_rtp(private_object_t *tech_pvt)
switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int force)
{
if (tech_pvt->video_read_codec.implementation) {
if (tech_pvt->video_read_codec.implementation && switch_core_codec_ready(&tech_pvt->video_read_codec)) {
if (!force) {
return SWITCH_STATUS_SUCCESS;
}
@@ -1825,7 +1825,7 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
if (tech_pvt->read_codec.implementation) {
if (tech_pvt->read_codec.implementation && switch_core_codec_ready(&tech_pvt->read_codec)) {
if (!force) {
switch_goto_status(SWITCH_STATUS_SUCCESS, end);
}
@@ -1885,7 +1885,7 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
tech_pvt->read_frame.rate = tech_pvt->rm_rate;
ms = tech_pvt->write_codec.implementation->microseconds_per_packet / 1000;
if (!tech_pvt->read_codec.implementation) {
if (!switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
+3 -3
View File
@@ -948,11 +948,11 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_hangup(%p)\n"
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
//switch_thread_cond_signal(tech_pvt->cond);
if (tech_pvt->read_codec.implementation)
if (switch_core_codec_ready(&tech_pvt->read_codec))
switch_core_codec_destroy(&tech_pvt->read_codec);
if (tech_pvt->write_codec.implementation)
if (switch_core_codec_ready(&tech_pvt->write_codec)
switch_core_codec_destroy(&tech_pvt->write_codec);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s channel hangup\n", switch_channel_get_name(channel));
#if 0
@@ -171,7 +171,7 @@ static switch_status_t engage_device(portaudio_stream_source_t *source,int resta
return SWITCH_STATUS_SUCCESS;
}
if (!source->read_codec.implementation) {
if (!switch_core_codec_ready(&source->read_codec)) {
if (switch_core_codec_init(&source->read_codec,
"L16",
NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
@@ -183,7 +183,7 @@ static switch_status_t engage_device(portaudio_stream_source_t *source,int resta
switch_assert(source->read_codec.implementation);
if (!source->write_codec.implementation) {
if (!switch_core_codec_ready(&source->write_codec) {
if (switch_core_codec_init(&source->write_codec,
"L16",
NULL,
@@ -340,11 +340,11 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
switch_mutex_lock(source->device_lock);
CloseAudioStream(source->audio_stream);
if (source->read_codec.implementation) {
if (switch_core_codec_ready(&source->read_codec)) {
switch_core_codec_destroy(&source->read_codec);
switch_core_codec_destroy(&source->write_codec);
}
if (source->write_codec.implementation) {
if (switch_core_codec_ready(&source->write_codec) {
switch_core_codec_destroy(&source->write_codec);
}
switch_mutex_unlock(source->device_lock);