Skip to content

Commit

Permalink
Add DirectSoundCaptureEnumerate() and DirectSoundEnumerate().
Browse files Browse the repository at this point in the history
Yeah, it's probably not worth it to define a shared callback wrapper structure.
  • Loading branch information
nmlgc committed Aug 22, 2015
1 parent a9204f1 commit 3f1de63
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 2 deletions.
60 changes: 60 additions & 0 deletions src/dsound_dll.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Win32 UTF-8 wrapper
*
* ----
*
* dsound.dll functions.
*/

const w32u8_pair_t dsound_pairs[] = {
{"DirectSoundCaptureEnumerateA", DirectSoundCaptureEnumerateU},
{"DirectSoundEnumerateA", DirectSoundEnumerateU},
NULL
};

typedef struct {
LPDSENUMCALLBACKA lpOrigProc;
LPVOID lOrigParam;
} DSEnumParam;

BOOL CALLBACK DSEnumCallbackWrap(
LPGUID lpGuid,
LPCWSTR lpcstrDescription,
LPCWSTR lpcstrModule,
DSEnumParam *wrap_param
)
{
BOOL ret;
UTF8_DEC(lpcstrDescription);
UTF8_DEC(lpcstrModule);
UTF8_CONV(lpcstrDescription);
UTF8_CONV(lpcstrModule);
ret = wrap_param->lpOrigProc(
lpGuid, lpcstrDescription_utf8, lpcstrModule_utf8, wrap_param->lOrigParam
);
UTF8_FREE(lpcstrDescription);
UTF8_FREE(lpcstrModule);
return ret;
}

HRESULT WINAPI DirectSoundCaptureEnumerateU(
LPDSENUMCALLBACKA pDSEnumCallback,
LPVOID pContext
)
{
DSEnumParam wrap_param = {pDSEnumCallback, pContext};
return DirectSoundCaptureEnumerateW(
(LPDSENUMCALLBACKW)DSEnumCallbackWrap, &wrap_param
);
}

HRESULT WINAPI DirectSoundEnumerateU(
LPDSENUMCALLBACKA pDSEnumCallback,
LPVOID pContext
)
{
DSEnumParam wrap_param = {pDSEnumCallback, pContext};
return DirectSoundEnumerateW(
(LPDSENUMCALLBACKW)DSEnumCallbackWrap, &wrap_param
);
}
23 changes: 23 additions & 0 deletions src/dsound_dll.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Win32 UTF-8 wrapper
*
* ----
*
* dsound.dll functions.
*/

#pragma once

HRESULT WINAPI DirectSoundCaptureEnumerateU(
LPDSENUMCALLBACKA pDSEnumCallback,
LPVOID pContext
);
#undef DirectSoundCaptureEnumerate
#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateU

HRESULT WINAPI DirectSoundEnumerateU(
LPDSENUMCALLBACKA pDSEnumCallback,
LPVOID pContext
);
#undef DirectSoundEnumerate
#define DirectSoundEnumerate DirectSoundEnumerateU
2 changes: 2 additions & 0 deletions src/win32_utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const w32u8_dll_t* w32u8_get_wrapped_functions()
{
// Yes, this is the prettiest way I came up with.
extern const w32u8_pair_t comdlg32_pairs[];
extern const w32u8_pair_t dsound_pairs[];
extern const w32u8_pair_t gdi32_pairs[];
extern const w32u8_pair_t kernel32_pairs[];
extern const w32u8_pair_t msvcrt_pairs[];
Expand All @@ -22,6 +23,7 @@ const w32u8_dll_t* w32u8_get_wrapped_functions()

static const w32u8_dll_t dlls[] = {
{"comdlg32.dll", comdlg32_pairs},
{"dsound.dll", dsound_pairs},
{"gdi32.dll", gdi32_pairs},
{"kernel32.dll", kernel32_pairs},
{"msvcrt.dll", msvcrt_pairs},
Expand Down
4 changes: 2 additions & 2 deletions src/win32_utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

#pragma once

#define WIN32_LEAN_AND_MEAN

#include <Windows.h>
#include <CommDlg.h>
#include <dsound.h>
#include <psapi.h>
#include <ShellAPI.h>
#include <Shlwapi.h>
Expand All @@ -23,6 +22,7 @@
#include "utf.h"

#include "comdlg32_dll.h"
#include "dsound_dll.h"
#include "gdi32_dll.h"
#include "kernel32_dll.h"
#include "msvcrt_dll.h"
Expand Down
5 changes: 5 additions & 0 deletions win32_utf8.def
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ EXPORTS
GetOpenFileNameU
GetSaveFileNameU

; dsound.dll
; ----------
DirectSoundCaptureEnumerateU
DirectSoundEnumerateU

; gdi32.dll
; ---------
lower_CreateFontA
Expand Down
2 changes: 2 additions & 0 deletions win32_utf8.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<PropertyGroup Label="UserMacros" />
<ItemGroup>
<ClInclude Include="src\comdlg32_dll.h" />
<ClInclude Include="src\dsound_dll.h" />
<ClInclude Include="src\gdi32_dll.h" />
<ClInclude Include="src\kernel32_dll.h" />
<ClInclude Include="src\macros.h" />
Expand All @@ -103,6 +104,7 @@
<ClInclude Include="src\wrappers.h" />
<ClCompile Include="win32_utf8_build.c" />
<None Include="src\comdlg32_dll.c" />
<None Include="src\dsound_dll.c" />
<None Include="src\gdi32_dll.c" />
<None Include="src\kernel32_dll.c" />
<None Include="src\macros.c" />
Expand Down
3 changes: 3 additions & 0 deletions win32_utf8.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
<ClInclude Include="src\comdlg32_dll.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="src\dsound_dll.h">
<Filter>Wrappers</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\utf.c">
Expand Down
2 changes: 2 additions & 0 deletions win32_utf8_build.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define COBJMACROS

#pragma comment(lib, "comdlg32.lib")
#pragma comment(lib, "dsound.lib")
#pragma comment(lib, "psapi.lib")
#pragma comment(lib, "shlwapi.lib")
#pragma comment(lib, "version.lib")
Expand All @@ -30,6 +31,7 @@

// Wrappers
#include "src/comdlg32_dll.c"
#include "src/dsound_dll.c"
#include "src/gdi32_dll.c"
#include "src/kernel32_dll.c"
#include "src/msvcrt_dll.c"
Expand Down

0 comments on commit 3f1de63

Please sign in to comment.