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 BOOL get_driver_name(PROPVARIANT *pv)
60 IMMDeviceEnumerator *devenum;
65 static const WCHAR wine_info_deviceW[] = {'W','i','n','e',' ',
66 'i','n','f','o',' ','d','e','v','i','c','e',0};
68 hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL,
69 CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&devenum);
73 hr = IMMDeviceEnumerator_GetDevice(devenum, wine_info_deviceW, &device);
74 IMMDeviceEnumerator_Release(devenum);
78 hr = IMMDevice_OpenPropertyStore(device, STGM_READ, &ps);
80 IMMDevice_Release(device);
84 hr = IPropertyStore_GetValue(ps,
85 (const PROPERTYKEY *)&DEVPKEY_Device_Driver, pv);
86 IPropertyStore_Release(ps);
87 IMMDevice_Release(device);
94 static void initAudioDlg (HWND hDlg)
96 WCHAR display_str[256], format_str[256], disabled_str[64];
101 LoadStringW(GetModuleHandle(NULL), IDS_AUDIO_DRIVER,
102 format_str, sizeof(format_str) / sizeof(*format_str));
103 LoadStringW(GetModuleHandle(NULL), IDS_AUDIO_DRIVER_NONE,
104 disabled_str, sizeof(disabled_str) / sizeof(*disabled_str));
106 PropVariantInit(&pv);
107 if(get_driver_name(&pv) && pv.u.pwszVal[0] != '\0')
108 wnsprintfW(display_str, sizeof(display_str) / sizeof(*display_str),
109 format_str, pv.u.pwszVal);
111 wnsprintfW(display_str, sizeof(display_str) / sizeof(*display_str),
112 format_str, disabled_str);
113 PropVariantClear(&pv);
115 SetDlgItemTextW(hDlg, IDC_AUDIO_DRIVER, display_str);
118 static void test_sound(void)
120 BOOL (WINAPI *pPlaySoundW)(const WCHAR *, HMODULE, DWORD);
123 static const WCHAR winmmW[] = {'w','i','n','m','m','.','d','l','l',0};
125 winmm = LoadLibraryW(winmmW);
127 WINE_ERR("LoadLibrary failed: %u\n", GetLastError());
131 pPlaySoundW = (void*)GetProcAddress(winmm, "PlaySoundW");
133 WINE_ERR("GetProcAddress failed: %u\n", GetLastError());
138 if(!pPlaySoundW(MAKEINTRESOURCEW(IDW_TESTSOUND), NULL, SND_RESOURCE | SND_SYNC)){
139 WCHAR error_str[256], title_str[256];
141 LoadStringW(GetModuleHandle(NULL), IDS_AUDIO_TEST_FAILED,
142 error_str, sizeof(error_str) / sizeof(*error_str));
143 LoadStringW(GetModuleHandle(NULL), IDS_AUDIO_TEST_FAILED_TITLE,
144 title_str, sizeof(title_str) / sizeof(*title_str));
146 MessageBoxW(NULL, error_str, title_str, MB_OK | MB_ICONERROR);
153 AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
157 switch (LOWORD(wParam)) {
163 set_window_title(hDlg);
167 switch(((LPNMHDR)lParam)->code) {
169 SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
173 SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);