2004-01-20 03:07:35 +01:00
|
|
|
/*
|
|
|
|
* Audio management UI code
|
|
|
|
*
|
|
|
|
* Copyright 2004 Chris Morgan
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-01-20 03:07:35 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-01-19 11:55:01 +01:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2005-12-08 11:57:44 +01:00
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
2004-01-20 03:07:35 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2011-08-31 22:16:16 +02:00
|
|
|
#define COBJMACROS
|
2006-01-19 11:55:01 +01:00
|
|
|
#include <windows.h>
|
2004-01-20 03:07:35 +01:00
|
|
|
#include <wine/debug.h>
|
|
|
|
#include <shellapi.h>
|
|
|
|
#include <objbase.h>
|
|
|
|
#include <shlguid.h>
|
|
|
|
#include <shlwapi.h>
|
|
|
|
#include <shlobj.h>
|
2005-06-28 21:12:52 +02:00
|
|
|
#include <mmsystem.h>
|
2005-12-07 12:50:52 +01:00
|
|
|
#include <mmreg.h>
|
|
|
|
#include <mmddk.h>
|
2004-01-20 03:07:35 +01:00
|
|
|
|
2011-08-31 22:16:16 +02:00
|
|
|
#include "ole2.h"
|
|
|
|
#include "initguid.h"
|
|
|
|
#include "devpkey.h"
|
|
|
|
#include "mmdeviceapi.h"
|
|
|
|
#include "audioclient.h"
|
|
|
|
#include "audiopolicy.h"
|
|
|
|
|
2004-01-20 03:07:35 +01:00
|
|
|
#include "winecfg.h"
|
|
|
|
#include "resource.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
|
|
|
|
|
2011-09-27 15:49:34 +02:00
|
|
|
static BOOL get_driver_name(PROPVARIANT *pv)
|
2006-08-19 05:19:57 +02:00
|
|
|
{
|
2011-09-27 15:49:34 +02:00
|
|
|
IMMDeviceEnumerator *devenum;
|
|
|
|
IMMDevice *device;
|
|
|
|
IPropertyStore *ps;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
static const WCHAR wine_info_deviceW[] = {'W','i','n','e',' ',
|
|
|
|
'i','n','f','o',' ','d','e','v','i','c','e',0};
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&devenum);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
hr = IMMDeviceEnumerator_GetDevice(devenum, wine_info_deviceW, &device);
|
|
|
|
IMMDeviceEnumerator_Release(devenum);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
hr = IMMDevice_OpenPropertyStore(device, STGM_READ, &ps);
|
|
|
|
if(FAILED(hr)){
|
|
|
|
IMMDevice_Release(device);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IPropertyStore_GetValue(ps,
|
|
|
|
(const PROPERTYKEY *)&DEVPKEY_Device_Driver, pv);
|
|
|
|
IPropertyStore_Release(ps);
|
|
|
|
IMMDevice_Release(device);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2006-04-06 02:53:02 +02:00
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
static void initAudioDlg (HWND hDlg)
|
|
|
|
{
|
2011-09-27 15:49:34 +02:00
|
|
|
WCHAR display_str[256], format_str[256], disabled_str[64];
|
|
|
|
PROPVARIANT pv;
|
2004-01-20 03:07:35 +01:00
|
|
|
|
2005-01-14 20:48:41 +01:00
|
|
|
WINE_TRACE("\n");
|
|
|
|
|
2011-09-27 15:49:34 +02:00
|
|
|
LoadStringW(GetModuleHandle(NULL), IDS_AUDIO_DRIVER,
|
|
|
|
format_str, sizeof(format_str) / sizeof(*format_str));
|
|
|
|
LoadStringW(GetModuleHandle(NULL), IDS_AUDIO_DRIVER_NONE,
|
|
|
|
disabled_str, sizeof(disabled_str) / sizeof(*disabled_str));
|
|
|
|
|
|
|
|
PropVariantInit(&pv);
|
|
|
|
if(get_driver_name(&pv) && pv.u.pwszVal[0] != '\0')
|
|
|
|
wnsprintfW(display_str, sizeof(display_str) / sizeof(*display_str),
|
|
|
|
format_str, pv.u.pwszVal);
|
|
|
|
else
|
|
|
|
wnsprintfW(display_str, sizeof(display_str) / sizeof(*display_str),
|
|
|
|
format_str, disabled_str);
|
|
|
|
PropVariantClear(&pv);
|
|
|
|
|
|
|
|
SetDlgItemTextW(hDlg, IDC_AUDIO_DRIVER, display_str);
|
2004-01-20 03:07:35 +01:00
|
|
|
}
|
|
|
|
|
2011-10-05 20:39:46 +02:00
|
|
|
static void test_sound(void)
|
|
|
|
{
|
|
|
|
BOOL (WINAPI *pPlaySoundW)(const WCHAR *, HMODULE, DWORD);
|
|
|
|
HMODULE winmm;
|
|
|
|
|
|
|
|
static const WCHAR winmmW[] = {'w','i','n','m','m','.','d','l','l',0};
|
|
|
|
|
|
|
|
winmm = LoadLibraryW(winmmW);
|
|
|
|
if(!winmm){
|
|
|
|
WINE_ERR("LoadLibrary failed: %u\n", GetLastError());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pPlaySoundW = (void*)GetProcAddress(winmm, "PlaySoundW");
|
|
|
|
if(!pPlaySoundW){
|
|
|
|
WINE_ERR("GetProcAddress failed: %u\n", GetLastError());
|
|
|
|
FreeLibrary(winmm);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!pPlaySoundW(MAKEINTRESOURCEW(IDW_TESTSOUND), NULL, SND_RESOURCE | SND_SYNC)){
|
|
|
|
WCHAR error_str[256], title_str[256];
|
|
|
|
|
|
|
|
LoadStringW(GetModuleHandle(NULL), IDS_AUDIO_TEST_FAILED,
|
|
|
|
error_str, sizeof(error_str) / sizeof(*error_str));
|
|
|
|
LoadStringW(GetModuleHandle(NULL), IDS_AUDIO_TEST_FAILED_TITLE,
|
|
|
|
title_str, sizeof(title_str) / sizeof(*title_str));
|
|
|
|
|
|
|
|
MessageBoxW(NULL, error_str, title_str, MB_OK | MB_ICONERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
FreeLibrary(winmm);
|
|
|
|
}
|
|
|
|
|
2004-01-20 03:07:35 +01:00
|
|
|
INT_PTR CALLBACK
|
|
|
|
AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (uMsg) {
|
|
|
|
case WM_COMMAND:
|
2011-08-31 22:16:16 +02:00
|
|
|
switch (LOWORD(wParam)) {
|
2007-04-03 22:09:02 +02:00
|
|
|
case IDC_AUDIO_TEST:
|
2011-10-05 20:39:46 +02:00
|
|
|
test_sound();
|
2011-08-31 22:16:16 +02:00
|
|
|
break;
|
|
|
|
}
|
2004-09-28 05:55:16 +02:00
|
|
|
case WM_SHOWWINDOW:
|
|
|
|
set_window_title(hDlg);
|
|
|
|
break;
|
2005-12-17 12:30:06 +01:00
|
|
|
|
2004-01-20 03:07:35 +01:00
|
|
|
case WM_NOTIFY:
|
2011-08-31 22:16:16 +02:00
|
|
|
switch(((LPNMHDR)lParam)->code) {
|
|
|
|
case PSN_KILLACTIVE:
|
|
|
|
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
|
|
|
|
break;
|
|
|
|
case PSN_APPLY:
|
2004-09-28 05:55:16 +02:00
|
|
|
apply();
|
2011-08-31 22:16:16 +02:00
|
|
|
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
|
2005-12-17 12:30:06 +01:00
|
|
|
break;
|
2011-08-31 22:16:16 +02:00
|
|
|
case PSN_SETACTIVE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
initAudioDlg(hDlg);
|
|
|
|
break;
|
2004-01-20 03:07:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|