diff options
author | Pierre Ossman <ossman@cendio.se> | 2006-05-11 11:02:25 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2006-05-11 11:02:25 +0000 |
commit | 6d2a9367bafb8ae4a98fe725bcb52b021f0fa4e6 (patch) | |
tree | 18729a317d2243d56d62b21251a95b9b54610d46 | |
parent | 26870176bae0b56d844aadedcfa1888e0c68e378 (diff) |
Do WSAStartup() in the DLL entry routine instead of at context creation.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@837 fefdeb5f-60dc-0310-8127-8f9354f1896f
-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; } |