[Freeswitch-svn] [commit] r9819 - freeswitch/trunk/src/mod/languages/mod_managed
Freeswitch SVN
michaelgg at freeswitch.org
Sat Oct 4 00:14:12 EDT 2008
Author: michaelgg
Date: Sat Oct 4 00:14:11 2008
New Revision: 9819
Modified:
freeswitch/trunk/src/mod/languages/mod_managed/freeswitch.i
freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.cpp
Log:
Unified Mono and CLR in freeswitch_managed
Modified: freeswitch/trunk/src/mod/languages/mod_managed/freeswitch.i
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/freeswitch.i (original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/freeswitch.i Sat Oct 4 00:14:11 2008
@@ -39,11 +39,10 @@
%typemap(csclassmodifiers) switch_xml_flag_t "[System.Flags] public enum"
%typemap(csclassmodifiers) switch_xml_section_enum_t "[System.Flags] public enum"
-
// Some things we dont want exposed to managed users directly, since
// we're gonna handle them with our own internalcall methods
-%ignore dtmfDelegateHandle;
-%ignore hangupDelegateHandle;
+%ignore dtmfDelegate;
+%ignore hangupDelegate;
%ignore setHangupHook;
%ignore beginAllowThreads;
%ignore endAllowThreads;
@@ -114,6 +113,7 @@
%include switch.h
%include switch_types.h
+//%include switch_apr.h
%include switch_core_db.h
%include switch_regex.h
Modified: freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.cpp Sat Oct 4 00:14:11 2008
@@ -45,6 +45,10 @@
#include "freeswitch_managed.h"
#ifdef _MANAGED
+#define ATTACH_THREADS
+#else
+#define ATTACH_THREADS mono_thread_attach(globals.domain);
+#endif
ManagedSession::ManagedSession():CoreSession()
{
@@ -61,21 +65,6 @@
}
-ManagedSession::~ManagedSession()
-{
- // Do auto-hangup ourselves because CoreSession can't call check_hangup_hook
- // after ManagedSession destruction (cause at point it's pure virtual)
- if (session) {
- channel = switch_core_session_get_channel(session);
- if (switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) {
- switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
- setAutoHangup(0);
- }
- // Don't let any callbacks use this CoreSession anymore
- switch_channel_set_private(channel, "CoreSession", NULL);
- }
-}
-
bool ManagedSession::begin_allow_threads()
{
return true;
@@ -86,49 +75,10 @@
return true;
}
-void ManagedSession::check_hangup_hook()
-{
- if (!hangupDelegate) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hangupDelegateHandle didn't get an object.");
- return;
- }
- hangupDelegate();
-}
-
-switch_status_t ManagedSession::run_dtmf_callback(void *input, switch_input_type_t itype)
-{
- if (!dtmfDelegate) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dtmfDelegateHandle didn't get an object.");
- return SWITCH_STATUS_FALSE;;
- }
- char *result = dtmfDelegate(input, itype);
-
- switch_status_t status = process_callback_result(result);
- Marshal::FreeCoTaskMem(IntPtr(result)); // I think this is right
- return status;
-}
-
-#else
-
-ManagedSession::ManagedSession():CoreSession()
-{
-
-}
-
-ManagedSession::ManagedSession(char *uuid):CoreSession(uuid)
-{
-
-}
-
-ManagedSession::ManagedSession(switch_core_session_t *session):CoreSession(session)
-{
-
-}
ManagedSession::~ManagedSession()
{
- mono_thread_attach(globals.domain);
-
+ ATTACH_THREADS
// Do auto-hangup ourselves because CoreSession can't call check_hangup_hook
// after ManagedSession destruction (cause at point it's pure virtual)
if (session) {
@@ -142,20 +92,11 @@
}
}
-bool ManagedSession::begin_allow_threads()
-{
- return true;
-}
-
-bool ManagedSession::end_allow_threads()
-{
- return true;
-}
-
void ManagedSession::check_hangup_hook()
{
- mono_thread_attach(globals.domain);
+ ATTACH_THREADS
if (!hangupDelegate) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "hangupDelegate is null.");
return;
}
hangupDelegate();
@@ -163,14 +104,19 @@
switch_status_t ManagedSession::run_dtmf_callback(void *input, switch_input_type_t itype)
{
- mono_thread_attach(globals.domain);
+ ATTACH_THREADS
if (!dtmfDelegate) {
- return SWITCH_STATUS_SUCCESS;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "dtmfDelegate is null.");
+ return SWITCH_STATUS_FALSE;;
}
- char *resPtr = dtmfDelegate(input, itype);
- switch_status_t status = process_callback_result(resPtr);
- g_free(resPtr);
+ char *result = dtmfDelegate(input, itype);
+ switch_status_t status = process_callback_result(result);
+
+#if WIN32
+ CoTaskMemFree(result);
+#else
+ g_free(result)
+#endif
return status;
}
-#endif
More information about the Freeswitch-svn
mailing list