ReactOS  0.4.14-dev-552-g2fad488
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 }
smooth NULL
Definition: ftsmooth.c:416
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 }
smooth NULL
Definition: ftsmooth.c:416
HRESULT DSoundEnumerate(LPDSENUMCALLBACKA lpDSEnumCallbackA, LPDSENUMCALLBACKW lpDSEnumCallbackW, LPVOID lpContext, BOOL bPlayback)
Definition: enum.c:106

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
smooth NULL
Definition: ftsmooth.c:416
HRESULT DSoundEnumerate(LPDSENUMCALLBACKA lpDSEnumCallbackA, LPDSENUMCALLBACKW lpDSEnumCallbackW, LPVOID lpContext, BOOL bPlayback)
Definition: enum.c:106

◆ 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 }
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
HRESULT DSoundEnumerate(LPDSENUMCALLBACKA lpDSEnumCallbackA, LPDSENUMCALLBACKW lpDSEnumCallbackW, LPVOID lpContext, BOOL bPlayback)
Definition: enum.c:106

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 }
#define TRUE
Definition: types.h:120
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
char * LPSTR
Definition: xmlstorage.h:182
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
VOID LoadResourceString(UINT ResourceId, LPVOID Buffer, UINT ccount, LPVOID DefaultString, BOOL bUnicode)
Definition: enum.c:13
__wchar_t WCHAR
Definition: xmlstorage.h:180
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
WCHAR * LPWSTR
Definition: xmlstorage.h:184
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by DSoundEnumerate().

◆ DSoundEnumerate()

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

Definition at line 106 of file enum.c.

111 {
112  ULONG ResourceId;
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 */
132  ResourceId = IDS_PRIMARY_PLAYBACK_DEVICE;
133  }
134  else
135  {
136  /* use resource id of playback string */
137  ResourceId = IDS_PRIMARY_RECORD_DEVICE;
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
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1060
struct tagFILTERINFO * lpNext
Definition: precomp.h:49
UINT WINAPI waveInGetDevCapsW(UINT_PTR uDeviceID, LPWAVEINCAPSW lpCaps, UINT uSize)
Definition: winmm.c:2576
UINT WINAPI waveOutGetDevCapsW(UINT_PTR uDeviceID, LPWAVEOUTCAPSW lpCaps, UINT uSize)
Definition: winmm.c:2176
#define DSERR_INVALIDPARAM
Definition: dsound.h:121
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDS_PRIMARY_RECORD_DEVICE
Definition: resource.h:5
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define IDS_PRIMARY_PLAYBACK_DEVICE
Definition: resource.h:4
#define DS_OK
Definition: dsound.h:116
GUID DeviceGuid[2]
Definition: precomp.h:46
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1039
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
#define GUID_NULL
Definition: ks.h:106
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
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define MAXPNAMELEN
Definition: mmsystem.h:24
ULONG MappedId[2]
Definition: precomp.h:47
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ULONG_MAX
Definition: limits.h:44

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 */
23  if (!LoadStringW(dsound_hInstance, ResourceId, (LPWSTR)Buffer, ccount))
24  {
25  /* default device name */
26  wcscpy((LPWSTR)Buffer, (LPWSTR)DefaultString);
27  }
28  }
29  else
30  {
31  /* load localized string */
32  if (!LoadStringA(dsound_hInstance, ResourceId, (LPSTR)Buffer, ccount))
33  {
34  /* default device name */
35  strcpy((LPSTR)Buffer, (LPSTR)DefaultString);
36  }
37  }
38 }
int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPSTR lpBuffer, _In_ int cchBufferMax)
char * LPSTR
Definition: xmlstorage.h:182
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
Definition: bufpool.h:45
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
HINSTANCE dsound_hInstance
Definition: dsound.c:12
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by AddItem(), AddService(), DoDSoundCallback(), Initialize(), PropSheetCallback(), ServicesPageWndProc(), and ToolsPageWndProc().