skypopen: fixing bug from Anton VG, adding some guards against NULL sessions and channels

This commit is contained in:
Giovanni Maruzzelli 2011-05-21 02:36:51 -05:00
parent 3ad0d5d624
commit 7fa3f7f3dd

View File

@ -938,6 +938,8 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
char *p = digit_str; char *p = digit_str;
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
if(channel){
while (p && *p) { while (p && *p) {
switch_dtmf_t dtmf; switch_dtmf_t dtmf;
dtmf.digit = *p; dtmf.digit = *p;
@ -948,6 +950,9 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPOPEN_P_LOG, digit_str, (unsigned int) new_dtmf_timestamp, NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPOPEN_P_LOG, digit_str, (unsigned int) new_dtmf_timestamp,
(unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp)); (unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp));
tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp; tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp;
}else{
WARNINGA("NO CHANNEL ?\n", SKYPOPEN_P_LOG);
}
} }
} }
} }
@ -2138,6 +2143,7 @@ int dtmf_received(private_t *tech_pvt, char *value)
switch_channel_t *channel = NULL; switch_channel_t *channel = NULL;
session = switch_core_session_locate(tech_pvt->session_uuid_str); session = switch_core_session_locate(tech_pvt->session_uuid_str);
if (session) {
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
if (channel) { if (channel) {
@ -2165,6 +2171,9 @@ int dtmf_received(private_t *tech_pvt, char *value)
WARNINGA("received %c DTMF, but no channel?\n", SKYPOPEN_P_LOG, value[0]); WARNINGA("received %c DTMF, but no channel?\n", SKYPOPEN_P_LOG, value[0]);
} }
switch_core_session_rwunlock(session); switch_core_session_rwunlock(session);
}else{
WARNINGA("received %c DTMF, but no session?\n", SKYPOPEN_P_LOG, value[0]);
}
return 0; return 0;
} }