]> code.delx.au - pulseaudio/commitdiff
Do WSAStartup() in the DLL entry routine instead of at context creation.
authorPierre Ossman <ossman@cendio.se>
Thu, 11 May 2006 11:02:25 +0000 (11:02 +0000)
committerPierre Ossman <ossman@cendio.se>
Thu, 11 May 2006 11:02:25 +0000 (11:02 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@837 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/polyp/context.c
src/polypcore/dllmain.c

index c9a65847765d218524a645e200a3d3bd0bb2ee27..d5cf90f8eefd565eb8bbc516d940d8b71d916a8b 100644 (file)
@@ -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) {
index d1d120ab8e1d648a917d6701ffab4b4ad187e09e..95473b0688b2c060102cd2b2081f215e0d040942 100644 (file)
 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;
 }