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);
119 AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
123 switch (LOWORD(wParam)) {
125 if(!PlaySound(MAKEINTRESOURCE(IDW_TESTSOUND), NULL, SND_RESOURCE | SND_SYNC))
126 MessageBox(NULL, "Audio test failed!", "Error", MB_OK | MB_ICONERROR);
130 set_window_title(hDlg);
134 switch(((LPNMHDR)lParam)->code) {
136 SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
140 SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);