comparison 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
comparison
equal deleted inserted replaced
5091:79bd1e289005 5092:327f181542f1
22 #include "SDL_config.h" 22 #include "SDL_config.h"
23 23
24 /* Allow access to a raw mixing buffer */ 24 /* Allow access to a raw mixing buffer */
25 25
26 #include "SDL_timer.h" 26 #include "SDL_timer.h"
27 #include "SDL_loadso.h"
27 #include "SDL_audio.h" 28 #include "SDL_audio.h"
28 #include "../SDL_audio_c.h" 29 #include "../SDL_audio_c.h"
29 #include "SDL_dx5audio.h" 30 #include "SDL_dx5audio.h"
30 31
31 /* !!! FIXME: move this somewhere that other drivers can use it... */ 32 /* !!! FIXME: move this somewhere that other drivers can use it... */
36 #else 37 #else
37 #define WINDOWS_OS_NAME "Win32" 38 #define WINDOWS_OS_NAME "Win32"
38 #endif 39 #endif
39 40
40 /* DirectX function pointers for audio */ 41 /* DirectX function pointers for audio */
41 static HINSTANCE DSoundDLL = NULL; 42 static void* DSoundDLL = NULL;
42 static HRESULT(WINAPI * DSoundCreate) (LPGUID, LPDIRECTSOUND *, LPUNKNOWN) = 43 static HRESULT(WINAPI * DSoundCreate) (LPGUID, LPDIRECTSOUND *, LPUNKNOWN) =
43 NULL; 44 NULL;
44 45
45 static void 46 static void
46 DSOUND_Unload(void) 47 DSOUND_Unload(void)
47 { 48 {
49 DSoundCreate = NULL;
50
48 if (DSoundDLL != NULL) { 51 if (DSoundDLL != NULL) {
49 FreeLibrary(DSoundDLL); 52 SDL_UnloadObject(DSoundDLL);
50 } 53 DSoundDLL = NULL;
51 54 }
52 DSoundCreate = NULL;
53 DSoundDLL = NULL;
54 } 55 }
55 56
56 57
57 static int 58 static int
58 DSOUND_Load(void) 59 DSOUND_Load(void)
59 { 60 {
60 int loaded = 0; 61 int loaded = 0;
61 62
62 DSOUND_Unload(); 63 DSOUND_Unload();
63 64
64 DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL")); 65 DSoundDLL = SDL_LoadObject("DSOUND.DLL");
65 if (DSoundDLL == NULL) { 66 if (DSoundDLL == NULL) {
66 SDL_SetError("DirectSound: failed to load DSOUND.DLL"); 67 SDL_SetError("DirectSound: failed to load DSOUND.DLL");
67 } else { 68 } else {
68 /* Now make sure we have DirectX 5 or better... */ 69 /* Now make sure we have DirectX 5 or better... */
69 /* (DirectSoundCaptureCreate was added in DX5) */ 70 /* (DirectSoundCaptureCreate was added in DX5) */
70 if (!GetProcAddress(DSoundDLL, TEXT("DirectSoundCaptureCreate"))) { 71 if (!SDL_LoadFunction(DSoundDLL, "DirectSoundCaptureCreate")) {
71 SDL_SetError("DirectSound: System doesn't appear to have DX5."); 72 SDL_SetError("DirectSound: System doesn't appear to have DX5.");
72 } else { 73 } else {
73 DSoundCreate = (void *) GetProcAddress(DSoundDLL, 74 DSoundCreate = SDL_LoadFunction(DSoundDLL, "DirectSoundCreate");
74 TEXT("DirectSoundCreate"));
75 } 75 }
76 76
77 if (!DSoundCreate) { 77 if (!DSoundCreate) {
78 SDL_SetError("DirectSound: Failed to find DirectSoundCreate"); 78 SDL_SetError("DirectSound: Failed to find DirectSoundCreate");
79 } else { 79 } else {