[Freeswitch-svn] [commit] r11610 - freeswitch/trunk/src
FreeSWITCH SVN
anthm at freeswitch.org
Tue Feb 3 09:17:31 PST 2009
Author: anthm
Date: Tue Feb 3 11:17:31 2009
New Revision: 11610
Log:
Modify state machine behaviour.
Endpoint handlers can still veto all other state handlers by returning SWITCH_STATUS_FALSE
Application handlers can only veto each other by returning SWITCH_STATUS_FALSE.
Global handlers will still be called when application vetos but they can still veto each other.
Default handler will not be called if application or global vetos or if state has changed from any handler.
Modified:
freeswitch/trunk/src/switch_core_state_machine.c
freeswitch/trunk/src/switch_ivr_originate.c
Modified: freeswitch/trunk/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/trunk/src/switch_core_state_machine.c (original)
+++ freeswitch/trunk/src/switch_core_state_machine.c Tue Feb 3 11:17:31 2009
@@ -276,12 +276,12 @@
midstate = state; \
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State %s\n", switch_channel_get_name(session->channel), __STATE_STR); \
if (!driver_state_handler->on_##__STATE || (driver_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS \
- && midstate == switch_channel_get_state(session->channel))) { \
+ )) { \
while (do_extra_handlers && (application_state_handler = switch_channel_get_state_handler(session->channel, index++)) != 0) { \
if (!application_state_handler || !application_state_handler->on_##__STATE \
|| (application_state_handler->on_##__STATE \
&& application_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS \
- && midstate == switch_channel_get_state(session->channel))) { \
+ )) { \
proceed++; \
continue; \
} else { \
@@ -290,11 +290,13 @@
} \
} \
index = 0; \
+ if (!proceed) global_proceed = 0; \
+ proceed = 1; \
while (do_extra_handlers && proceed && (application_state_handler = switch_core_get_state_handler(index++)) != 0) { \
if (!application_state_handler || !application_state_handler->on_##__STATE || \
(application_state_handler->on_##__STATE && \
application_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS \
- && midstate == switch_channel_get_state(session->channel))) { \
+ )) { \
proceed++; \
continue; \
} else { \
@@ -302,7 +304,8 @@
break; \
} \
} \
- if (proceed) { \
+ if (!proceed || midstate != switch_channel_get_state(session->channel)) global_proceed = 0; \
+ if (global_proceed) { \
switch_core_standard_on_##__STATE(session); \
} \
} \
@@ -374,6 +377,7 @@
if (state != switch_channel_get_running_state(session->channel) || state == CS_HANGUP) {
int index = 0;
int proceed = 1;
+ int global_proceed = 1;
int do_extra_handlers = 1;
switch_channel_set_running_state(session->channel, state);
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Tue Feb 3 11:17:31 2009
@@ -58,8 +58,10 @@
{
switch_channel_t *channel = switch_core_session_get_channel(session);
- /* put the channel in a passive state until it is answered */
- switch_channel_set_state(channel, CS_CONSUME_MEDIA);
+ if (switch_channel_get_state(channel) == CS_ROUTING) {
+ /* put the channel in a passive state until it is answered */
+ switch_channel_set_state(channel, CS_CONSUME_MEDIA);
+ }
return SWITCH_STATUS_FALSE;
}
More information about the Freeswitch-svn
mailing list