[commit] r8734 - in freeswitch/trunk/src: . mod/languages/mod_spidermonkey
Author: anthm Date: Sat May 31 12:48:54 2008 New Revision: 8734 Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h freeswitch/trunk/src/switch_core_io.c Log: keep hangup hook in the session thread Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original) +++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Sat May 31 12:48:54 2008 @@ -38,18 +38,17 @@ #include <curl/curl.h> #endif static int foo = 0; +static void check_hangup_hook(struct js_session *jss); SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spidermonkey_shutdown); SWITCH_MODULE_DEFINITION(mod_spidermonkey, mod_spidermonkey_load, mod_spidermonkey_shutdown, NULL); -#define METHOD_SANITY_CHECK() do { \ -if (!jss || !jss->session) { \ - eval_some_js("~throw new Error(\"You must call the session.originate method before calling this method!\");", cx, obj, rval); \ - *rval = BOOLEAN_TO_JSVAL(JS_FALSE); \ - return JS_FALSE; \ - } \ - } while(foo == 1) +#define METHOD_SANITY_CHECK() if (!jss || !jss->session) { \ + eval_some_js("~throw new Error(\"You must call the session.originate method before calling this method!\");", cx, obj, rval); \ + *rval = BOOLEAN_TO_JSVAL(JS_FALSE); \ + return JS_FALSE; \ + } else check_hangup_hook(jss) #define CHANNEL_SANITY_CHECK() do { \ if (!switch_channel_ready(channel)) { \ @@ -1148,11 +1147,11 @@ jss->stack_depth--; return SWITCH_STATUS_FALSE; } - + check_hangup_hook(jss); JS_ResumeRequest(cb_state->cx, cb_state->saveDepth); JS_CallFunction(cb_state->cx, cb_state->obj, cb_state->function, argc, argv, &cb_state->ret); cb_state->saveDepth = JS_SuspendRequest(cb_state->cx); - + check_hangup_hook(jss); jss->stack_depth--; return SWITCH_STATUS_SUCCESS; } @@ -1420,7 +1419,9 @@ args.input_callback = dtmf_func; args.buf = bp; args.buflen = len; + check_hangup_hook(jss); switch_ivr_record_file(jss->session, &fh, file_name, &args, limit); + check_hangup_hook(jss); JS_ResumeRequest(cx, cb_state.saveDepth); *rval = cb_state.ret; @@ -1470,7 +1471,9 @@ args.input_callback = dtmf_func; args.buf = bp; args.buflen = len; + check_hangup_hook(jss); switch_ivr_collect_digits_callback(jss->session, &args, to); + check_hangup_hook(jss); JS_ResumeRequest(cx, cb_state.saveDepth); *rval = cb_state.ret; @@ -1544,9 +1547,9 @@ args.input_callback = dtmf_func; args.buf = bp; args.buflen = len; - + check_hangup_hook(jss); switch_ivr_phrase_macro(jss->session, phrase_name, phrase_data, phrase_lang, &args); - + check_hangup_hook(jss); JS_ResumeRequest(cx, cb_state.saveDepth); *rval = cb_state.ret; @@ -1559,7 +1562,8 @@ int argc = 0; jsval ret; - if (jss->on_hangup && (jss->hook_state == CS_HANGUP || jss->hook_state == CS_ROUTING)) { + if (!jss->check_state && jss->on_hangup && (jss->hook_state == CS_HANGUP || jss->hook_state == CS_ROUTING)) { + jss->check_state++; argv[argc++] = OBJECT_TO_JSVAL(jss->obj); if (jss->hook_state == CS_HANGUP) { argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(jss->cx, "hangup")); @@ -1579,7 +1583,7 @@ switch_channel_state_t state = switch_channel_get_state(channel); if (jss->hook_state != state) { jss->hook_state = state; - check_hangup_hook(jss); + jss->check_state = 0; } } @@ -1673,7 +1677,9 @@ args.input_callback = dtmf_func; args.buf = bp; args.buflen = len; + check_hangup_hook(jss); switch_ivr_play_file(jss->session, &fh, file_name, &args); + check_hangup_hook(jss); JS_ResumeRequest(cx, cb_state.saveDepth); *rval = cb_state.ret; @@ -1862,7 +1868,9 @@ args.buflen = len; switch_core_speech_flush_tts(&jss->speech->sh); + check_hangup_hook(jss); switch_ivr_speak_text_handle(jss->session, &jss->speech->sh, &jss->speech->codec, NULL, text, &args); + check_hangup_hook(jss); JS_ResumeRequest(cx, cb_state.saveDepth); *rval = cb_state.ret; @@ -2011,7 +2019,7 @@ if (argc > 0) { JS_ValueToInt32(cx, argv[0], &timeout); } - + check_hangup_hook(jss); saveDepth = JS_SuspendRequest(cx); for (;;) { if (((elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000)) > (switch_time_t) timeout) @@ -2029,7 +2037,7 @@ switch_yield(1000); } JS_ResumeRequest(cx, saveDepth); - + check_hangup_hook(jss); return JS_TRUE; } @@ -2050,7 +2058,7 @@ if (argc > 0) { JS_ValueToInt32(cx, argv[0], &timeout); } - + check_hangup_hook(jss); saveDepth = JS_SuspendRequest(cx); for (;;) { if (((elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000)) > (switch_time_t) timeout) @@ -2067,7 +2075,7 @@ switch_yield(1000); } JS_ResumeRequest(cx, saveDepth); - + check_hangup_hook(jss); return JS_TRUE; } @@ -2097,7 +2105,9 @@ if ((application_interface = switch_loadable_module_get_application_interface(app_name))) { if (application_interface->application_function) { saveDepth = JS_SuspendRequest(cx); + check_hangup_hook(jss); switch_core_session_exec(jss->session, application_interface, app_arg); + check_hangup_hook(jss); JS_ResumeRequest(cx, saveDepth); retval = JS_TRUE; } Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h (original) +++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h Sat May 31 12:48:54 2008 @@ -146,6 +146,7 @@ char *rdnis; char *context; char *username; + int check_state; struct js_session_speech *speech; }; Modified: freeswitch/trunk/src/switch_core_io.c ============================================================================== --- freeswitch/trunk/src/switch_core_io.c (original) +++ freeswitch/trunk/src/switch_core_io.c Sat May 31 12:48:54 2008 @@ -634,6 +634,11 @@ status = SWITCH_STATUS_SUCCESS; break; default: + 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; }
participants (1)
-
Freeswitch SVN