mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
code analysis, clean up asserts related to switch_core_session_get_channel.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7402 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -40,17 +40,12 @@
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_time_t start, now, done = switch_timestamp_now() + (ms * 1000);
|
||||
switch_time_t start = switch_timestamp_now(), now, done = switch_timestamp_now() + (ms * 1000);
|
||||
switch_frame_t *read_frame;
|
||||
int32_t left, elapsed;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
start = switch_timestamp_now();
|
||||
|
||||
for (;;) {
|
||||
now = switch_timestamp_now();
|
||||
elapsed = (int32_t) ((now - start) / 1000);
|
||||
@@ -121,12 +116,9 @@ static void unicast_thread_launch(switch_unicast_conninfo_t *conninfo)
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_deactivate_unicast(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_unicast_conninfo_t *conninfo;
|
||||
int sanity = 0;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
if (!switch_channel_test_flag(channel, CF_UNICAST)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
@@ -159,14 +151,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_activate_unicast(switch_core_session_
|
||||
char *transport,
|
||||
char *flags)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
switch_unicast_conninfo_t *conninfo;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_unicast_conninfo_t *conninfo = switch_core_session_alloc(session, sizeof(*conninfo));
|
||||
switch_codec_t *read_codec;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
conninfo = switch_core_session_alloc(session, sizeof(*conninfo));
|
||||
switch_assert(conninfo != NULL);
|
||||
|
||||
conninfo->local_ip = switch_core_session_strdup(session, local_ip);
|
||||
@@ -270,9 +258,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
|
||||
char *event_lock = switch_event_get_header(event, "event-lock");
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
switch_assert(channel != NULL);
|
||||
switch_assert(event != NULL);
|
||||
|
||||
if (switch_strlen_zero(cmd)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Command!\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
@@ -382,10 +367,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_events(switch_core_session_t *session)
|
||||
{
|
||||
switch_event_t *event;
|
||||
switch_channel_t *channel;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
while (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_ivr_parse_event(session, event);
|
||||
@@ -399,16 +380,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_events(switch_core_session_
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, switch_input_args_t *args)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_channel_t *channel;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_frame_t *read_frame;
|
||||
int stream_id = 0;
|
||||
switch_event_t *event;
|
||||
switch_unicast_conninfo_t *conninfo = NULL;
|
||||
switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Careful, Channel is unanswered. Pre-answering...\n");
|
||||
switch_channel_pre_answer(channel);
|
||||
@@ -536,14 +514,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session, switch_input_args_t *args, uint32_t timeout)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_time_t started = 0;
|
||||
uint32_t elapsed;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
if (!args->input_callback) {
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
@@ -606,15 +581,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
|
||||
uint32_t abs_timeout)
|
||||
{
|
||||
switch_size_t i = 0, x = strlen(buf);
|
||||
switch_channel_t *channel;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
switch_time_t started = 0, digit_started = 0;
|
||||
uint32_t abs_elapsed = 0, digit_elapsed = 0;
|
||||
uint32_t eff_timeout = 0;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
if (terminator != NULL)
|
||||
*terminator = '\0';
|
||||
|
||||
@@ -709,14 +681,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session)
|
||||
{
|
||||
switch_core_session_message_t msg = { 0 };
|
||||
switch_channel_t *channel;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
msg.message_id = SWITCH_MESSAGE_INDICATE_HOLD;
|
||||
msg.from = __FILE__;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
switch_channel_set_flag(channel, CF_HOLD);
|
||||
switch_channel_set_flag(channel, CF_SUSPEND);
|
||||
|
||||
@@ -740,14 +709,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid)
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_unhold(switch_core_session_t *session)
|
||||
{
|
||||
switch_core_session_message_t msg = { 0 };
|
||||
switch_channel_t *channel;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
msg.message_id = SWITCH_MESSAGE_INDICATE_UNHOLD;
|
||||
msg.from = __FILE__;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
switch_channel_clear_flag(channel, CF_HOLD);
|
||||
switch_channel_clear_flag(channel, CF_SUSPEND);
|
||||
|
||||
@@ -782,7 +748,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_
|
||||
|
||||
if ((session = switch_core_session_locate(uuid))) {
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
if ((flags & SMF_REBRIDGE) && !switch_channel_test_flag(channel, CF_ORIGINATOR)) {
|
||||
swap = 1;
|
||||
}
|
||||
@@ -834,7 +800,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi
|
||||
if ((session = switch_core_session_locate(uuid))) {
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
if ((flags & SMF_REBRIDGE) && !switch_channel_test_flag(channel, CF_ORIGINATOR)) {
|
||||
swap = 1;
|
||||
@@ -846,7 +811,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi
|
||||
if ((flags & SMF_REBRIDGE) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &&
|
||||
(other_session = switch_core_session_locate(other_uuid))) {
|
||||
other_channel = switch_core_session_get_channel(other_session);
|
||||
switch_assert(other_channel != NULL);
|
||||
|
||||
switch_core_session_receive_message(other_session, &msg);
|
||||
switch_channel_clear_state_handler(other_channel, NULL);
|
||||
@@ -870,19 +834,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, const char *extension, const char *dialplan, const char *context)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_caller_profile_t *profile, *new_profile;
|
||||
switch_core_session_message_t msg = { 0 };
|
||||
switch_core_session_t *other_session;
|
||||
switch_channel_t *other_channel = NULL;
|
||||
const char *uuid = NULL;
|
||||
|
||||
switch_assert(session != NULL);
|
||||
switch_core_session_reset(session, SWITCH_TRUE);
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
switch_channel_clear_flag(channel, CF_ORIGINATING);
|
||||
|
||||
/* clear all state handlers */
|
||||
@@ -930,7 +889,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_
|
||||
|
||||
if (uuid && (other_session = switch_core_session_locate(uuid))) {
|
||||
other_channel = switch_core_session_get_channel(other_session);
|
||||
switch_assert(other_channel != NULL);
|
||||
switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BOND_VARIABLE, NULL);
|
||||
switch_core_session_rwunlock(other_session);
|
||||
}
|
||||
@@ -938,7 +896,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_
|
||||
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE))
|
||||
&& (other_session = switch_core_session_locate(uuid))) {
|
||||
other_channel = switch_core_session_get_channel(other_session);
|
||||
switch_assert(other_channel != NULL);
|
||||
|
||||
switch_channel_set_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
|
||||
switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
|
||||
@@ -1339,7 +1296,7 @@ SWITCH_DECLARE(int) switch_ivr_set_xml_chan_vars(switch_xml_t xml, switch_channe
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_t *session, switch_xml_t * xml_cdr)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_caller_profile_t *caller_profile;
|
||||
switch_xml_t variables, cdr, x_main_cp, x_caller_profile, x_caller_extension, x_times, time_tag,
|
||||
x_application, x_callflow, x_inner_extension, x_apps, x_o;
|
||||
@@ -1347,9 +1304,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_
|
||||
char tmp[512];
|
||||
int cdr_off = 0, v_off = 0;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
if (!(cdr = switch_xml_new("cdr"))) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -1553,7 +1507,7 @@ SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint3
|
||||
stfu_frame_t *jb_frame;
|
||||
switch_frame_t *read_frame, write_frame = { 0 };
|
||||
switch_status_t status;
|
||||
switch_channel_t *channel;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
uint32_t interval, samples;
|
||||
uint32_t ts = 0;
|
||||
|
||||
@@ -1570,7 +1524,6 @@ SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint3
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting delay to %dms (%d frames)\n", delay_ms, qlen);
|
||||
jb = stfu_n_init(qlen);
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
write_frame.codec = read_codec;
|
||||
|
||||
while(switch_channel_ready(channel)) {
|
||||
|
Reference in New Issue
Block a user