2 * Audio management UI code
4 * Copyright 2004 Chris Morgan
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define WIN32_LEAN_AND_MEAN
23 #define NONAMELESSSTRUCT
24 #define NONAMELESSUNION
27 #include "wine/port.h"
36 #include <wine/debug.h>
49 #include "mmdeviceapi.h"
50 #include "audioclient.h"
51 #include "audiopolicy.h"
56 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
58 static struct DSOUNDACCEL
62 const char* settingStr;
63 } DSound_HW_Accels[] = {
64 {IDS_ACCEL_FULL, 1, "Full"},
65 {IDS_ACCEL_STANDARD, 0, "Standard"},
66 {IDS_ACCEL_BASIC, 0, "Basic"},
67 {IDS_ACCEL_EMULATION, 1, "Emulation"},
71 static const char* DSound_Rates[] = {
81 static const char* DSound_Bits[] = {
87 static void initAudioDlg (HWND hDlg)
94 SendDlgItemMessage(hDlg, IDC_DSOUND_HW_ACCEL, CB_RESETCONTENT, 0, 0);
95 buf = get_reg_key(config_key, keypath("DirectSound"), "HardwareAcceleration", "Full");
98 for (i = 0; 0 != DSound_HW_Accels[i].displayID; ++i) {
102 match = (strcmp(buf, DSound_HW_Accels[i].settingStr) == 0);
105 DSound_HW_Accels[i].visible = 1;
109 if (DSound_HW_Accels[i].visible)
111 LoadStringW (GetModuleHandle (NULL), DSound_HW_Accels[i].displayID,
112 accelStr, sizeof(accelStr)/sizeof(accelStr[0]));
113 SendDlgItemMessageW (hDlg, IDC_DSOUND_HW_ACCEL, CB_ADDSTRING, 0, (LPARAM)accelStr);
115 SendDlgItemMessage(hDlg, IDC_DSOUND_HW_ACCEL, CB_SETCURSEL, j, 0);
120 WINE_ERR("Invalid Direct Sound HW Accel read from registry (%s)\n", buf);
122 HeapFree(GetProcessHeap(), 0, buf);
124 SendDlgItemMessage(hDlg, IDC_DSOUND_RATES, CB_RESETCONTENT, 0, 0);
125 for (i = 0; NULL != DSound_Rates[i]; ++i) {
126 SendDlgItemMessage(hDlg, IDC_DSOUND_RATES, CB_ADDSTRING, 0, (LPARAM) DSound_Rates[i]);
128 buf = get_reg_key(config_key, keypath("DirectSound"), "DefaultSampleRate", "44100");
129 for (i = 0; NULL != DSound_Rates[i]; ++i) {
130 if (strcmp(buf, DSound_Rates[i]) == 0) {
131 SendDlgItemMessage(hDlg, IDC_DSOUND_RATES, CB_SETCURSEL, i, 0);
136 SendDlgItemMessage(hDlg, IDC_DSOUND_BITS, CB_RESETCONTENT, 0, 0);
137 for (i = 0; NULL != DSound_Bits[i]; ++i) {
138 SendDlgItemMessage(hDlg, IDC_DSOUND_BITS, CB_ADDSTRING, 0, (LPARAM) DSound_Bits[i]);
140 buf = get_reg_key(config_key, keypath("DirectSound"), "DefaultBitsPerSample", "16");
141 for (i = 0; NULL != DSound_Bits[i]; ++i) {
142 if (strcmp(buf, DSound_Bits[i]) == 0) {
143 SendDlgItemMessage(hDlg, IDC_DSOUND_BITS, CB_SETCURSEL, i, 0);
147 HeapFree(GetProcessHeap(), 0, buf);
151 AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
155 switch (LOWORD(wParam)) {
157 if(!PlaySound(MAKEINTRESOURCE(IDW_TESTSOUND), NULL, SND_RESOURCE | SND_SYNC))
158 MessageBox(NULL, "Audio test failed!", "Error", MB_OK | MB_ICONERROR);
160 case IDC_DSOUND_HW_ACCEL:
161 if (HIWORD(wParam) == CBN_SELCHANGE) {
162 int selected_dsound_accel;
165 SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
166 selected_dsound_accel = SendDlgItemMessage(hDlg, IDC_DSOUND_HW_ACCEL, CB_GETCURSEL, 0, 0);
167 for (i = 0; DSound_HW_Accels[i].settingStr; ++i)
169 if (DSound_HW_Accels[i].visible)
171 if (j == selected_dsound_accel)
173 set_reg_key(config_key, keypath("DirectSound"), "HardwareAcceleration",
174 DSound_HW_Accels[i].settingStr);
182 case IDC_DSOUND_RATES:
183 if (HIWORD(wParam) == CBN_SELCHANGE) {
184 int selected_dsound_rate;
185 SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
186 selected_dsound_rate = SendDlgItemMessage(hDlg, IDC_DSOUND_RATES, CB_GETCURSEL, 0, 0);
187 set_reg_key(config_key, keypath("DirectSound"), "DefaultSampleRate", DSound_Rates[selected_dsound_rate]);
190 case IDC_DSOUND_BITS:
191 if (HIWORD(wParam) == CBN_SELCHANGE) {
192 int selected_dsound_bits;
193 SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
194 selected_dsound_bits = SendDlgItemMessage(hDlg, IDC_DSOUND_BITS, CB_GETCURSEL, 0, 0);
195 set_reg_key(config_key, keypath("DirectSound"), "DefaultBitsPerSample", DSound_Bits[selected_dsound_bits]);
201 set_window_title(hDlg);
205 switch(((LPNMHDR)lParam)->code) {
207 SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
211 SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);