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);
|
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
static struct DSOUNDACCEL
|
|
|
|
{
|
|
|
|
UINT displayID;
|
2009-08-05 15:16:55 +02:00
|
|
|
UINT visible;
|
2006-08-19 05:19:57 +02:00
|
|
|
const char* settingStr;
|
2009-08-05 15:16:55 +02:00
|
|
|
} DSound_HW_Accels[] = {
|
|
|
|
{IDS_ACCEL_FULL, 1, "Full"},
|
|
|
|
{IDS_ACCEL_STANDARD, 0, "Standard"},
|
|
|
|
{IDS_ACCEL_BASIC, 0, "Basic"},
|
|
|
|
{IDS_ACCEL_EMULATION, 1, "Emulation"},
|
|
|
|
{0, 0, 0}
|
2005-07-11 12:24:28 +02:00
|
|
|
};
|
|
|
|
|
2006-04-06 02:53:02 +02:00
|
|
|
static const char* DSound_Rates[] = {
|
|
|
|
"48000",
|
|
|
|
"44100",
|
|
|
|
"22050",
|
|
|
|
"16000",
|
|
|
|
"11025",
|
|
|
|
"8000",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char* DSound_Bits[] = {
|
|
|
|
"8",
|
|
|
|
"16",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
static void initAudioDlg (HWND hDlg)
|
|
|
|
{
|
2009-08-05 15:16:55 +02:00
|
|
|
int i, j, found;
|
2005-07-11 12:24:28 +02:00
|
|
|
char* buf = NULL;
|
2004-01-20 03:07:35 +01:00
|
|
|
|
2005-01-14 20:48:41 +01:00
|
|
|
WINE_TRACE("\n");
|
|
|
|
|
2005-07-11 12:24:28 +02:00
|
|
|
SendDlgItemMessage(hDlg, IDC_DSOUND_HW_ACCEL, CB_RESETCONTENT, 0, 0);
|
2009-08-05 15:16:55 +02:00
|
|
|
buf = get_reg_key(config_key, keypath("DirectSound"), "HardwareAcceleration", "Full");
|
|
|
|
|
|
|
|
j = found = 0;
|
2006-08-19 05:19:57 +02:00
|
|
|
for (i = 0; 0 != DSound_HW_Accels[i].displayID; ++i) {
|
|
|
|
WCHAR accelStr[64];
|
2009-08-05 15:16:55 +02:00
|
|
|
int match;
|
|
|
|
|
|
|
|
match = (strcmp(buf, DSound_HW_Accels[i].settingStr) == 0);
|
|
|
|
if (match)
|
|
|
|
{
|
|
|
|
DSound_HW_Accels[i].visible = 1;
|
|
|
|
found = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DSound_HW_Accels[i].visible)
|
|
|
|
{
|
|
|
|
LoadStringW (GetModuleHandle (NULL), DSound_HW_Accels[i].displayID,
|
|
|
|
accelStr, sizeof(accelStr)/sizeof(accelStr[0]));
|
|
|
|
SendDlgItemMessageW (hDlg, IDC_DSOUND_HW_ACCEL, CB_ADDSTRING, 0, (LPARAM)accelStr);
|
|
|
|
if (match)
|
|
|
|
SendDlgItemMessage(hDlg, IDC_DSOUND_HW_ACCEL, CB_SETCURSEL, j, 0);
|
|
|
|
j++;
|
2005-07-11 12:24:28 +02:00
|
|
|
}
|
|
|
|
}
|
2009-08-05 15:16:55 +02:00
|
|
|
if (!found) {
|
2005-07-11 12:24:28 +02:00
|
|
|
WINE_ERR("Invalid Direct Sound HW Accel read from registry (%s)\n", buf);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
|
2006-04-06 02:53:02 +02:00
|
|
|
SendDlgItemMessage(hDlg, IDC_DSOUND_RATES, CB_RESETCONTENT, 0, 0);
|
|
|
|
for (i = 0; NULL != DSound_Rates[i]; ++i) {
|
|
|
|
SendDlgItemMessage(hDlg, IDC_DSOUND_RATES, CB_ADDSTRING, 0, (LPARAM) DSound_Rates[i]);
|
|
|
|
}
|
2007-08-31 18:21:14 +02:00
|
|
|
buf = get_reg_key(config_key, keypath("DirectSound"), "DefaultSampleRate", "44100");
|
2006-04-06 02:53:02 +02:00
|
|
|
for (i = 0; NULL != DSound_Rates[i]; ++i) {
|
|
|
|
if (strcmp(buf, DSound_Rates[i]) == 0) {
|
|
|
|
SendDlgItemMessage(hDlg, IDC_DSOUND_RATES, CB_SETCURSEL, i, 0);
|
|
|
|
break ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SendDlgItemMessage(hDlg, IDC_DSOUND_BITS, CB_RESETCONTENT, 0, 0);
|
|
|
|
for (i = 0; NULL != DSound_Bits[i]; ++i) {
|
|
|
|
SendDlgItemMessage(hDlg, IDC_DSOUND_BITS, CB_ADDSTRING, 0, (LPARAM) DSound_Bits[i]);
|
|
|
|
}
|
2007-08-31 18:21:14 +02:00
|
|
|
buf = get_reg_key(config_key, keypath("DirectSound"), "DefaultBitsPerSample", "16");
|
2006-04-06 02:53:02 +02:00
|
|
|
for (i = 0; NULL != DSound_Bits[i]; ++i) {
|
|
|
|
if (strcmp(buf, DSound_Bits[i]) == 0) {
|
|
|
|
SendDlgItemMessage(hDlg, IDC_DSOUND_BITS, CB_SETCURSEL, i, 0);
|
|
|
|
break ;
|
|
|
|
}
|
|
|
|
}
|
2005-07-11 12:24:28 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
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-08-31 22:16:16 +02:00
|
|
|
if(!PlaySound(MAKEINTRESOURCE(IDW_TESTSOUND), NULL, SND_RESOURCE | SND_SYNC))
|
|
|
|
MessageBox(NULL, "Audio test failed!", "Error", MB_OK | MB_ICONERROR);
|
|
|
|
break;
|
2005-07-11 12:24:28 +02:00
|
|
|
case IDC_DSOUND_HW_ACCEL:
|
2011-08-31 22:16:16 +02:00
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE) {
|
|
|
|
int selected_dsound_accel;
|
2009-08-05 15:16:55 +02:00
|
|
|
int i, j = 0;
|
|
|
|
|
2011-08-31 22:16:16 +02:00
|
|
|
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
|
|
|
|
selected_dsound_accel = SendDlgItemMessage(hDlg, IDC_DSOUND_HW_ACCEL, CB_GETCURSEL, 0, 0);
|
2009-08-05 15:16:55 +02:00
|
|
|
for (i = 0; DSound_HW_Accels[i].settingStr; ++i)
|
|
|
|
{
|
|
|
|
if (DSound_HW_Accels[i].visible)
|
|
|
|
{
|
|
|
|
if (j == selected_dsound_accel)
|
|
|
|
{
|
|
|
|
set_reg_key(config_key, keypath("DirectSound"), "HardwareAcceleration",
|
|
|
|
DSound_HW_Accels[i].settingStr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
2011-08-31 22:16:16 +02:00
|
|
|
}
|
|
|
|
break;
|
2006-04-06 02:53:02 +02:00
|
|
|
case IDC_DSOUND_RATES:
|
2011-08-31 22:16:16 +02:00
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE) {
|
|
|
|
int selected_dsound_rate;
|
|
|
|
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
|
|
|
|
selected_dsound_rate = SendDlgItemMessage(hDlg, IDC_DSOUND_RATES, CB_GETCURSEL, 0, 0);
|
|
|
|
set_reg_key(config_key, keypath("DirectSound"), "DefaultSampleRate", DSound_Rates[selected_dsound_rate]);
|
|
|
|
}
|
|
|
|
break;
|
2006-04-06 02:53:02 +02:00
|
|
|
case IDC_DSOUND_BITS:
|
2011-08-31 22:16:16 +02:00
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE) {
|
|
|
|
int selected_dsound_bits;
|
|
|
|
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
|
|
|
|
selected_dsound_bits = SendDlgItemMessage(hDlg, IDC_DSOUND_BITS, CB_GETCURSEL, 0, 0);
|
|
|
|
set_reg_key(config_key, keypath("DirectSound"), "DefaultBitsPerSample", DSound_Bits[selected_dsound_bits]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|