[Freeswitch-branches] [commit] r10695 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
FreeSWITCH SVN
gmaruzz at freeswitch.org
Wed Dec 10 07:52:02 PST 2008
Author: gmaruzz
Date: Wed Dec 10 10:52:01 2008
New Revision: 10695
Log:
skypiax: unload without crashes on windows, yay
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Wed Dec 10 10:52:01 2008
@@ -34,7 +34,10 @@
switch_core_session_t *global_session = NULL;
#ifdef WIN32
HANDLE win32_hGlobal_ThreadShutdownEvent;
+switch_thread_t *do_skype_thread_thread;
+HWND win32_hInit_MainWindowHandle;
#endif /* WIN32 */
+switch_thread_t *skypiax_do_controldev_thread_thread;
/*************************************************/
/*************************************************/
/*************************************************/
@@ -744,9 +747,7 @@
}
if (interface_id && interface_id < SKYPIAX_MAX_INTERFACES) {
struct skypiax_interface newconf;
- switch_thread_t *do_skype_thread_thread;
switch_threadattr_t *do_skype_thd_attr = NULL;
- switch_thread_t *skypiax_do_controldev_thread_thread;
switch_threadattr_t *skypiax_do_controldev_thread_thd_attr = NULL;
memset(&newconf, '\0', sizeof(newconf));
@@ -778,7 +779,7 @@
"STARTING interface_id=%d\n", interface_id);
switch_threadattr_create(&do_skype_thd_attr, skypiax_module_pool);
- switch_threadattr_detach_set(do_skype_thd_attr, 1);
+ //switch_threadattr_detach_set(do_skype_thd_attr, 1);
switch_threadattr_stacksize_set(do_skype_thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&do_skype_thread_thread, do_skype_thd_attr, do_skype_thread,
&SKYPIAX_INTERFACES[interface_id], skypiax_module_pool);
@@ -787,7 +788,7 @@
switch_threadattr_create(&skypiax_do_controldev_thread_thd_attr,
skypiax_module_pool);
- switch_threadattr_detach_set(skypiax_do_controldev_thread_thd_attr, 1);
+ //switch_threadattr_detach_set(skypiax_do_controldev_thread_thd_attr, 1);
switch_threadattr_stacksize_set(skypiax_do_controldev_thread_thd_attr,
SWITCH_THREAD_STACKSIZE);
switch_thread_create(&skypiax_do_controldev_thread_thread,
@@ -878,20 +879,28 @@
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown)
{
- int x = 1000;
+ int x = 100;
struct skypiax_interface *p = NULL;
+ switch_status_t status;
+ unsigned int howmany=8;
+
+ p = &SKYPIAX_INTERFACES[2];
running = 0;
+ switch_file_write(p->AsteriskHandlesAst.fdesc[1], "sciutati", &howmany); // let's the controldev_thread die
+
#ifdef WIN32
- SetEvent(win32_hGlobal_ThreadShutdownEvent);
+ if (SendMessage (win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the do_skype_thread die
+ ERRORA("WHY FALSE HERE? %d\n", SKYPIAX_P_LOG, GetLastError());
+ }
#endif
-
while (x) {
x--;
switch_yield(20000);
}
- NOTICA("EXITING FUNC!\n", SKYPIAX_P_LOG);
+ switch_thread_join(&status, do_skype_thread_thread);
+ switch_thread_join(&status, skypiax_do_controldev_thread_thread);
return SWITCH_STATUS_SUCCESS;
}
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Wed Dec 10 10:52:01 2008
@@ -7,7 +7,7 @@
extern int running;
extern skypiax_interface_t SKYPIAX_INTERFACES;
#ifdef WIN32
-extern HANDLE win32_hGlobal_ThreadShutdownEvent;
+extern HWND win32_hInit_MainWindowHandle;
#endif /* WIN32 */
#define SKYPE_AUDIO
@@ -379,7 +379,6 @@
#ifdef WIN32
struct AsteriskHandles *win32_AsteriskHandlesSkype;
-HWND win32_hInit_MainWindowHandle;
HINSTANCE win32_hInit_ProcessHandle;
char win32_acInit_WindowClassName[128];
UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach;
@@ -441,6 +440,7 @@
fIssueDefProc = 0;
switch (uiMessage) {
case WM_DESTROY:
+ NOTICA("got DESTROY\n", SKYPIAX_P_LOG);
win32_hInit_MainWindowHandle = NULL;
PostQuitMessage(0);
break;
@@ -593,9 +593,6 @@
&& win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
if (win32_Initialize_CreateWindowClass()) {
if (win32_Initialize_CreateMainWindow()) {
- //win32_hGlobal_ThreadShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- win32_hGlobal_ThreadShutdownEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (win32_hGlobal_ThreadShutdownEvent != NULL) {
if (SendMessage
(HWND_BROADCAST, win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
(WPARAM) win32_hInit_MainWindowHandle, 0) != 0) {
@@ -603,28 +600,15 @@
win32_hInit_MainWindowHandle;
while (1) {
MSG oMessage;
- const HANDLE *MsgWaitHandles[1];
-
- MsgWaitHandles[0] = &win32_hGlobal_ThreadShutdownEvent;
if(!running)
break;
- while (MsgWaitResult = MsgWaitForMultipleObjects(1,MsgWaitHandles, FALSE, 300,QS_ALLPOSTMESSAGE)){
- if(!running)
- break;
- if (MsgWaitResult == WAIT_TIMEOUT) {
- continue;
- }
-
- GetMessage(&oMessage, 0, 0, 0);
- if(!running)
+ while( GetMessage(&oMessage, 0, 0, 0) ){
break;
TranslateMessage(&oMessage);
DispatchMessage(&oMessage);
}
}
}
- CloseHandle(win32_hGlobal_ThreadShutdownEvent);
- }
win32_DeInitialize_DestroyMainWindow();
}
win32_DeInitialize_DestroyWindowClass();
More information about the Freeswitch-branches
mailing list