ReactOS 0.4.15-dev-7131-ge4d03f4
sound.c File Reference
#include "precomp.h"
#include <mmsystem.h>
#include <mmreg.h>
#include <dsound.h>
Include dependency graph for sound.c:

Go to the source code of this file.

Functions

static void SetDeviceDetails (HWND hwndDlg, LPCGUID classGUID, LPCWSTR lpcstrDescription)
 
BOOL CALLBACK DSEnumCallback (LPGUID lpGuid, LPCWSTR lpcstrDescription, LPCWSTR lpcstrModule, LPVOID lpContext)
 
void InitializeDirectSoundPage (PDXDIAG_CONTEXT pContext)
 
INT_PTR CALLBACK SoundPageWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 

Function Documentation

◆ DSEnumCallback()

BOOL CALLBACK DSEnumCallback ( LPGUID  lpGuid,
LPCWSTR  lpcstrDescription,
LPCWSTR  lpcstrModule,
LPVOID  lpContext 
)

Definition at line 191 of file sound.c.

192{
193 PDXDIAG_CONTEXT pContext = (PDXDIAG_CONTEXT)lpContext;
194 HWND * hDlgs;
195 HWND hwndDlg;
196 WCHAR szSound[20];
197 WCHAR szText[30];
198 IDirectSound8 *pObj;
199 HRESULT hResult;
200 DWORD dwCertified;
201
202 if (!lpGuid)
203 return TRUE;
204
205 if (pContext->NumSoundAdapter)
206 hDlgs = HeapReAlloc(GetProcessHeap(), 0, pContext->hSoundWnd, (pContext->NumSoundAdapter + 1) * sizeof(HWND));
207 else
208 hDlgs = HeapAlloc(GetProcessHeap(), 0, (pContext->NumSoundAdapter + 1) * sizeof(HWND));
209
210 if (!hDlgs)
211 return FALSE;
212
213 pContext->hSoundWnd = hDlgs;
215 if (!hwndDlg)
216 return FALSE;
217
218 hResult = DirectSoundCreate8(lpGuid, (LPDIRECTSOUND8*)&pObj, NULL);
219 if (hResult == DS_OK)
220 {
221 szText[0] = L'\0';
222 if (IDirectSound8_VerifyCertification(pObj, &dwCertified) == DS_OK)
223 {
224 if (dwCertified == DS_CERTIFIED)
225 LoadStringW(hInst, IDS_OPTION_YES, szText, sizeof(szText)/sizeof(WCHAR));
226 else if (dwCertified == DS_UNCERTIFIED)
227 LoadStringW(hInst, IDS_NOT_APPLICABLE, szText, sizeof(szText)/sizeof(WCHAR));
228 }
229 else
230 {
231 LoadStringW(hInst, IDS_OPTION_NO, szText, sizeof(szText)/sizeof(WCHAR));
232 }
233 szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0';
236 }
237
238 /* set device name */
239 SendDlgItemMessageW(hwndDlg, IDC_STATIC_DSOUND_NAME, WM_SETTEXT, 0, (LPARAM)lpcstrDescription);
240
241 /* set range for slider */
243
244 /* FIXME set correct position */
246
247 /* set further device details */
248 SetDeviceDetails(hwndDlg, &GUID_DEVCLASS_MEDIA, lpcstrDescription);
249
250 /* load sound resource string */
251 szSound[0] = L'\0';
252 LoadStringW(hInst, IDS_SOUND_DIALOG, szSound, sizeof(szSound)/sizeof(WCHAR));
253 szSound[(sizeof(szSound)/sizeof(WCHAR))-1] = L'\0';
254 /* output the device id */
255 wsprintfW (szText, L"%s %u", szSound, pContext->NumSoundAdapter + 1);
256 /* insert it into general tab */
257 InsertTabCtrlItem(pContext->hTabCtrl, pContext->NumDisplayAdapter + pContext->NumSoundAdapter + 1, szText);
258 /* store dialog window */
259 hDlgs[pContext->NumSoundAdapter] = hwndDlg;
260 pContext->NumSoundAdapter++;
261 return TRUE;
262}
struct DXDIAG_CONTEXT * PDXDIAG_CONTEXT
#define IDD_SOUND_DIALOG
Definition: resource.h:9
#define IDS_SOUND_DIALOG
Definition: resource.h:106
#define IDS_OPTION_YES
Definition: resource.h:126
#define IDC_STATIC_DSOUND_NAME
Definition: resource.h:65
#define IDC_STATIC_DSOUND_LOGO
Definition: resource.h:74
#define IDS_OPTION_NO
Definition: resource.h:152
#define IDC_SLIDER_DSOUND
Definition: resource.h:77
#define IDS_NOT_APPLICABLE
Definition: resource.h:125
INT_PTR CALLBACK SoundPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: sound.c:283
static void SetDeviceDetails(HWND hwndDlg, LPCGUID classGUID, LPCWSTR lpcstrDescription)
Definition: sound.c:103
HRESULT WINAPI DirectSoundCreate8(LPCGUID lpcGUID, LPDIRECTSOUND8 *ppDS, IUnknown *pUnkOuter)
Definition: directsound.c:504
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define DS_OK
Definition: dsound.h:116
#define DS_UNCERTIFIED
Definition: dsound.h:327
struct IDirectSound8 * LPDIRECTSOUND8
Definition: dsound.h:73
#define IDirectSound8_Release(p)
Definition: dsound.h:507
#define DS_CERTIFIED
Definition: dsound.h:326
#define IDirectSound8_VerifyCertification(p, a)
Definition: dsound.h:518
HINSTANCE hInst
Definition: dxdiag.c:13
BOOL EnableDialogTheme(HWND hwnd)
Definition: dxdiag.c:38
VOID InsertTabCtrlItem(HWND hDlgCtrl, INT Position, LPWSTR uId)
Definition: dxdiag.c:102
unsigned long DWORD
Definition: ntddk_ex.h:95
#define L(x)
Definition: ntvdm.h:50
#define TBM_SETSEL
Definition: commctrl.h:2041
#define TBM_SETRANGE
Definition: commctrl.h:2037
HWND hMainDialog
Definition: precomp.h:31
HWND * hSoundWnd
Definition: precomp.h:36
ULONG NumSoundAdapter
Definition: precomp.h:35
ULONG NumDisplayAdapter
Definition: precomp.h:33
HWND hTabCtrl
Definition: precomp.h:32
#define MAKELONG(a, b)
Definition: typedefs.h:249
LONG_PTR LPARAM
Definition: windef.h:208
HWND WINAPI CreateDialogParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SETTEXT
Definition: winuser.h:1616
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by InitializeDirectSoundPage().

◆ InitializeDirectSoundPage()

void InitializeDirectSoundPage ( PDXDIAG_CONTEXT  pContext)

Definition at line 265 of file sound.c.

266{
267 HRESULT hResult;
268
269
270 /* create DSound object */
271
272// if (hResult != DS_OK)
273// return;
274 hResult = DirectSoundEnumerateW(DSEnumCallback, pContext);
275
276 /* release the DSound object */
277// pObj->lpVtbl->Release(pObj);
278 (void)hResult;
279}
BOOL CALLBACK DSEnumCallback(LPGUID lpGuid, LPCWSTR lpcstrDescription, LPCWSTR lpcstrModule, LPVOID lpContext)
Definition: sound.c:191
HRESULT WINAPI DirectSoundEnumerateW(LPDSENUMCALLBACKW lpDSEnumCallback, LPVOID lpContext)
Definition: enum.c:210

Referenced by InitializeTabCtrl().

◆ SetDeviceDetails()

static void SetDeviceDetails ( HWND  hwndDlg,
LPCGUID  classGUID,
LPCWSTR  lpcstrDescription 
)
static

Definition at line 103 of file sound.c.

104{
105 HDEVINFO hInfo;
106 DWORD dwIndex = 0;
107 SP_DEVINFO_DATA InfoData;
108 WCHAR szText[30];
109 HWND hDlgCtrls[3];
110 WAVEOUTCAPSW waveOut;
111 UINT numDev;
112 MMRESULT errCode;
113
114
115 /* enumerate waveout devices */
116 numDev = waveOutGetNumDevs();
117 if (numDev)
118 {
119 do
120 {
121 ZeroMemory(&waveOut, sizeof(waveOut));
122 errCode = waveOutGetDevCapsW(dwIndex++, &waveOut, sizeof(waveOut));
123 if (!wcsncmp(lpcstrDescription, waveOut.szPname, min(MAXPNAMELEN, wcslen(waveOut.szPname))))
124 {
125 /* set the product id */
127 /* set the vendor id */
129 /* check if it's a WDM audio driver */
130 if (waveOut.wPid == MM_MSFT_WDMAUDIO_WAVEOUT)
132
133 /* check if device is default device */
134 szText[0] = L'\0';
135 if (dwIndex - 1 == 0) /* FIXME assume default playback device is device 0 */
136 LoadStringW(hInst, IDS_OPTION_YES, szText, sizeof(szText)/sizeof(WCHAR));
137 else
138 LoadStringW(hInst, IDS_OPTION_NO, szText, sizeof(szText)/sizeof(WCHAR));
139
140 szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0';
141 /* set default device info */
143 break;
144 }
145 }while(errCode == MMSYSERR_NOERROR && dwIndex < numDev);
146 }
147
148 dwIndex = 0;
149 /* create the setup list */
151 if (hInfo == INVALID_HANDLE_VALUE)
152 return;
153
154 do
155 {
156 ZeroMemory(&InfoData, sizeof(InfoData));
157 InfoData.cbSize = sizeof(InfoData);
158
159 if (SetupDiEnumDeviceInfo(hInfo, dwIndex, &InfoData))
160 {
161 /* set device name */
162 if (SetupDiGetDeviceInstanceId(hInfo, &InfoData, szText, sizeof(szText)/sizeof(WCHAR), NULL))
164
165 /* set the manufacturer name */
166 if (SetupDiGetDeviceRegistryPropertyW(hInfo, &InfoData, SPDRP_MFG, NULL, (PBYTE)szText, sizeof(szText), NULL))
168
169 /* FIXME
170 * we currently enumerate only the first adapter
171 */
172 hDlgCtrls[0] = GetDlgItem(hwndDlg, IDC_STATIC_DSOUND_DRIVER);
173 hDlgCtrls[1] = GetDlgItem(hwndDlg, IDC_STATIC_DSOUND_VERSION);
174 hDlgCtrls[2] = GetDlgItem(hwndDlg, IDC_STATIC_DSOUND_DATE);
175 EnumerateDrivers(hDlgCtrls, hInfo, &InfoData);
176 break;
177 }
178
180 break;
181
182 dwIndex++;
183 }while(TRUE);
184
185 /* destroy the setup list */
187}
VOID EnumerateDrivers(PVOID Context, HDEVINFO hList, PSP_DEVINFO_DATA pInfoData)
Definition: display.c:99
#define IDC_STATIC_DSOUND_VENDORID
Definition: resource.h:67
#define IDC_STATIC_DSOUND_STANDARD
Definition: resource.h:70
#define IDC_STATIC_DSOUND_PRODUCTID
Definition: resource.h:68
#define IDC_STATIC_DSOUND_TYPE
Definition: resource.h:69
#define IDC_STATIC_DSOUND_DATE
Definition: resource.h:73
#define IDC_STATIC_DSOUND_DEVICEID
Definition: resource.h:66
#define IDC_STATIC_DSOUND_DRIVER
Definition: resource.h:71
#define IDC_STATIC_DSOUND_VERSION
Definition: resource.h:72
#define IDC_STATIC_ADAPTER_PROVIDER
Definition: resource.h:76
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
BOOL WINAPI SetupDiEnumDeviceInfo(HDEVINFO devinfo, DWORD index, PSP_DEVINFO_DATA info)
Definition: devinst.c:1787
BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize)
Definition: devinst.c:3224
HDEVINFO WINAPI SetupDiGetClassDevsW(CONST GUID *class, LPCWSTR enumstr, HWND parent, DWORD flags)
Definition: devinst.c:2292
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2893
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define MM_MSFT_WDMAUDIO_WAVEOUT
Definition: mmreg.h:35
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MAXPNAMELEN
Definition: mmsystem.h:24
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
BYTE * PBYTE
Definition: pedump.c:66
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define SetupDiGetDeviceInstanceId
Definition: setupapi.h:2600
#define DIGCF_PROFILE
Definition: setupapi.h:173
#define DIGCF_PRESENT
Definition: setupapi.h:171
#define SPDRP_MFG
Definition: setupapi.h:518
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1039
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
UINT WINAPI waveOutGetNumDevs(void)
Definition: winmm.c:2137
UINT WINAPI waveOutGetDevCapsW(UINT_PTR uDeviceID, LPWAVEOUTCAPSW lpCaps, UINT uSize)
Definition: winmm.c:2173
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)

Referenced by DSEnumCallback().

◆ SoundPageWndProc()

INT_PTR CALLBACK SoundPageWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 283 of file sound.c.

284{
285 switch (message)
286 {
287 case WM_INITDIALOG:
288 {
290 return TRUE;
291 }
292 case WM_COMMAND:
293 {
295 {
296 return FALSE;
297 }
298 break;
299 }
300 }
301
302 return FALSE;
303}
#define IDC_BUTTON_TESTDSOUND
Definition: resource.h:78
WPARAM wParam
Definition: combotst.c:138
#define LOWORD(l)
Definition: pedump.c:82
Definition: tftpd.h:60
#define SWP_NOACTIVATE
Definition: winuser.h:1241
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WM_COMMAND
Definition: winuser.h:1739
#define SWP_NOSIZE
Definition: winuser.h:1244
#define WM_INITDIALOG
Definition: winuser.h:1738
#define SWP_NOOWNERZORDER
Definition: winuser.h:1248
#define SWP_NOZORDER
Definition: winuser.h:1246

Referenced by DSEnumCallback().