[Freeswitch-svn] [commit] r10182 - in freeswitch/trunk/src: . include
Freeswitch SVN
brian at freeswitch.org
Tue Oct 28 20:04:21 EDT 2008
Author: brian
Date: Tue Oct 28 20:04:20 2008
New Revision: 10182
Modified:
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/switch_core_codec.c
freeswitch/trunk/src/switch_core_io.c
freeswitch/trunk/src/switch_core_media_bug.c
freeswitch/trunk/src/switch_core_session.c
Log:
fix FSCORE-210
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Tue Oct 28 20:04:20 2008
@@ -623,7 +623,8 @@
SWITCH_STATUS_NOTFOUND,
SWITCH_STATUS_UNLOAD,
SWITCH_STATUS_NOUNLOAD,
- SWITCH_STATUS_IGNORE
+ SWITCH_STATUS_IGNORE,
+ SWITCH_STATUS_NOT_INITALIZED
} switch_status_t;
Modified: freeswitch/trunk/src/switch_core_codec.c
==============================================================================
--- freeswitch/trunk/src/switch_core_codec.c (original)
+++ freeswitch/trunk/src/switch_core_codec.c Tue Oct 28 20:04:20 2008
@@ -60,45 +60,34 @@
char tmp[30];
switch_status_t status = SWITCH_STATUS_SUCCESS;
- if (codec && !codec->implementation) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot set UNINITIALIZED codec!\n");
- status = SWITCH_STATUS_FALSE;
- goto end;
- }
-
- if (!codec || codec == session->real_read_codec) {
-
+ if (!codec || !codec->implementation) {
if (session->real_read_codec) {
- if (session->real_read_codec->implementation) {
- session->read_codec = session->real_read_codec;
- session->read_impl = *session->real_read_codec->implementation;
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "resetting to uninitilized codec, setting to NULL\n");
- session->read_codec = session->real_read_codec = NULL;
- status = SWITCH_STATUS_FALSE;
- goto end;
- }
+ session->read_codec = session->real_read_codec;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Restore original codec.\n");
} else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot set UNINITIALIZED codec!\n");
status = SWITCH_STATUS_FALSE;
goto end;
}
-
- } else if (codec) {
- if (session->read_codec != session->real_read_codec) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot double-set codec!\n");
- status = SWITCH_STATUS_FALSE;
- goto end;
- }
-
- session->read_codec = codec;
- session->read_impl = *codec->implementation;
+ } else {
if (!session->real_read_codec) {
- session->real_read_codec = session->read_codec;
+ session->read_codec = session->real_read_codec = codec;
+ } else {
+ session->read_codec = codec;
}
}
- if (session->read_codec && codec && session->read_impl.decoded_bytes_per_packet) {
+ if (!session->read_codec) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No READ codec!\n");
+ status = SWITCH_STATUS_FALSE;
+ goto end;
+ }
+
+ session->read_impl = *session->read_codec->implementation;
+
+
+ if (session->read_codec && session->read_impl.decoded_bytes_per_packet) {
if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(session->channel, event);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-read-codec-name", session->read_impl.iananame);
@@ -477,12 +466,12 @@
if (!codec->implementation) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec is not initialized!\n");
- return SWITCH_STATUS_GENERR;
+ return SWITCH_STATUS_NOT_INITALIZED;
}
if (!switch_test_flag(codec, SWITCH_CODEC_FLAG_ENCODE)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec encoder is not initialized!\n");
- return SWITCH_STATUS_GENERR;
+ return SWITCH_STATUS_NOT_INITALIZED;
}
return codec->implementation->encode(codec, other_codec, decoded_data, decoded_data_len, decoded_rate, encoded_data, encoded_data_len, encoded_rate,
@@ -502,12 +491,12 @@
if (!codec->implementation) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec is not initialized!\n");
- return SWITCH_STATUS_GENERR;
+ return SWITCH_STATUS_NOT_INITALIZED;
}
if (!switch_test_flag(codec, SWITCH_CODEC_FLAG_DECODE)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec decoder is not initialized!\n");
- return SWITCH_STATUS_GENERR;
+ return SWITCH_STATUS_NOT_INITALIZED;
}
return codec->implementation->decode(codec, other_codec, encoded_data, encoded_data_len, encoded_rate, decoded_data, decoded_data_len, decoded_rate,
@@ -520,7 +509,7 @@
if (!codec->implementation) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec is not initialized!\n");
- return SWITCH_STATUS_GENERR;
+ return SWITCH_STATUS_NOT_INITALIZED;
}
codec->implementation->destroy(codec);
Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c (original)
+++ freeswitch/trunk/src/switch_core_io.c Tue Oct 28 20:04:20 2008
@@ -296,6 +296,9 @@
read_frame = &session->raw_read_frame;
status = SWITCH_STATUS_SUCCESS;
break;
+ case SWITCH_STATUS_NOT_INITALIZED:
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec init error!\n");
+ goto done;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec %s decoder error!\n", session->read_codec->codec_interface->interface_name);
goto done;
@@ -437,6 +440,11 @@
*frame = &session->raw_read_frame;
status = SWITCH_STATUS_SUCCESS;
break;
+ case SWITCH_STATUS_NOT_INITALIZED:
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec init error!\n");
+ *frame = NULL;
+ status = SWITCH_STATUS_GENERR;
+ break;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec %s encoder error!\n",
session->read_codec->codec_interface->interface_name);
@@ -650,11 +658,15 @@
status = SWITCH_STATUS_SUCCESS;
break;
default:
+ if (status == SWITCH_STATUS_NOT_INITALIZED) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec init error!\n");
+ return status;
+ }
if (ptime_mismatch) {
status = perform_write(session, frame, flags, stream_id);
return SWITCH_STATUS_SUCCESS;
}
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec %s decoder error!\n", frame->codec->codec_interface->interface_name);
return status;
}
@@ -799,6 +811,10 @@
write_frame = enc_frame;
status = SWITCH_STATUS_SUCCESS;
break;
+ case SWITCH_STATUS_NOT_INITALIZED:
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec init error!\n");
+ write_frame = NULL;
+ return status;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec %s encoder error!\n",
session->read_codec->codec_interface->interface_name);
@@ -886,6 +902,10 @@
write_frame = enc_frame;
status = SWITCH_STATUS_SUCCESS;
break;
+ case SWITCH_STATUS_NOT_INITALIZED:
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec init error!\n");
+ write_frame = NULL;
+ return status;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec %s encoder error %d!\n",
session->read_codec->codec_interface->interface_name, status);
Modified: freeswitch/trunk/src/switch_core_media_bug.c
==============================================================================
--- freeswitch/trunk/src/switch_core_media_bug.c (original)
+++ freeswitch/trunk/src/switch_core_media_bug.c Tue Oct 28 20:04:20 2008
@@ -290,6 +290,7 @@
if (session->bug_codec.implementation) {
switch_core_codec_destroy(&session->bug_codec);
+ memset(&session->bug_codec, 0, sizeof(session->bug_codec));
}
return SWITCH_STATUS_FALSE;
@@ -346,9 +347,10 @@
switch_thread_rwlock_unlock(session->bug_rwlock);
status = switch_core_media_bug_close(&bp);
}
-
+
if (!session->bugs && session->bug_codec.implementation) {
switch_core_codec_destroy(&session->bug_codec);
+ memset(&session->bug_codec, 0, sizeof(session->bug_codec));
}
return status;
Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c (original)
+++ freeswitch/trunk/src/switch_core_session.c Tue Oct 28 20:04:20 2008
@@ -672,7 +672,7 @@
switch_size_t has;
switch_core_session_set_read_codec(session, NULL);
-
+
/* clear resamplers */
switch_mutex_lock(session->resample_mutex);
switch_resample_destroy(&session->read_resampler);
More information about the Freeswitch-svn
mailing list