xref: /reactos/dll/cpl/mmsys/audio.c (revision 3da25b73)
1c2c66affSColin Finck /*
2c2c66affSColin Finck  *
3c2c66affSColin Finck  * PROJECT:         ReactOS Multimedia Control Panel
4c2c66affSColin Finck  * FILE:            dll/cpl/mmsys/audio.c
5c2c66affSColin Finck  * PURPOSE:         ReactOS Multimedia Control Panel
6c2c66affSColin Finck  * PROGRAMMER:      Thomas Weidenmueller <w3seek@reactos.com>
7c2c66affSColin Finck  *                  Johannes Anderwald <janderwald@reactos.com>
8c2c66affSColin Finck  *                  Dmitry Chapyshev <dmitry@reactos.org>
9c2c66affSColin Finck  */
10c2c66affSColin Finck 
11c2c66affSColin Finck #include "mmsys.h"
12c2c66affSColin Finck 
13c95f3358SStanislav Motylkov typedef struct _GLOBAL_DATA
14c95f3358SStanislav Motylkov {
15c95f3358SStanislav Motylkov     BOOL bNoAudioOut;
16c95f3358SStanislav Motylkov     BOOL bNoAudioIn;
17c95f3358SStanislav Motylkov     BOOL bNoMIDIOut;
18c95f3358SStanislav Motylkov 
19c95f3358SStanislav Motylkov     BOOL bAudioOutChanged;
20c95f3358SStanislav Motylkov     BOOL bAudioInChanged;
21c95f3358SStanislav Motylkov     BOOL bMIDIOutChanged;
22c95f3358SStanislav Motylkov 
23c95f3358SStanislav Motylkov } GLOBAL_DATA, *PGLOBAL_DATA;
24c95f3358SStanislav Motylkov 
25c2c66affSColin Finck VOID
InitAudioDlg(HWND hwnd,PGLOBAL_DATA pGlobalData)26c95f3358SStanislav Motylkov InitAudioDlg(HWND hwnd, PGLOBAL_DATA pGlobalData)
27c2c66affSColin Finck {
28c2c66affSColin Finck     WAVEOUTCAPSW waveOutputPaps;
29781c247bSThamatip Chitpong     WAVEINCAPSW waveInputPaps;
30781c247bSThamatip Chitpong     MIDIOUTCAPSW midiOutCaps;
31781c247bSThamatip Chitpong     WCHAR szNoDevices[256];
32c2c66affSColin Finck     UINT DevsNum;
33c2c66affSColin Finck     UINT uIndex;
34c2c66affSColin Finck     HWND hCB;
35c2c66affSColin Finck     LRESULT Res;
36c2c66affSColin Finck 
37781c247bSThamatip Chitpong     LoadStringW(hApplet, IDS_NO_DEVICES, szNoDevices, _countof(szNoDevices));
38c2c66affSColin Finck 
39c2c66affSColin Finck     // Init sound playback devices list
40c2c66affSColin Finck     hCB = GetDlgItem(hwnd, IDC_DEVICE_PLAY_LIST);
41c2c66affSColin Finck 
42c2c66affSColin Finck     DevsNum = waveOutGetNumDevs();
43c2c66affSColin Finck     if (DevsNum < 1)
44c2c66affSColin Finck     {
45781c247bSThamatip Chitpong         Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM)szNoDevices);
46781c247bSThamatip Chitpong         SendMessageW(hCB, CB_SETCURSEL, (WPARAM)Res, 0);
47c95f3358SStanislav Motylkov         pGlobalData->bNoAudioOut = TRUE;
48c2c66affSColin Finck     }
49c2c66affSColin Finck     else
50c2c66affSColin Finck     {
51c2c66affSColin Finck         WCHAR DefaultDevice[MAX_PATH] = {0};
52c2c66affSColin Finck         HKEY hKey;
53c2c66affSColin Finck         DWORD dwSize = sizeof(DefaultDevice);
54c2c66affSColin Finck         UINT DefaultIndex = 0;
55c2c66affSColin Finck 
56c2c66affSColin Finck         if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Multimedia\\Sound Mapper", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
57c2c66affSColin Finck         {
58c2c66affSColin Finck             RegQueryValueExW(hKey, L"Playback", NULL, NULL, (LPBYTE)DefaultDevice, &dwSize);
59781c247bSThamatip Chitpong             DefaultDevice[_countof(DefaultDevice) - 1] = UNICODE_NULL;
60c2c66affSColin Finck             RegCloseKey(hKey);
61c2c66affSColin Finck         }
62c2c66affSColin Finck 
63c2c66affSColin Finck         for (uIndex = 0; uIndex < DevsNum; uIndex++)
64c2c66affSColin Finck         {
65c2c66affSColin Finck             if (waveOutGetDevCapsW(uIndex, &waveOutputPaps, sizeof(waveOutputPaps)))
66c2c66affSColin Finck                 continue;
67c2c66affSColin Finck 
68c2c66affSColin Finck             Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM)waveOutputPaps.szPname);
69c2c66affSColin Finck 
70c2c66affSColin Finck             if (CB_ERR != Res)
71c2c66affSColin Finck             {
72781c247bSThamatip Chitpong                 SendMessageW(hCB, CB_SETITEMDATA, Res, (LPARAM)uIndex);
73781c247bSThamatip Chitpong                 if (!_wcsicmp(waveOutputPaps.szPname, DefaultDevice))
74c2c66affSColin Finck                     DefaultIndex = Res;
75c2c66affSColin Finck             }
76c2c66affSColin Finck         }
77781c247bSThamatip Chitpong         SendMessageW(hCB, CB_SETCURSEL, (WPARAM)DefaultIndex, 0);
78c2c66affSColin Finck     }
79c2c66affSColin Finck 
80c2c66affSColin Finck     // Init sound recording devices list
81c2c66affSColin Finck     hCB = GetDlgItem(hwnd, IDC_DEVICE_REC_LIST);
82c2c66affSColin Finck 
83c2c66affSColin Finck     DevsNum = waveInGetNumDevs();
84c2c66affSColin Finck     if (DevsNum < 1)
85c2c66affSColin Finck     {
86781c247bSThamatip Chitpong         Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM)szNoDevices);
87781c247bSThamatip Chitpong         SendMessageW(hCB, CB_SETCURSEL, (WPARAM)Res, 0);
88c95f3358SStanislav Motylkov         pGlobalData->bNoAudioIn = TRUE;
89c2c66affSColin Finck     }
90c2c66affSColin Finck     else
91c2c66affSColin Finck     {
92c2c66affSColin Finck         WCHAR DefaultDevice[MAX_PATH] = {0};
93c2c66affSColin Finck         HKEY hKey;
94c2c66affSColin Finck         DWORD dwSize = sizeof(DefaultDevice);
95c2c66affSColin Finck         UINT DefaultIndex = 0;
96c2c66affSColin Finck 
97c2c66affSColin Finck         if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Multimedia\\Sound Mapper", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
98c2c66affSColin Finck         {
99c2c66affSColin Finck             RegQueryValueExW(hKey, L"Record", NULL, NULL, (LPBYTE)DefaultDevice, &dwSize);
100781c247bSThamatip Chitpong             DefaultDevice[_countof(DefaultDevice) - 1] = UNICODE_NULL;
101c2c66affSColin Finck             RegCloseKey(hKey);
102c2c66affSColin Finck         }
103c2c66affSColin Finck 
104c2c66affSColin Finck 
105c2c66affSColin Finck         for (uIndex = 0; uIndex < DevsNum; uIndex++)
106c2c66affSColin Finck         {
107781c247bSThamatip Chitpong             if (waveInGetDevCapsW(uIndex, &waveInputPaps, sizeof(waveInputPaps)))
108c2c66affSColin Finck                 continue;
109c2c66affSColin Finck 
110781c247bSThamatip Chitpong             Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM)waveInputPaps.szPname);
111c2c66affSColin Finck 
112c2c66affSColin Finck             if (CB_ERR != Res)
113c2c66affSColin Finck             {
114781c247bSThamatip Chitpong                 SendMessageW(hCB, CB_SETITEMDATA, Res, (LPARAM)uIndex);
115781c247bSThamatip Chitpong                 if (!_wcsicmp(waveInputPaps.szPname, DefaultDevice))
116c2c66affSColin Finck                     DefaultIndex = Res;
117c2c66affSColin Finck             }
118c2c66affSColin Finck         }
119781c247bSThamatip Chitpong         SendMessageW(hCB, CB_SETCURSEL, (WPARAM)DefaultIndex, 0);
120c2c66affSColin Finck     }
121c2c66affSColin Finck 
122c2c66affSColin Finck     // Init MIDI devices list
123c2c66affSColin Finck     hCB = GetDlgItem(hwnd, IDC_DEVICE_MIDI_LIST);
124c2c66affSColin Finck 
125c2c66affSColin Finck     DevsNum = midiOutGetNumDevs();
126c2c66affSColin Finck     if (DevsNum < 1)
127c2c66affSColin Finck     {
128781c247bSThamatip Chitpong         Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM)szNoDevices);
129781c247bSThamatip Chitpong         SendMessageW(hCB, CB_SETCURSEL, (WPARAM)Res, 0);
130c95f3358SStanislav Motylkov         pGlobalData->bNoMIDIOut = TRUE;
131c2c66affSColin Finck     }
132c2c66affSColin Finck     else
133c2c66affSColin Finck     {
134da528a66SStanislav Motylkov         WCHAR DefaultDevice[MAX_PATH] = {0};
135da528a66SStanislav Motylkov         HKEY hKey;
136da528a66SStanislav Motylkov         DWORD dwSize = sizeof(DefaultDevice);
137da528a66SStanislav Motylkov         UINT DefaultIndex = 0;
138da528a66SStanislav Motylkov 
139da528a66SStanislav Motylkov         if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Multimedia\\MIDIMap", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
140da528a66SStanislav Motylkov         {
141da528a66SStanislav Motylkov             RegQueryValueExW(hKey, L"szPname", NULL, NULL, (LPBYTE)DefaultDevice, &dwSize);
142781c247bSThamatip Chitpong             DefaultDevice[_countof(DefaultDevice) - 1] = UNICODE_NULL;
143da528a66SStanislav Motylkov             RegCloseKey(hKey);
144da528a66SStanislav Motylkov         }
145da528a66SStanislav Motylkov 
146c2c66affSColin Finck         for (uIndex = 0; uIndex < DevsNum; uIndex++)
147c2c66affSColin Finck         {
148781c247bSThamatip Chitpong             if (midiOutGetDevCapsW(uIndex, &midiOutCaps, sizeof(midiOutCaps)))
149c2c66affSColin Finck                 continue;
150c2c66affSColin Finck 
151781c247bSThamatip Chitpong             Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM)midiOutCaps.szPname);
152c2c66affSColin Finck 
153c2c66affSColin Finck             if (CB_ERR != Res)
154c2c66affSColin Finck             {
155781c247bSThamatip Chitpong                 SendMessageW(hCB, CB_SETITEMDATA, Res, (LPARAM)uIndex);
156781c247bSThamatip Chitpong                 if (!_wcsicmp(midiOutCaps.szPname, DefaultDevice))
157da528a66SStanislav Motylkov                     DefaultIndex = Res;
158c2c66affSColin Finck             }
159c2c66affSColin Finck         }
160781c247bSThamatip Chitpong         SendMessageW(hCB, CB_SETCURSEL, (WPARAM)DefaultIndex, 0);
161c2c66affSColin Finck     }
162c2c66affSColin Finck }
163c2c66affSColin Finck 
164c95f3358SStanislav Motylkov VOID
UpdateRegistryString(HWND hwnd,INT ctrl,LPCWSTR key,LPCWSTR value)165*3da25b73SThamatip Chitpong UpdateRegistryString(HWND hwnd, INT ctrl, LPCWSTR key, LPCWSTR value)
166c95f3358SStanislav Motylkov {
167c95f3358SStanislav Motylkov     HWND hwndCombo = GetDlgItem(hwnd, ctrl);
168781c247bSThamatip Chitpong     INT CurSel = SendMessageW(hwndCombo, CB_GETCURSEL, 0, 0);
169c95f3358SStanislav Motylkov     UINT TextLen;
170c95f3358SStanislav Motylkov     WCHAR SelectedDevice[MAX_PATH] = {0};
171c95f3358SStanislav Motylkov     HKEY hKey;
172c95f3358SStanislav Motylkov 
173c95f3358SStanislav Motylkov     if (CurSel == CB_ERR)
174c95f3358SStanislav Motylkov         return;
175c95f3358SStanislav Motylkov 
176c95f3358SStanislav Motylkov     TextLen = SendMessageW(hwndCombo, CB_GETLBTEXTLEN, CurSel, 0) + 1;
177c95f3358SStanislav Motylkov 
178c95f3358SStanislav Motylkov     if (TextLen > _countof(SelectedDevice))
179c95f3358SStanislav Motylkov         return;
180c95f3358SStanislav Motylkov 
181c95f3358SStanislav Motylkov     SendMessageW(hwndCombo, CB_GETLBTEXT, CurSel, (LPARAM)SelectedDevice);
182c95f3358SStanislav Motylkov 
183c95f3358SStanislav Motylkov     if (RegCreateKeyExW(HKEY_CURRENT_USER, key, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS)
184c95f3358SStanislav Motylkov         return;
185c95f3358SStanislav Motylkov 
186c95f3358SStanislav Motylkov     RegSetValueExW(hKey, value, 0, REG_SZ, (BYTE*)SelectedDevice, (wcslen(SelectedDevice) + 1) * sizeof(WCHAR));
187c95f3358SStanislav Motylkov     RegCloseKey(hKey);
188c95f3358SStanislav Motylkov }
189c95f3358SStanislav Motylkov 
190c95f3358SStanislav Motylkov VOID
SaveAudioDlg(HWND hwnd,PGLOBAL_DATA pGlobalData)191c95f3358SStanislav Motylkov SaveAudioDlg(HWND hwnd, PGLOBAL_DATA pGlobalData)
192c95f3358SStanislav Motylkov {
193c95f3358SStanislav Motylkov     if (pGlobalData->bAudioOutChanged)
194c95f3358SStanislav Motylkov     {
195c95f3358SStanislav Motylkov         UpdateRegistryString(hwnd,
196c95f3358SStanislav Motylkov                              IDC_DEVICE_PLAY_LIST,
197c95f3358SStanislav Motylkov                              L"Software\\Microsoft\\Multimedia\\Sound Mapper",
198c95f3358SStanislav Motylkov                              L"Playback");
199c95f3358SStanislav Motylkov     }
200c95f3358SStanislav Motylkov 
201c95f3358SStanislav Motylkov     if (pGlobalData->bAudioInChanged)
202c95f3358SStanislav Motylkov     {
203c95f3358SStanislav Motylkov         UpdateRegistryString(hwnd,
204c95f3358SStanislav Motylkov                              IDC_DEVICE_REC_LIST,
205c95f3358SStanislav Motylkov                              L"Software\\Microsoft\\Multimedia\\Sound Mapper",
206c95f3358SStanislav Motylkov                              L"Record");
207c95f3358SStanislav Motylkov     }
208c95f3358SStanislav Motylkov 
209c95f3358SStanislav Motylkov     if (pGlobalData->bMIDIOutChanged)
210c95f3358SStanislav Motylkov     {
211c95f3358SStanislav Motylkov         UpdateRegistryString(hwnd,
212c95f3358SStanislav Motylkov                              IDC_DEVICE_MIDI_LIST,
213c95f3358SStanislav Motylkov                              L"Software\\Microsoft\\Windows\\CurrentVersion\\Multimedia\\MIDIMap",
214c95f3358SStanislav Motylkov                              L"szPname");
215c95f3358SStanislav Motylkov     }
216c95f3358SStanislav Motylkov }
217c95f3358SStanislav Motylkov 
218c2c66affSColin Finck static UINT
GetDevNum(HWND hControl,DWORD Id)219c2c66affSColin Finck GetDevNum(HWND hControl, DWORD Id)
220c2c66affSColin Finck {
221c2c66affSColin Finck     int iCurSel;
222c2c66affSColin Finck     UINT DevNum;
223c2c66affSColin Finck 
224781c247bSThamatip Chitpong     iCurSel = SendMessageW(hControl, CB_GETCURSEL, 0, 0);
225c2c66affSColin Finck 
226c2c66affSColin Finck     if (iCurSel == CB_ERR)
227c2c66affSColin Finck         return 0;
228c2c66affSColin Finck 
229781c247bSThamatip Chitpong     DevNum = (UINT)SendMessageW(hControl, CB_GETITEMDATA, iCurSel, 0);
230c2c66affSColin Finck     if (DevNum == (UINT) CB_ERR)
231c2c66affSColin Finck         return 0;
232c2c66affSColin Finck 
233c2c66affSColin Finck     if (mixerGetID((HMIXEROBJ)IntToPtr(DevNum), &DevNum, Id) != MMSYSERR_NOERROR)
234c2c66affSColin Finck         return 0;
235c2c66affSColin Finck 
236c2c66affSColin Finck     return DevNum;
237c2c66affSColin Finck }
238c2c66affSColin Finck 
239c2c66affSColin Finck /* Audio property page dialog callback */
240c2c66affSColin Finck INT_PTR CALLBACK
AudioDlgProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)241c2c66affSColin Finck AudioDlgProc(HWND hwndDlg,
242c2c66affSColin Finck              UINT uMsg,
243c2c66affSColin Finck              WPARAM wParam,
244c2c66affSColin Finck              LPARAM lParam)
245c2c66affSColin Finck {
246c95f3358SStanislav Motylkov     PGLOBAL_DATA pGlobalData;
247c95f3358SStanislav Motylkov 
248781c247bSThamatip Chitpong     pGlobalData = (PGLOBAL_DATA)GetWindowLongPtrW(hwndDlg, DWLP_USER);
249c2c66affSColin Finck 
250c2c66affSColin Finck     switch (uMsg)
251c2c66affSColin Finck     {
252c2c66affSColin Finck         case WM_INITDIALOG:
253c2c66affSColin Finck         {
254c2c66affSColin Finck             UINT NumWavOut = waveOutGetNumDevs();
255c2c66affSColin Finck 
256c95f3358SStanislav Motylkov             pGlobalData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBAL_DATA));
257781c247bSThamatip Chitpong             SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
258c95f3358SStanislav Motylkov 
259c95f3358SStanislav Motylkov             if (!pGlobalData)
260c95f3358SStanislav Motylkov                 break;
261c95f3358SStanislav Motylkov 
262c95f3358SStanislav Motylkov             InitAudioDlg(hwndDlg, pGlobalData);
263c2c66affSColin Finck 
264c2c66affSColin Finck             if (!NumWavOut)
265c2c66affSColin Finck             {
266c2c66affSColin Finck                 EnableWindow(GetDlgItem(hwndDlg, IDC_DEVICE_PLAY_LIST),     FALSE);
267c2c66affSColin Finck                 EnableWindow(GetDlgItem(hwndDlg, IDC_DEVICE_REC_LIST),      FALSE);
268c2c66affSColin Finck                 EnableWindow(GetDlgItem(hwndDlg, IDC_DEVICE_MIDI_LIST),     FALSE);
269c2c66affSColin Finck                 EnableWindow(GetDlgItem(hwndDlg, IDC_DEFAULT_DEV_CHECKBOX), FALSE);
270c2c66affSColin Finck                 EnableWindow(GetDlgItem(hwndDlg, IDC_VOLUME1_BTN),          FALSE);
271c2c66affSColin Finck                 EnableWindow(GetDlgItem(hwndDlg, IDC_ADV2_BTN),             FALSE);
272c2c66affSColin Finck                 EnableWindow(GetDlgItem(hwndDlg, IDC_VOLUME2_BTN),          FALSE);
273c2c66affSColin Finck                 EnableWindow(GetDlgItem(hwndDlg, IDC_ADV1_BTN),             FALSE);
274c2c66affSColin Finck                 EnableWindow(GetDlgItem(hwndDlg, IDC_VOLUME3_BTN),          FALSE);
275c2c66affSColin Finck                 EnableWindow(GetDlgItem(hwndDlg, IDC_ADV3_BTN),             FALSE);
276c2c66affSColin Finck             }
277c95f3358SStanislav Motylkov 
278c95f3358SStanislav Motylkov             if (pGlobalData->bNoAudioOut)
279c95f3358SStanislav Motylkov             {
280c95f3358SStanislav Motylkov                 EnableWindow(GetDlgItem(hwndDlg, IDC_DEVICE_PLAY_LIST),     FALSE);
281c95f3358SStanislav Motylkov                 EnableWindow(GetDlgItem(hwndDlg, IDC_VOLUME1_BTN),          FALSE);
282c95f3358SStanislav Motylkov                 EnableWindow(GetDlgItem(hwndDlg, IDC_ADV2_BTN),             FALSE);
283c95f3358SStanislav Motylkov             }
284c95f3358SStanislav Motylkov 
285c95f3358SStanislav Motylkov             if (pGlobalData->bNoAudioIn)
286c95f3358SStanislav Motylkov             {
287c95f3358SStanislav Motylkov                 EnableWindow(GetDlgItem(hwndDlg, IDC_DEVICE_REC_LIST),      FALSE);
288c95f3358SStanislav Motylkov                 EnableWindow(GetDlgItem(hwndDlg, IDC_VOLUME2_BTN),          FALSE);
289c95f3358SStanislav Motylkov                 EnableWindow(GetDlgItem(hwndDlg, IDC_ADV1_BTN),             FALSE);
290c95f3358SStanislav Motylkov             }
291c95f3358SStanislav Motylkov 
292c95f3358SStanislav Motylkov             if (pGlobalData->bNoMIDIOut)
293c95f3358SStanislav Motylkov             {
294c95f3358SStanislav Motylkov                 EnableWindow(GetDlgItem(hwndDlg, IDC_DEVICE_MIDI_LIST),     FALSE);
295c95f3358SStanislav Motylkov                 EnableWindow(GetDlgItem(hwndDlg, IDC_VOLUME3_BTN),          FALSE);
296c95f3358SStanislav Motylkov                 EnableWindow(GetDlgItem(hwndDlg, IDC_ADV3_BTN),             FALSE);
297c95f3358SStanislav Motylkov             }
298c2c66affSColin Finck         }
299c2c66affSColin Finck         break;
300c2c66affSColin Finck 
301c2c66affSColin Finck         case WM_COMMAND:
302c2c66affSColin Finck         {
303781c247bSThamatip Chitpong             STARTUPINFOW si;
304c2c66affSColin Finck             PROCESS_INFORMATION pi;
305c2c66affSColin Finck             WCHAR szPath[MAX_PATH];
306c2c66affSColin Finck 
307c95f3358SStanislav Motylkov             if (!pGlobalData)
308c95f3358SStanislav Motylkov                 break;
309c95f3358SStanislav Motylkov 
310c2c66affSColin Finck             switch (LOWORD(wParam))
311c2c66affSColin Finck             {
312c2c66affSColin Finck                 case IDC_VOLUME1_BTN:
313c2c66affSColin Finck                 {
314781c247bSThamatip Chitpong                     StringCchPrintfW(szPath, _countof(szPath), L"sndvol32.exe -d %d",
315c2c66affSColin Finck                                      GetDevNum(GetDlgItem(hwndDlg, IDC_DEVICE_PLAY_LIST), MIXER_OBJECTF_WAVEOUT));
316c2c66affSColin Finck 
317c2c66affSColin Finck                     ZeroMemory(&si, sizeof(si));
318c2c66affSColin Finck                     si.cb = sizeof(si);
319c2c66affSColin Finck                     si.dwFlags = STARTF_USESHOWWINDOW;
320c2c66affSColin Finck                     si.wShowWindow = SW_SHOW;
321c2c66affSColin Finck 
322781c247bSThamatip Chitpong                     if (CreateProcessW(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
323781c247bSThamatip Chitpong                     {
324781c247bSThamatip Chitpong                         CloseHandle(pi.hProcess);
325781c247bSThamatip Chitpong                         CloseHandle(pi.hThread);
326781c247bSThamatip Chitpong                     }
327c2c66affSColin Finck                 }
328c2c66affSColin Finck                 break;
329c2c66affSColin Finck 
330c2c66affSColin Finck                 case IDC_ADV2_BTN:
331c2c66affSColin Finck                 {
332c2c66affSColin Finck 
333c2c66affSColin Finck                 }
334c2c66affSColin Finck                 break;
335c2c66affSColin Finck 
336c2c66affSColin Finck                 case IDC_VOLUME2_BTN:
337c2c66affSColin Finck                 {
338781c247bSThamatip Chitpong                     StringCchPrintfW(szPath, _countof(szPath), L"sndvol32.exe -r -d %d",
339c2c66affSColin Finck                                      GetDevNum(GetDlgItem(hwndDlg, IDC_DEVICE_REC_LIST), MIXER_OBJECTF_WAVEIN));
340c2c66affSColin Finck 
341c2c66affSColin Finck                     ZeroMemory(&si, sizeof(si));
342c2c66affSColin Finck                     si.cb = sizeof(si);
343c2c66affSColin Finck                     si.dwFlags = STARTF_USESHOWWINDOW;
344c2c66affSColin Finck                     si.wShowWindow = SW_SHOW;
345c2c66affSColin Finck 
346781c247bSThamatip Chitpong                     if (CreateProcessW(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
347781c247bSThamatip Chitpong                     {
348781c247bSThamatip Chitpong                         CloseHandle(pi.hProcess);
349781c247bSThamatip Chitpong                         CloseHandle(pi.hThread);
350781c247bSThamatip Chitpong                     }
351c2c66affSColin Finck                 }
352c2c66affSColin Finck                 break;
353c2c66affSColin Finck 
354c2c66affSColin Finck                 case IDC_ADV1_BTN:
355c2c66affSColin Finck                 {
356c2c66affSColin Finck 
357c2c66affSColin Finck                 }
358c2c66affSColin Finck                 break;
359c2c66affSColin Finck 
360c2c66affSColin Finck                 case IDC_VOLUME3_BTN:
361c2c66affSColin Finck                 {
362781c247bSThamatip Chitpong                     StringCchPrintfW(szPath, _countof(szPath), L"sndvol32.exe -d %d",
363c2c66affSColin Finck                                      GetDevNum(GetDlgItem(hwndDlg, IDC_DEVICE_MIDI_LIST), MIXER_OBJECTF_MIDIOUT));
364c2c66affSColin Finck 
365c2c66affSColin Finck                     ZeroMemory(&si, sizeof(si));
366c2c66affSColin Finck                     si.cb = sizeof(si);
367c2c66affSColin Finck                     si.dwFlags = STARTF_USESHOWWINDOW;
368c2c66affSColin Finck                     si.wShowWindow = SW_SHOW;
369c2c66affSColin Finck 
370781c247bSThamatip Chitpong                     if (CreateProcessW(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
371781c247bSThamatip Chitpong                     {
372781c247bSThamatip Chitpong                         CloseHandle(pi.hProcess);
373781c247bSThamatip Chitpong                         CloseHandle(pi.hThread);
374781c247bSThamatip Chitpong                     }
375c2c66affSColin Finck                 }
376c2c66affSColin Finck                 break;
377c2c66affSColin Finck 
378c2c66affSColin Finck                 case IDC_ADV3_BTN:
379c2c66affSColin Finck                 {
380c2c66affSColin Finck 
381c2c66affSColin Finck                 }
382c2c66affSColin Finck                 break;
383c95f3358SStanislav Motylkov 
384c95f3358SStanislav Motylkov                 case IDC_DEVICE_PLAY_LIST:
385c95f3358SStanislav Motylkov                 {
386c95f3358SStanislav Motylkov                     if (HIWORD(wParam) == CBN_SELCHANGE)
387c95f3358SStanislav Motylkov                     {
388c95f3358SStanislav Motylkov                         PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
389c95f3358SStanislav Motylkov                         pGlobalData->bAudioOutChanged = TRUE;
390c2c66affSColin Finck                     }
391c2c66affSColin Finck                 }
392c2c66affSColin Finck                 break;
393c95f3358SStanislav Motylkov 
394c95f3358SStanislav Motylkov                 case IDC_DEVICE_REC_LIST:
395c95f3358SStanislav Motylkov                 {
396c95f3358SStanislav Motylkov                     if (HIWORD(wParam) == CBN_SELCHANGE)
397c95f3358SStanislav Motylkov                     {
398c95f3358SStanislav Motylkov                         PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
399c95f3358SStanislav Motylkov                         pGlobalData->bAudioInChanged = TRUE;
400c95f3358SStanislav Motylkov                     }
401c95f3358SStanislav Motylkov                 }
402c95f3358SStanislav Motylkov 
403c95f3358SStanislav Motylkov                 case IDC_DEVICE_MIDI_LIST:
404c95f3358SStanislav Motylkov                 {
405c95f3358SStanislav Motylkov                     if (HIWORD(wParam) == CBN_SELCHANGE)
406c95f3358SStanislav Motylkov                     {
407c95f3358SStanislav Motylkov                         PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
408c95f3358SStanislav Motylkov                         pGlobalData->bMIDIOutChanged = TRUE;
409c95f3358SStanislav Motylkov                     }
410c95f3358SStanislav Motylkov                 }
411c95f3358SStanislav Motylkov                 break;
412c95f3358SStanislav Motylkov             }
413c95f3358SStanislav Motylkov         }
414c95f3358SStanislav Motylkov         break;
415c95f3358SStanislav Motylkov 
416c95f3358SStanislav Motylkov         case WM_DESTROY:
417c95f3358SStanislav Motylkov             if (!pGlobalData)
418c95f3358SStanislav Motylkov                 break;
419c95f3358SStanislav Motylkov 
420c95f3358SStanislav Motylkov             HeapFree(GetProcessHeap(), 0, pGlobalData);
421c95f3358SStanislav Motylkov             break;
422c95f3358SStanislav Motylkov 
423c95f3358SStanislav Motylkov         case WM_NOTIFY:
424c95f3358SStanislav Motylkov             if (!pGlobalData)
425c95f3358SStanislav Motylkov                 break;
426c95f3358SStanislav Motylkov 
427c95f3358SStanislav Motylkov             if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
428c95f3358SStanislav Motylkov             {
429c95f3358SStanislav Motylkov                 SaveAudioDlg(hwndDlg, pGlobalData);
430c95f3358SStanislav Motylkov             }
431c95f3358SStanislav Motylkov             return TRUE;
432c2c66affSColin Finck     }
433c2c66affSColin Finck 
434c2c66affSColin Finck     return FALSE;
435c2c66affSColin Finck }
436