ReactOS 0.4.16-dev-297-gc569aee
enum.c File Reference
#include "precomp.h"
Include dependency graph for enum.c:

Go to the source code of this file.

Functions

VOID LoadResourceString (UINT ResourceId, LPVOID Buffer, UINT ccount, LPVOID DefaultString, BOOL bUnicode)
 
BOOL DoDSoundCallback (LPDSENUMCALLBACKA lpDSEnumCallbackA, LPDSENUMCALLBACKW lpDSEnumCallbackW, LPGUID DeviceGuid, UINT ResourceId, LPWSTR ProductName, LPWSTR DriverName, LPVOID lpContext)
 
HRESULT DSoundEnumerate (LPDSENUMCALLBACKA lpDSEnumCallbackA, LPDSENUMCALLBACKW lpDSEnumCallbackW, LPVOID lpContext, BOOL bPlayback)
 
HRESULT WINAPI DirectSoundEnumerateA (LPDSENUMCALLBACKA lpDSEnumCallback, LPVOID lpContext)
 
HRESULT WINAPI DirectSoundEnumerateW (LPDSENUMCALLBACKW lpDSEnumCallback, LPVOID lpContext)
 
HRESULT WINAPI DirectSoundCaptureEnumerateA (LPDSENUMCALLBACKA lpDSEnumCallback, LPVOID lpContext)
 
HRESULT WINAPI DirectSoundCaptureEnumerateW (LPDSENUMCALLBACKW lpDSEnumCallback, LPVOID lpContext)
 

Function Documentation

◆ DirectSoundCaptureEnumerateA()

HRESULT WINAPI DirectSoundCaptureEnumerateA ( LPDSENUMCALLBACKA  lpDSEnumCallback,
LPVOID  lpContext 
)

Definition at line 219 of file enum.c.

222{
223 return DSoundEnumerate(lpDSEnumCallback, NULL, lpContext, FALSE);
224}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
HRESULT DSoundEnumerate(LPDSENUMCALLBACKA lpDSEnumCallbackA, LPDSENUMCALLBACKW lpDSEnumCallbackW, LPVOID lpContext, BOOL bPlayback)
Definition: enum.c:106

◆ DirectSoundCaptureEnumerateW()

HRESULT WINAPI DirectSoundCaptureEnumerateW ( LPDSENUMCALLBACKW  lpDSEnumCallback,
LPVOID  lpContext 
)

Definition at line 228 of file enum.c.

231{
232 return DSoundEnumerate(NULL, lpDSEnumCallback, lpContext, FALSE);
233}

Referenced by build_directsound_tree().

◆ DirectSoundEnumerateA()

HRESULT WINAPI DirectSoundEnumerateA ( LPDSENUMCALLBACKA  lpDSEnumCallback,
LPVOID  lpContext 
)

Definition at line 201 of file enum.c.

204{
205 return DSoundEnumerate(lpDSEnumCallback, NULL, lpContext, TRUE);
206}
#define TRUE
Definition: types.h:120

◆ DirectSoundEnumerateW()

HRESULT WINAPI DirectSoundEnumerateW ( LPDSENUMCALLBACKW  lpDSEnumCallback,
LPVOID  lpContext 
)

Definition at line 210 of file enum.c.

213{
214 return DSoundEnumerate(NULL, lpDSEnumCallback, lpContext, TRUE);
215}

Referenced by build_directsound_tree(), DEVENUM_ICreateDevEnum_CreateClassEnumerator(), InitializeDirectSoundPage(), and START_TEST().

◆ DoDSoundCallback()

BOOL DoDSoundCallback ( LPDSENUMCALLBACKA  lpDSEnumCallbackA,
LPDSENUMCALLBACKW  lpDSEnumCallbackW,
LPGUID  DeviceGuid,
UINT  ResourceId,
LPWSTR  ProductName,
LPWSTR  DriverName,
LPVOID  lpContext 
)

Definition at line 42 of file enum.c.

50{
51 WCHAR Buffer[200] = {0};
52 char DriverNameA[200];
53
54 static LPWSTR SoundDriverW = L"Primary Sound Driver";
55 static LPWSTR SoundDriverA = L"Primary Sound Driver";
56
57 if (lpDSEnumCallbackW)
58 {
59 if (ResourceId)
60 {
61 /* load resource string */
62 Buffer[0] = 0;
63 LoadResourceString(ResourceId, (LPVOID)Buffer, sizeof(Buffer)/sizeof(WCHAR), (LPVOID)SoundDriverW, TRUE);
64 Buffer[(sizeof(Buffer)/sizeof(WCHAR))-1] = '\0';
65 }
66 else
67 {
68 /* use passed string */
69 ASSERT(ProductName);
70 wcscpy(Buffer, ProductName);
71 }
72
73 /* perform callback */
74 return lpDSEnumCallbackW(DeviceGuid, Buffer, DriverName, lpContext);
75 }
76 else
77 {
78 if (ResourceId)
79 {
80 /* load resource string */
81 Buffer[0] = 0;
82 LoadResourceString(ResourceId, (LPVOID)Buffer, sizeof(Buffer)/sizeof(char), (LPVOID)SoundDriverA, FALSE);
83 Buffer[(sizeof(Buffer)/sizeof(WCHAR))-1] = 0;
84 }
85 else
86 {
87 /* use passed string */
88 Buffer[0] = 0;
89 WideCharToMultiByte(CP_ACP, 0, ProductName, -1, (LPSTR)Buffer, sizeof(Buffer) / sizeof(char), NULL, NULL);
90 Buffer[(sizeof(Buffer)/sizeof(WCHAR))-1] = 0;
91 }
92
93 DriverNameA[0] = 0;
94 if (ProductName)
95 {
96 WideCharToMultiByte(CP_ACP, 0, ProductName, -1, DriverNameA, sizeof(DriverNameA) / sizeof(char), NULL, NULL);
97 DriverNameA[(sizeof(DriverNameA) / sizeof(char))-1] = 0;
98 }
99
100 return lpDSEnumCallbackA(DeviceGuid, (LPSTR)Buffer, DriverNameA, lpContext);
101 }
102}
INT ResourceId
Definition: LoadImageGCC.c:72
#define LoadResourceString(hInst, uID)
Definition: utils.h:48
Definition: bufpool.h:45
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
#define ASSERT(a)
Definition: mode.c:44
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DSoundEnumerate().

◆ DSoundEnumerate()

HRESULT DSoundEnumerate ( LPDSENUMCALLBACKA  lpDSEnumCallbackA,
LPDSENUMCALLBACKW  lpDSEnumCallbackW,
LPVOID  lpContext,
BOOL  bPlayback 
)

Definition at line 106 of file enum.c.

111{
113 BOOL bResult;
114 LPFILTERINFO CurInfo;
115 WAVEOUTCAPSW WaveOutCaps;
116 WAVEINCAPSW WaveInCaps;
117
118 if (!RootInfo)
119 {
121 }
122
123 if (lpDSEnumCallbackA == NULL && lpDSEnumCallbackW == NULL)
124 {
125 DPRINT("No callback\n");
126 return DSERR_INVALIDPARAM;
127 }
128
129 if (bPlayback)
130 {
131 /* use resource id of playback string */
133 }
134 else
135 {
136 /* use resource id of playback string */
138 }
139
140 if (RootInfo)
141 {
142 /* perform first callback */
143 bResult = DoDSoundCallback(lpDSEnumCallbackA, lpDSEnumCallbackW, NULL, ResourceId, NULL, L"", lpContext);
144 if (!bResult)
145 {
146 /* callback asked as to stop */
147 return DS_OK;
148 }
149
150 /* now iterate through all devices */
151 CurInfo = RootInfo;
152
153 do
154 {
155 if (bPlayback && !IsEqualGUID(&CurInfo->DeviceGuid[1], &GUID_NULL))
156 {
157 RtlZeroMemory(&WaveOutCaps, sizeof(WAVEOUTCAPSW));
158
159 /* sanity check */
160 ASSERT(CurInfo->MappedId[1] != ULONG_MAX);
161
162 /* get wave out caps */
163 waveOutGetDevCapsW((UINT_PTR)CurInfo->MappedId[1], &WaveOutCaps, sizeof(WAVEOUTCAPSW));
164 WaveOutCaps.szPname[MAXPNAMELEN-1] = L'\0';
165
166 bResult = DoDSoundCallback(lpDSEnumCallbackA, lpDSEnumCallbackW, &CurInfo->DeviceGuid[1], 0, WaveOutCaps.szPname, L"" /* FIXME */, lpContext);
167 if (!bResult)
168 {
169 /* callback asked as to stop */
170 return DS_OK;
171 }
172 }
173 else if (!bPlayback && !IsEqualGUID(&CurInfo->DeviceGuid[0], &GUID_NULL))
174 {
175 RtlZeroMemory(&WaveInCaps, sizeof(WAVEINCAPSW));
176
177 /* sanity check */
178 ASSERT(CurInfo->MappedId[1] != ULONG_MAX);
179
180 /* get wave in caps */
181 waveInGetDevCapsW((UINT_PTR)CurInfo->MappedId[0], &WaveInCaps, sizeof(WAVEINCAPSW));
182 WaveInCaps.szPname[MAXPNAMELEN-1] = L'\0';
183
184 bResult = DoDSoundCallback(lpDSEnumCallbackA, lpDSEnumCallbackW, &CurInfo->DeviceGuid[0], 0, WaveInCaps.szPname, L"" /* FIXME */, lpContext);
185 if (!bResult)
186 {
187 /* callback asked as to stop */
188 return DS_OK;
189 }
190 }
191
192 /* move to next entry */
193 CurInfo = CurInfo->lpNext;
194 }while(CurInfo);
195 }
196 return DS_OK;
197}
HRESULT EnumAudioDeviceInterfaces(LPFILTERINFO *OutRootInfo)
Definition: devicelist.c:384
LPFILTERINFO RootInfo
Definition: dsound.c:13
BOOL DoDSoundCallback(LPDSENUMCALLBACKA lpDSEnumCallbackA, LPDSENUMCALLBACKW lpDSEnumCallbackW, LPGUID DeviceGuid, UINT ResourceId, LPWSTR ProductName, LPWSTR DriverName, LPVOID lpContext)
Definition: enum.c:42
#define IDS_PRIMARY_RECORD_DEVICE
Definition: resource.h:5
#define IDS_PRIMARY_PLAYBACK_DEVICE
Definition: resource.h:4
#define DS_OK
Definition: dsound.h:116
#define DSERR_INVALIDPARAM
Definition: dsound.h:121
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ULONG_MAX
Definition: intsafe.h:155
#define GUID_NULL
Definition: ks.h:106
#define MAXPNAMELEN
Definition: mmsystem.h:24
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define DPRINT
Definition: sndvol32.h:73
struct tagFILTERINFO * lpNext
Definition: precomp.h:48
GUID DeviceGuid[2]
Definition: precomp.h:45
ULONG MappedId[2]
Definition: precomp.h:46
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1060
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1039
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
UINT WINAPI waveOutGetDevCapsW(UINT_PTR uDeviceID, LPWAVEOUTCAPSW lpCaps, UINT uSize)
Definition: winmm.c:2173
UINT WINAPI waveInGetDevCapsW(UINT_PTR uDeviceID, LPWAVEINCAPSW lpCaps, UINT uSize)
Definition: winmm.c:2573

Referenced by DirectSoundCaptureEnumerateA(), DirectSoundCaptureEnumerateW(), DirectSoundEnumerateA(), and DirectSoundEnumerateW().

◆ LoadResourceString()

VOID LoadResourceString ( UINT  ResourceId,
LPVOID  Buffer,
UINT  ccount,
LPVOID  DefaultString,
BOOL  bUnicode 
)

Definition at line 13 of file enum.c.

19{
20 if (bUnicode)
21 {
22 /* load localized string */
24 {
25 /* default device name */
26 wcscpy((LPWSTR)Buffer, (LPWSTR)DefaultString);
27 }
28 }
29 else
30 {
31 /* load localized string */
33 {
34 /* default device name */
35 strcpy((LPSTR)Buffer, (LPSTR)DefaultString);
36 }
37 }
38}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
HINSTANCE dsound_hInstance
Definition: dsound.c:12
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPSTR lpBuffer, _In_ int cchBufferMax)