|
@ -49,15 +49,15 @@ std::thread* oscThread; |
|
|
* UdpListeningReceiveSocket runs in a blocking loop. [RunUntilSigInt()]*/ |
|
|
* UdpListeningReceiveSocket runs in a blocking loop. [RunUntilSigInt()]*/ |
|
|
void runOscThread(unsigned int port) |
|
|
void runOscThread(unsigned int port) |
|
|
{ |
|
|
{ |
|
|
thePacketListener = new ThePacketListener; |
|
|
|
|
|
|
|
|
if (!thePacketListener) |
|
|
|
|
|
thePacketListener = new ThePacketListener; |
|
|
|
|
|
|
|
|
|
|
|
if (sock) sock->~UdpListeningReceiveSocket(); |
|
|
sock = new UdpListeningReceiveSocket( |
|
|
sock = new UdpListeningReceiveSocket( |
|
|
IpEndpointName(IpEndpointName::ANY_ADDRESS, port), |
|
|
IpEndpointName(IpEndpointName::ANY_ADDRESS, port), |
|
|
thePacketListener); |
|
|
thePacketListener); |
|
|
sock->RunUntilSigInt(); //<<--- this is the loop
|
|
|
|
|
|
|
|
|
|
|
|
//Cleanup after sock exited the loop
|
|
|
|
|
|
sock = NULL; |
|
|
|
|
|
thePacketListener = NULL; |
|
|
|
|
|
|
|
|
sock->RunUntilSigInt(); //<<--- this is the loop
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* DLL was loaded */ |
|
|
/* DLL was loaded */ |
|
@ -69,9 +69,11 @@ BOOL APIENTRY DllMain( HMODULE hModule, |
|
|
switch (ul_reason_for_call) |
|
|
switch (ul_reason_for_call) |
|
|
{ |
|
|
{ |
|
|
case DLL_PROCESS_ATTACH: |
|
|
case DLL_PROCESS_ATTACH: |
|
|
|
|
|
break; |
|
|
case DLL_THREAD_ATTACH: |
|
|
case DLL_THREAD_ATTACH: |
|
|
break; |
|
|
break; |
|
|
case DLL_THREAD_DETACH: |
|
|
case DLL_THREAD_DETACH: |
|
|
|
|
|
break; |
|
|
case DLL_PROCESS_DETACH: |
|
|
case DLL_PROCESS_DETACH: |
|
|
close(); |
|
|
close(); |
|
|
break; |
|
|
break; |
|
@ -97,15 +99,16 @@ DLLEXPORT int open(HWND targetWindowHandle, unsigned int port) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
DLLEXPORT int close() |
|
|
|
|
|
|
|
|
DLLEXPORT int close(unsigned int clearListeners) |
|
|
{ |
|
|
{ |
|
|
if (sock && sock->IsBound()) |
|
|
|
|
|
|
|
|
if (sock) |
|
|
{ |
|
|
{ |
|
|
sock->AsynchronousBreak(); |
|
|
sock->AsynchronousBreak(); |
|
|
} |
|
|
} |
|
|
|
|
|
oscThread->join(); |
|
|
oscThread = NULL; |
|
|
oscThread = NULL; |
|
|
hwnd = NULL; |
|
|
hwnd = NULL; |
|
|
listeners.clear(); |
|
|
|
|
|
|
|
|
if (clearListeners) listeners.clear(); |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -168,7 +171,10 @@ DLLEXPORT int handleOscMsg(const osc::ReceivedMessage& m) |
|
|
|
|
|
|
|
|
if (!hwnd || !sock->IsBound()) |
|
|
if (!hwnd || !sock->IsBound()) |
|
|
{ |
|
|
{ |
|
|
OutputDebugString(L"handleOscMsg: Seems open() was not called yet...\r\n"); |
|
|
|
|
|
|
|
|
OutputDebugString(L"handleOscMsg: Seems open() was not called yet..."); |
|
|
|
|
|
if (!hwnd) OutputDebugString(L" (hwnd)"); |
|
|
|
|
|
if (!sock->IsBound()) OutputDebugString(L" (sock)"); |
|
|
|
|
|
OutputDebugString(L"\r\n"); |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|