From e42dd48d7f5ab197728d326ea3cdade2f252a860 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Mon, 27 Feb 2006 04:01:38 +0000 Subject: [PATCH] add mod_spidermonkey to msvc build, tweak mod_spidermonkey warnings, fix tts interface. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@686 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_core.h | 6 +- src/include/switch_frame.h | 2 +- src/include/switch_module_interfaces.h | 6 +- .../mod_spidermonkey/mod_spidermonkey.c | 16 +- .../mod_spidermonkey/mod_spidermonkey.vcproj | 214 ++++++++++++++++++ src/switch_core.c | 6 +- src/switch_ivr.c | 2 +- w32/vsnet/Freeswitch.sln | 12 + w32/vsnet/GetLibs.vbs | 6 +- 9 files changed, 249 insertions(+), 21 deletions(-) create mode 100644 src/mod/languages/mod_spidermonkey/mod_spidermonkey.vcproj diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 86281717e9..5db2487ac5 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -801,7 +801,7 @@ SWITCH_DECLARE(switch_status) switch_core_speech_interpret_asr(switch_speech_han \param flags flags in/out for fine tuning \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful */ -SWITCH_DECLARE(switch_status) switch_core_speech_feed_tts(switch_speech_handle *sh, char *text, unsigned int *flags); +SWITCH_DECLARE(switch_status) switch_core_speech_feed_tts(switch_speech_handle *sh, char *text, switch_speech_flag *flags); /*! \brief Read rendered audio from the TTS module @@ -816,14 +816,14 @@ SWITCH_DECLARE(switch_status) switch_core_speech_feed_tts(switch_speech_handle * void *data, unsigned int *datalen, unsigned int *rate, - unsigned int *flags); + switch_speech_flag *flags); /*! \brief Close an open speech handle \param sh the speech handle to close \param flags flags in/out for fine tuning \return SWITCH_STATUS_SUCCESS if the file handle was closed */ -SWITCH_DECLARE(switch_status) switch_core_speech_close(switch_speech_handle *sh, unsigned int *flags); +SWITCH_DECLARE(switch_status) switch_core_speech_close(switch_speech_handle *sh, switch_speech_flag *flags); ///\} diff --git a/src/include/switch_frame.h b/src/include/switch_frame.h index 303eefb299..d269cee927 100644 --- a/src/include/switch_frame.h +++ b/src/include/switch_frame.h @@ -53,7 +53,7 @@ struct switch_frame { /*! the entire size of the buffer */ size_t buflen; /*! the number of audio samples present (audio only) */ - int samples; + size_t samples; /*! the rate of the frame */ int rate; }; diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index 373ac2bfcd..e025e9d3fc 100644 --- a/src/include/switch_module_interfaces.h +++ b/src/include/switch_module_interfaces.h @@ -290,19 +290,19 @@ struct switch_speech_interface { int rate, unsigned int flags); /*! function to close the speech interface */ - switch_status (*speech_close)(switch_speech_handle *, unsigned int *flags); + switch_status (*speech_close)(switch_speech_handle *, switch_speech_flag *flags); /*! function to feed audio to the ASR*/ switch_status (*speech_feed_asr)(switch_speech_handle *sh, void *data, unsigned int *len, int rate, unsigned int *flags); /*! function to read text from the ASR*/ switch_status (*speech_interpret_asr)(switch_speech_handle *sh, char *buf, unsigned int buflen, unsigned int *flags); /*! function to feed text to the TTS*/ - switch_status (*speech_feed_tts)(switch_speech_handle *sh, char *text, unsigned int *flags); + switch_status (*speech_feed_tts)(switch_speech_handle *sh, char *text, switch_speech_flag *flags); /*! function to read audio from the TTS*/ switch_status (*speech_read_tts)(switch_speech_handle *sh, void *data, unsigned int *datalen, unsigned int *rate, - unsigned int *flags); + switch_speech_flag *flags); const struct switch_speech_interface *next; }; diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index 21774d05e3..a21867c9b5 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -47,6 +47,10 @@ #include "jsscript.h" #include +#ifdef _MSC_VER +#pragma warning(disable: 4311) +#endif + static const char modname[] = "mod_spidermonkey"; @@ -91,12 +95,6 @@ static switch_status init_js(void) globals.gErrFile = NULL; globals.gOutFile = NULL; globals.gStackChunkSize = 8192; - if(0) { - js_error(NULL, NULL, NULL); - if(&global_class); - - } - globals.gStackBase = (jsuword)&globals.stackDummy; globals.gErrFile = stderr; globals.gOutFile = stdout; @@ -230,11 +228,12 @@ static JSBool chan_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp int param = 0; JSBool res = JS_TRUE; switch_channel *channel; + char *name; channel = switch_core_session_get_channel(jc->session); assert(channel != NULL); - char *name = JS_GetStringBytes(JS_ValueToString(cx, id)); + name = JS_GetStringBytes(JS_ValueToString(cx, id)); /* numbers are our props anything else is a method */ if (name[0] >= 48 && name[0] <= 57) { param = atoi(name); @@ -303,11 +302,12 @@ static JSObject *new_jchan(JSContext *cx, JSObject *obj, switch_core_session *se static int eval_some_js(char *code, JSContext *cx, JSObject *obj, jsval *rval) { JSScript *script; - JS_ClearPendingException(cx); char *cptr; char path[512]; int res = 0; + JS_ClearPendingException(cx); + if (code[0] == '~') { cptr = code + 1; script = JS_CompileScript(cx, obj, cptr, strlen(cptr), "inline", 1); diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.vcproj b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.vcproj new file mode 100644 index 0000000000..34c6111b4c --- /dev/null +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.vcproj @@ -0,0 +1,214 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/switch_core.c b/src/switch_core.c index 45ab88f44e..1aecfd3c3e 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -514,7 +514,7 @@ SWITCH_DECLARE(switch_status) switch_core_speech_interpret_asr(switch_speech_han return sh->speech_interface->speech_interpret_asr(sh, buf, buflen, flags); } -SWITCH_DECLARE(switch_status) switch_core_speech_feed_tts(switch_speech_handle *sh, char *text, unsigned int *flags) +SWITCH_DECLARE(switch_status) switch_core_speech_feed_tts(switch_speech_handle *sh, char *text, switch_speech_flag *flags) { assert(sh != NULL); @@ -525,7 +525,7 @@ SWITCH_DECLARE(switch_status) switch_core_speech_read_tts(switch_speech_handle * void *data, unsigned int *datalen, unsigned int *rate, - unsigned int *flags) + switch_speech_flag *flags) { assert(sh != NULL); @@ -533,7 +533,7 @@ SWITCH_DECLARE(switch_status) switch_core_speech_read_tts(switch_speech_handle * } -SWITCH_DECLARE(switch_status) switch_core_speech_close(switch_speech_handle *sh, unsigned int *flags) +SWITCH_DECLARE(switch_status) switch_core_speech_close(switch_speech_handle *sh, switch_speech_flag *flags) { return sh->speech_interface->speech_close(sh, flags); } diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 04f23d5a1e..e7dc6db7fc 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -397,7 +397,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session char dtmf[128]; int interval = 0, samples = 0; size_t len = 0; - unsigned int ilen = 0; + size_t ilen = 0; switch_frame write_frame; switch_timer timer; switch_core_thread_session thread_session; diff --git a/w32/vsnet/Freeswitch.sln b/w32/vsnet/Freeswitch.sln index 48061c5ad2..469b068e1d 100644 --- a/w32/vsnet/Freeswitch.sln +++ b/w32/vsnet/Freeswitch.sln @@ -147,6 +147,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_event_multicast", "..\. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libteletone", "..\..\libs\libteletone\libteletone.vcproj", "{89385C74-5860-4174-9CAF-A39E7C48909C}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Languages", "Languages", "{0C808854-54D1-4230-BFF5-77B5FD905000}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey", "..\..\src\mod\languages\mod_spidermonkey\mod_spidermonkey.vcproj", "{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}" + ProjectSection(ProjectDependencies) = postProject + {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -259,6 +266,10 @@ Global {89385C74-5860-4174-9CAF-A39E7C48909C}.Debug|Win32.Build.0 = Debug|Win32 {89385C74-5860-4174-9CAF-A39E7C48909C}.Release|Win32.ActiveCfg = Release|Win32 {89385C74-5860-4174-9CAF-A39E7C48909C}.Release|Win32.Build.0 = Release|Win32 + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Debug|Win32.ActiveCfg = Debug|Win32 + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Debug|Win32.Build.0 = Debug|Win32 + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|Win32.ActiveCfg = Release|Win32 + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -287,5 +298,6 @@ Global {DCC13474-28DF-47CA-A8EB-72F8CE9A78C5} = {2D57D093-3F8D-4729-AD9A-68E945C200A5} {1A1FF289-4FD6-4285-A422-D31DD67A4723} = {CBD81696-EFB4-4D2F-8451-1B8DAA86155A} {EC3E5C7F-EE09-47E2-80FE-546363D14A98} = {B8F5B47B-8568-46EB-B320-64C17D2A98BC} + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F} = {0C808854-54D1-4230-BFF5-77B5FD905000} EndGlobalSection EndGlobal diff --git a/w32/vsnet/GetLibs.vbs b/w32/vsnet/GetLibs.vbs index 01f941eb46..2f457b0e9c 100644 --- a/w32/vsnet/GetLibs.vbs +++ b/w32/vsnet/GetLibs.vbs @@ -26,7 +26,7 @@ BuildModrawaudio=False BuildModpcre=False BuildModldap=False BuildModzeroconf=False -BuildSpiderMonkey=False +BuildModSpiderMonkey=False quote=Chr(34) ScriptDir=Left(WScript.ScriptFullName,Len(WScript.ScriptFullName)-Len(WScript.ScriptName)) @@ -89,6 +89,8 @@ If objArgs.Count >=1 Then BuildModldap=True Case "Mod_zeroconf" BuildModzeroconf=True + Case "Mod_SpiderMonkey" + BuildModSpiderMonkey=True Case Else BuildCore=True BuildModExosip=True @@ -200,7 +202,7 @@ If BuildModldap Then BuildLibs_ldap BuildDebug, BuildRelease End If -If BuildSpiderMonkey Then +If BuildModSpiderMonkey Then BuildLibs_SpiderMonkey BuildDebug, BuildRelease End If