summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rwxr-xr-xmain.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/main.c b/main.c
index 8aaaeb9..17a8c29 100755
--- a/main.c
+++ b/main.c
@@ -19,12 +19,14 @@
#include "commonheaders.h"
-void Start();
+
+//maybe add mutex ?
+void Start(void *param);
int Parser();
LPINITPROC Init()
{
- Start();
+ mir_forkthread(&Start, 0);
return 0;
}
void Stop();
@@ -37,7 +39,7 @@ LPCHECKPROC CheckPlayer(HWND wnd, int flags)
{
if(!ghConnection)
{
- Start();
+ mir_forkthread(&Start, 0);
return 0;
}
if(Parser())
@@ -50,7 +52,7 @@ LPGETSTATUSPROC GetStatus()
{
if(!ghConnection)
{
- Start();
+ mir_forkthread(&Start, 0);
return 0;
}
if(Parser())
@@ -61,7 +63,7 @@ LPNAMEPROC GetFileName(HWND wnd, int flags)
{
if(!ghConnection)
{
- Start();
+ mir_forkthread(&Start, 0);
return 0;
}
return 0;
@@ -72,7 +74,7 @@ LPINFOPROC GetPlayerInfo(LPSONGINFO info, int flags)
{
if(!ghConnection)
{
- Start();
+ mir_forkthread(&Start, 0);
return 0;
}
if(Parser())
@@ -174,7 +176,7 @@ void RegisterPlayer()
CallService(MS_WAT_PLAYER, (WPARAM)WAT_ACT_REGISTER, (LPARAM)&player);
}
}
-void ReStart();
+void ReStart(void *data);
int Parser()
{
static NETLIBPACKETRECVER nlpr = {0};
@@ -187,7 +189,7 @@ int Parser()
nlpr.dwTimeout = 5;
if(!ghConnection)
{
- Start();
+ mir_forkthread(&Start, 0);
}
if(ghConnection)
{
@@ -209,7 +211,8 @@ int Parser()
recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr);
if(recvResult == SOCKET_ERROR)
{
- ReStart();
+ mir_forkthread(&ReStart, 0);
+// ReStart();
return 1;
}
if(strlen(tmp2) > 2)
@@ -221,7 +224,7 @@ int Parser()
recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr);
if(recvResult == SOCKET_ERROR)
{
- ReStart();
+ mir_forkthread(&ReStart, 0);
return 1;
}
}
@@ -231,14 +234,14 @@ int Parser()
recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr);
if(recvResult == SOCKET_ERROR)
{
- ReStart();
+ mir_forkthread(&ReStart, 0);
return 1;
}
Netlib_Send(ghConnection, "currentsong\n", strlen("currentsong\n"), 0);
recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr);
if(recvResult == SOCKET_ERROR)
{
- ReStart();
+ mir_forkthread(&ReStart, 0);
return 1;
}
nlpr.bytesUsed = nlpr.bytesAvailable;
@@ -396,7 +399,7 @@ int Parser()
}
-void Start()
+void Start(void* param)
{
NETLIBOPENCONNECTION nloc = {0};
char *tmp = (char*)mir_u2a(gbHost);
@@ -418,13 +421,13 @@ void Stop()
if(ghNetlibUser && (ghNetlibUser != INVALID_HANDLE_VALUE))
CallService(MS_NETLIB_SHUTDOWN,(WPARAM)ghNetlibUser,0);
}
-void ReStart()
+void ReStart(void *param)
{
if(ghPacketReciever)
Netlib_CloseHandle(ghPacketReciever);
if(ghConnection)
Netlib_CloseHandle(ghConnection);
Sleep(500);
- Start();
+ mir_forkthread(&Start, 0);
}