diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/polyp/context.c | 11 | ||||
-rw-r--r-- | src/polypcore/dllmain.c | 17 |
2 files changed, 13 insertions, 15 deletions
diff --git a/src/polyp/context.c b/src/polyp/context.c index c9a65847..d5cf90f8 100644 --- a/src/polyp/context.c +++ b/src/polyp/context.c @@ -142,13 +142,6 @@ pa_context *pa_context_new(pa_mainloop_api *mainloop, const char *name) { #endif pa_client_conf_env(c->conf); -#ifdef OS_IS_WIN32 - { - WSADATA data; - WSAStartup(MAKEWORD(2, 0), &data); - } -#endif - return c; } @@ -187,10 +180,6 @@ static void context_free(pa_context *c) { pa_xfree(c->name); pa_xfree(c->server); pa_xfree(c); - -#ifdef OS_IS_WIN32 - WSACleanup(); -#endif } pa_context* pa_context_ref(pa_context *c) { diff --git a/src/polypcore/dllmain.c b/src/polypcore/dllmain.c index d1d120ab..95473b06 100644 --- a/src/polypcore/dllmain.c +++ b/src/polypcore/dllmain.c @@ -34,12 +34,21 @@ extern pa_set_root(HANDLE handle); BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { - if (fdwReason != DLL_PROCESS_ATTACH) - return TRUE; + WSADATA data; - if (!pa_set_root(hinstDLL)) - return FALSE; + switch (fdwReason) { + case DLL_PROCESS_ATTACH: + if (!pa_set_root(hinstDLL)) + return FALSE; + WSAStartup(MAKEWORD(2, 0), &data); + break; + + case DLL_PROCESS_DETACH: + WSACleanup(); + break; + + } return TRUE; } |