diff src/audio/windx5/SDL_dx5audio.c @ 5092:327f181542f1

Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share. I think this also fixes the bug relating to non-latin characters in filenames, since UNICODE wasn't defined in SDL_rwops.c
author Sam Lantinga <slouken@libsdl.org>
date Mon, 24 Jan 2011 21:20:30 -0800
parents 4160ba33b597
children b530ef003506
line wrap: on
line diff
--- a/src/audio/windx5/SDL_dx5audio.c	Mon Jan 24 17:47:18 2011 -0800
+++ b/src/audio/windx5/SDL_dx5audio.c	Mon Jan 24 21:20:30 2011 -0800
@@ -24,6 +24,7 @@
 /* Allow access to a raw mixing buffer */
 
 #include "SDL_timer.h"
+#include "SDL_loadso.h"
 #include "SDL_audio.h"
 #include "../SDL_audio_c.h"
 #include "SDL_dx5audio.h"
@@ -38,19 +39,19 @@
 #endif
 
 /* DirectX function pointers for audio */
-static HINSTANCE DSoundDLL = NULL;
+static void* DSoundDLL = NULL;
 static HRESULT(WINAPI * DSoundCreate) (LPGUID, LPDIRECTSOUND *, LPUNKNOWN) =
     NULL;
 
 static void
 DSOUND_Unload(void)
 {
+    DSoundCreate = NULL;
+
     if (DSoundDLL != NULL) {
-        FreeLibrary(DSoundDLL);
+        SDL_UnloadObject(DSoundDLL);
+        DSoundDLL = NULL;
     }
-
-    DSoundCreate = NULL;
-    DSoundDLL = NULL;
 }
 
 
@@ -61,17 +62,16 @@
 
     DSOUND_Unload();
 
-    DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL"));
+    DSoundDLL = SDL_LoadObject("DSOUND.DLL");
     if (DSoundDLL == NULL) {
         SDL_SetError("DirectSound: failed to load DSOUND.DLL");
     } else {
         /* Now make sure we have DirectX 5 or better... */
         /*  (DirectSoundCaptureCreate was added in DX5) */
-        if (!GetProcAddress(DSoundDLL, TEXT("DirectSoundCaptureCreate"))) {
+        if (!SDL_LoadFunction(DSoundDLL, "DirectSoundCaptureCreate")) {
             SDL_SetError("DirectSound: System doesn't appear to have DX5.");
         } else {
-            DSoundCreate = (void *) GetProcAddress(DSoundDLL,
-                                                   TEXT("DirectSoundCreate"));
+            DSoundCreate = SDL_LoadFunction(DSoundDLL, "DirectSoundCreate");
         }
 
         if (!DSoundCreate) {