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>
|
|
|
|
|
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
|
|
|
|
|
|
|
#include "winecfg.h"
|
|
|
|
#include "resource.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
|
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
#define DRIVER_MASK 0x80000000
|
|
|
|
#define DEVICE_MASK 0x40000000
|
|
|
|
|
2005-12-07 12:50:52 +01:00
|
|
|
typedef DWORD (WINAPI * MessagePtr)(UINT, UINT, DWORD, DWORD, DWORD);
|
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
static struct DSOUNDACCEL
|
|
|
|
{
|
|
|
|
UINT displayID;
|
|
|
|
const char* settingStr;
|
|
|
|
} const DSound_HW_Accels[] = {
|
|
|
|
{IDS_ACCEL_FULL, "Full"},
|
|
|
|
{IDS_ACCEL_STANDARD, "Standard"},
|
|
|
|
{IDS_ACCEL_BASIC, "Basic"},
|
|
|
|
{IDS_ACCEL_EMULATION, "Emulation"},
|
|
|
|
{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
|
|
|
|
};
|
|
|
|
|
2006-01-19 11:55:01 +01:00
|
|
|
static const AUDIO_DRIVER sAudioDrivers[] = {
|
2006-08-19 05:19:57 +02:00
|
|
|
{IDS_DRIVER_ALSA, "alsa"},
|
|
|
|
{IDS_DRIVER_ESOUND, "esd"},
|
|
|
|
{IDS_DRIVER_OSS, "oss"},
|
|
|
|
{IDS_DRIVER_JACK, "jack"},
|
|
|
|
{IDS_DRIVER_NAS, "nas"},
|
|
|
|
{IDS_DRIVER_AUDIOIO, "audioio"},
|
|
|
|
{IDS_DRIVER_COREAUDIO, "coreaudio"},
|
|
|
|
{0, ""}
|
2006-01-19 11:55:01 +01:00
|
|
|
};
|
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
/* list of available drivers */
|
|
|
|
static AUDIO_DRIVER * loadedAudioDrv;
|
|
|
|
|
|
|
|
/* local copy of registry setting */
|
|
|
|
static char curAudioDriver[1024];
|
|
|
|
|
|
|
|
/* driver index to configure */
|
|
|
|
static int toConfigure;
|
|
|
|
|
|
|
|
/* display a driver specific configuration dialog */
|
|
|
|
static void configureAudioDriver(HWND hDlg)
|
2004-01-20 03:07:35 +01:00
|
|
|
{
|
2005-12-17 12:30:06 +01:00
|
|
|
const AUDIO_DRIVER *pAudioDrv = &loadedAudioDrv[toConfigure];
|
2004-01-20 03:07:35 +01:00
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
if (strlen(pAudioDrv->szDriver) != 0)
|
2004-01-20 03:07:35 +01:00
|
|
|
{
|
2005-12-17 12:30:06 +01:00
|
|
|
HDRVR hdrvr;
|
2006-08-19 05:19:57 +02:00
|
|
|
char wine_driver[MAX_NAME_LENGTH + 9];
|
2005-12-17 12:30:06 +01:00
|
|
|
sprintf(wine_driver, "wine%s.drv", pAudioDrv->szDriver);
|
|
|
|
hdrvr = OpenDriverA(wine_driver, 0, 0);
|
|
|
|
if (hdrvr != 0)
|
|
|
|
{
|
|
|
|
if (SendDriverMessage(hdrvr, DRV_QUERYCONFIGURE, 0, 0) != 0)
|
|
|
|
{
|
|
|
|
DRVCONFIGINFO dci;
|
|
|
|
LONG lRes;
|
|
|
|
dci.dwDCISize = sizeof (dci);
|
|
|
|
dci.lpszDCISectionName = NULL;
|
|
|
|
dci.lpszDCIAliasName = NULL;
|
2006-06-06 07:33:34 +02:00
|
|
|
lRes = SendDriverMessage(hdrvr, DRV_CONFIGURE, 0, (LONG_PTR)&dci);
|
2005-12-17 12:30:06 +01:00
|
|
|
}
|
|
|
|
CloseDriver(hdrvr, 0, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-08-19 05:19:57 +02:00
|
|
|
WCHAR wine_driverW[MAX_NAME_LENGTH+9];
|
|
|
|
WCHAR messageStr[256];
|
|
|
|
WCHAR str[1024];
|
|
|
|
|
|
|
|
MultiByteToWideChar (CP_ACP, 0, wine_driver, -1, wine_driverW,
|
|
|
|
sizeof (wine_driverW)/sizeof(wine_driverW[0]));
|
|
|
|
|
|
|
|
LoadStringW (GetModuleHandle (NULL), IDS_OPEN_DRIVER_ERROR, messageStr,
|
|
|
|
sizeof(messageStr)/sizeof(messageStr[0]));
|
|
|
|
wsprintfW (str, messageStr, wine_driverW);
|
|
|
|
MessageBoxW (hDlg, str, NULL, MB_OK | MB_ICONERROR);
|
2005-12-17 12:30:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* is driver in local copy of driver registry string */
|
|
|
|
static BOOL isDriverSet(const char * driver)
|
|
|
|
{
|
|
|
|
WINE_TRACE("driver = %s, curAudioDriver = %s\n", driver, curAudioDriver);
|
|
|
|
|
|
|
|
if (strstr(curAudioDriver, driver))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add driver to local copy of driver registry string */
|
|
|
|
static void addDriver(const char * driver)
|
|
|
|
{
|
|
|
|
if (!isDriverSet(driver))
|
|
|
|
{
|
|
|
|
if (strlen(curAudioDriver))
|
|
|
|
strcat(curAudioDriver, ",");
|
|
|
|
strcat(curAudioDriver, driver);
|
2004-01-20 03:07:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
/* remove driver from local copy of driver registry string */
|
|
|
|
static void removeDriver(const char * driver)
|
2005-06-28 21:12:52 +02:00
|
|
|
{
|
2005-12-17 12:30:06 +01:00
|
|
|
char before[32], after[32], * start;
|
|
|
|
|
|
|
|
strcpy(before, ",");
|
|
|
|
strcat(before, driver);
|
|
|
|
strcpy(after, driver);
|
|
|
|
strcat(after, ",");
|
2005-06-28 21:12:52 +02:00
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
if ((start = strstr(curAudioDriver, after)))
|
2005-06-28 21:12:52 +02:00
|
|
|
{
|
2005-12-17 12:30:06 +01:00
|
|
|
int len = strlen(after);
|
|
|
|
char * end = curAudioDriver + strlen(curAudioDriver);
|
|
|
|
int i, count = end - start + len;
|
|
|
|
for (i = 0; i < count; i++)
|
2005-06-28 21:12:52 +02:00
|
|
|
{
|
2005-12-17 12:30:06 +01:00
|
|
|
if (start + len >= end)
|
|
|
|
*start = 0;
|
|
|
|
else
|
|
|
|
*start = start[len];
|
|
|
|
start++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((start = strstr(curAudioDriver, before)))
|
|
|
|
{
|
|
|
|
int len = strlen(before);
|
|
|
|
char * end = curAudioDriver + strlen(curAudioDriver);
|
|
|
|
int i, count = end - start + len;
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (start + len >= end)
|
|
|
|
*start = 0;
|
|
|
|
else
|
|
|
|
*start = start[len];
|
|
|
|
start++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp(curAudioDriver, driver) == 0)
|
|
|
|
{
|
|
|
|
strcpy(curAudioDriver, "");
|
2005-06-28 21:12:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-07 12:50:52 +01:00
|
|
|
static void initAudioDeviceTree(HWND hDlg)
|
|
|
|
{
|
|
|
|
const AUDIO_DRIVER *pAudioDrv = NULL;
|
|
|
|
int i, j;
|
2006-08-19 05:19:57 +02:00
|
|
|
TVINSERTSTRUCTW insert;
|
2005-12-07 12:50:52 +01:00
|
|
|
HTREEITEM root, driver[10];
|
|
|
|
HWND tree = NULL;
|
2005-12-17 12:30:06 +01:00
|
|
|
HIMAGELIST hImageList;
|
|
|
|
HBITMAP hBitMap;
|
2005-12-26 12:55:40 +01:00
|
|
|
HCURSOR old_cursor;
|
2006-08-19 05:19:57 +02:00
|
|
|
WCHAR driver_type[64], dev_type[64];
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
tree = GetDlgItem(hDlg, IDC_AUDIO_TREE);
|
|
|
|
|
|
|
|
if (!tree)
|
|
|
|
return;
|
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
/* set tree view style */
|
2005-12-07 12:50:52 +01:00
|
|
|
SetWindowLong(tree, GWL_STYLE, GetWindowLong(tree, GWL_STYLE) | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT);
|
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
/* state checkbox */
|
|
|
|
hImageList = ImageList_Create(16, 16, FALSE, 3, 0);
|
|
|
|
hBitMap = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_CHECKBOX));
|
|
|
|
ImageList_Add(hImageList, hBitMap, NULL);
|
|
|
|
DeleteObject(hBitMap);
|
2006-03-04 16:58:44 +01:00
|
|
|
SendMessageW( tree, TVM_SETIMAGELIST, TVSIL_STATE, (LPARAM)hImageList );
|
2005-12-17 12:30:06 +01:00
|
|
|
|
|
|
|
/* root item */
|
2006-08-19 05:19:57 +02:00
|
|
|
LoadStringW (GetModuleHandle (NULL), IDS_SOUNDDRIVERS, driver_type,
|
|
|
|
sizeof(driver_type)/sizeof(driver_type[0]));
|
2005-12-07 12:50:52 +01:00
|
|
|
insert.hParent = TVI_ROOT;
|
|
|
|
insert.hInsertAfter = TVI_LAST;
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN;
|
2006-08-19 05:19:57 +02:00
|
|
|
insert.u.item.pszText = driver_type;
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.cChildren = 1;
|
2006-08-19 05:19:57 +02:00
|
|
|
root = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2005-12-26 12:55:40 +01:00
|
|
|
/* change to the wait cursor because this can take a while if there is a
|
|
|
|
* misbehaving driver that takes a long time to open
|
|
|
|
*/
|
|
|
|
old_cursor = SetCursor(LoadCursor(0, IDC_WAIT));
|
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
/* iterate over list of loaded drivers */
|
2006-08-19 05:19:57 +02:00
|
|
|
for (pAudioDrv = loadedAudioDrv, i = 0; pAudioDrv->nameID; i++, pAudioDrv++) {
|
2005-12-07 12:50:52 +01:00
|
|
|
HDRVR hdrv;
|
|
|
|
char name[MAX_PATH];
|
2006-08-19 05:19:57 +02:00
|
|
|
WCHAR text[MAX_PATH];
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
sprintf(name, "wine%s.drv", pAudioDrv->szDriver);
|
2006-08-19 05:19:57 +02:00
|
|
|
LoadStringW (GetModuleHandle (NULL), pAudioDrv->nameID, text,
|
|
|
|
sizeof(text)/sizeof(text[0]));
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
if ((hdrv = OpenDriverA(name, 0, 0)))
|
2005-12-07 12:50:52 +01:00
|
|
|
{
|
2005-12-13 11:12:24 +01:00
|
|
|
HMODULE lib;
|
|
|
|
if ((lib = GetDriverModuleHandle(hdrv)))
|
2005-12-07 12:50:52 +01:00
|
|
|
{
|
|
|
|
int num_wod = 0, num_wid = 0, num_mod = 0, num_mid = 0, num_aux = 0, num_mxd = 0;
|
|
|
|
MessagePtr wodMessagePtr = (MessagePtr)GetProcAddress(lib, "wodMessage");
|
|
|
|
MessagePtr widMessagePtr = (MessagePtr)GetProcAddress(lib, "widMessage");
|
|
|
|
MessagePtr modMessagePtr = (MessagePtr)GetProcAddress(lib, "modMessage");
|
|
|
|
MessagePtr midMessagePtr = (MessagePtr)GetProcAddress(lib, "midMessage");
|
|
|
|
MessagePtr auxMessagePtr = (MessagePtr)GetProcAddress(lib, "auxMessage");
|
|
|
|
MessagePtr mxdMessagePtr = (MessagePtr)GetProcAddress(lib, "mxdMessage");
|
|
|
|
|
|
|
|
if (wodMessagePtr)
|
|
|
|
num_wod = wodMessagePtr(0, WODM_GETNUMDEVS, 0, 0, 0);
|
|
|
|
|
|
|
|
if (widMessagePtr)
|
|
|
|
num_wid = widMessagePtr(0, WIDM_GETNUMDEVS, 0, 0, 0);
|
|
|
|
|
|
|
|
if (modMessagePtr)
|
|
|
|
num_mod = modMessagePtr(0, MODM_GETNUMDEVS, 0, 0, 0);
|
|
|
|
|
|
|
|
if (midMessagePtr)
|
|
|
|
num_mid = midMessagePtr(0, MIDM_GETNUMDEVS, 0, 0, 0);
|
|
|
|
|
|
|
|
if (auxMessagePtr)
|
|
|
|
num_aux = auxMessagePtr(0, AUXDM_GETNUMDEVS, 0, 0, 0);
|
|
|
|
|
|
|
|
if (mxdMessagePtr)
|
|
|
|
num_mxd = mxdMessagePtr(0, MXDM_GETNUMDEVS, 0, 0, 0);
|
|
|
|
|
|
|
|
if (num_wod == 0 && num_wid == 0 && num_mod == 0 && num_mid == 0 && num_aux == 0 && num_mxd == 0)
|
|
|
|
{
|
|
|
|
insert.hParent = root;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.pszText = text;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.stateMask = TVIS_STATEIMAGEMASK;
|
|
|
|
insert.u.item.lParam = i + DRIVER_MASK;
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
driver[i] = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HTREEITEM type;
|
|
|
|
|
|
|
|
insert.hParent = root;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN | TVIF_STATE | TVIF_PARAM;
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.pszText = text;
|
|
|
|
insert.u.item.cChildren = 1;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.stateMask = TVIS_STATEIMAGEMASK;
|
|
|
|
insert.u.item.lParam = i + DRIVER_MASK;
|
|
|
|
|
|
|
|
if (isDriverSet(pAudioDrv->szDriver))
|
|
|
|
insert.u.item.state = INDEXTOSTATEIMAGEMASK(2);
|
|
|
|
else
|
|
|
|
insert.u.item.state = INDEXTOSTATEIMAGEMASK(1);
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
driver[i] = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
if (num_wod)
|
|
|
|
{
|
2006-08-19 05:19:57 +02:00
|
|
|
LoadStringW (GetModuleHandle (NULL), IDS_DEVICES_WAVEOUT, dev_type,
|
|
|
|
sizeof(dev_type)/sizeof(dev_type[0]));
|
2006-07-07 20:42:27 +02:00
|
|
|
|
2005-12-07 12:50:52 +01:00
|
|
|
insert.hParent = driver[i];
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN;
|
2006-08-19 05:19:57 +02:00
|
|
|
insert.u.item.pszText = dev_type;
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.cChildren = 1;
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
type = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
for (j = 0; j < num_wod; j++)
|
|
|
|
{
|
|
|
|
WAVEOUTCAPSW caps;
|
|
|
|
|
2006-06-06 07:33:34 +02:00
|
|
|
wodMessagePtr(j, WODM_GETDEVCAPS, 0, (DWORD_PTR)&caps, sizeof(caps));
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
insert.hParent = type;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_PARAM;
|
2006-08-19 05:19:57 +02:00
|
|
|
insert.u.item.pszText = caps.szPname;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.lParam = j + DEVICE_MASK;
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_wid)
|
|
|
|
{
|
2006-08-19 05:19:57 +02:00
|
|
|
LoadStringW (GetModuleHandle (NULL), IDS_DEVICES_WAVEIN, dev_type,
|
|
|
|
sizeof(dev_type)/sizeof(dev_type[0]));
|
2006-07-07 20:42:27 +02:00
|
|
|
|
2005-12-07 12:50:52 +01:00
|
|
|
insert.hParent = driver[i];
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN;
|
2006-08-19 05:19:57 +02:00
|
|
|
insert.u.item.pszText = dev_type;
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.cChildren = 1;
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
type = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
for (j = 0; j < num_wid; j++)
|
|
|
|
{
|
|
|
|
WAVEINCAPSW caps;
|
|
|
|
|
2006-06-06 07:33:34 +02:00
|
|
|
widMessagePtr(j, WIDM_GETDEVCAPS, 0, (DWORD_PTR)&caps, sizeof(caps));
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
insert.hParent = type;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_PARAM;
|
2006-08-19 05:19:57 +02:00
|
|
|
insert.u.item.pszText = caps.szPname;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.lParam = j + DEVICE_MASK;
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_mod)
|
|
|
|
{
|
2006-08-19 05:19:57 +02:00
|
|
|
LoadStringW (GetModuleHandle (NULL), IDS_DEVICES_MIDIOUT, dev_type,
|
|
|
|
sizeof(dev_type)/sizeof(dev_type[0]));
|
2006-07-07 20:42:27 +02:00
|
|
|
|
2005-12-07 12:50:52 +01:00
|
|
|
insert.hParent = driver[i];
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN;
|
2006-08-19 05:19:57 +02:00
|
|
|
insert.u.item.pszText = dev_type;
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.cChildren = 1;
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
type = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
for (j = 0; j < num_mod; j++)
|
|
|
|
{
|
|
|
|
MIDIOUTCAPSW caps;
|
|
|
|
|
2006-06-06 07:33:34 +02:00
|
|
|
modMessagePtr(j, MODM_GETDEVCAPS, 0, (DWORD_PTR)&caps, sizeof(caps));
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
insert.hParent = type;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_PARAM;
|
2006-08-19 05:19:57 +02:00
|
|
|
insert.u.item.pszText = caps.szPname;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.lParam = j + DEVICE_MASK;
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_mid)
|
|
|
|
{
|
2006-08-19 05:19:57 +02:00
|
|
|
LoadStringW (GetModuleHandle (NULL), IDS_DEVICES_MIDIIN, dev_type,
|
|
|
|
sizeof(dev_type)/sizeof(dev_type[0]));
|
2006-07-07 20:42:27 +02:00
|
|
|
|
2005-12-07 12:50:52 +01:00
|
|
|
insert.hParent = driver[i];
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN;
|
2006-08-19 05:19:57 +02:00
|
|
|
insert.u.item.pszText = dev_type;
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.cChildren = 1;
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
type = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
for (j = 0; j < num_mid; j++)
|
|
|
|
{
|
|
|
|
MIDIINCAPSW caps;
|
|
|
|
|
2006-06-06 07:33:34 +02:00
|
|
|
midMessagePtr(j, MIDM_GETDEVCAPS, 0, (DWORD_PTR)&caps, sizeof(caps));
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
insert.hParent = type;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_PARAM;
|
2006-08-19 05:19:57 +02:00
|
|
|
insert.u.item.pszText = caps.szPname;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.lParam = j + DEVICE_MASK;
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_aux)
|
|
|
|
{
|
2006-08-19 05:19:57 +02:00
|
|
|
LoadStringW (GetModuleHandle (NULL), IDS_DEVICES_AUX, dev_type,
|
|
|
|
sizeof(dev_type)/sizeof(dev_type[0]));
|
2006-07-07 20:42:27 +02:00
|
|
|
|
2005-12-07 12:50:52 +01:00
|
|
|
insert.hParent = driver[i];
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN;
|
2006-08-19 05:19:57 +02:00
|
|
|
insert.u.item.pszText = dev_type;
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.cChildren = 1;
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
type = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
for (j = 0; j < num_aux; j++)
|
|
|
|
{
|
|
|
|
AUXCAPSW caps;
|
|
|
|
|
2006-06-06 07:33:34 +02:00
|
|
|
auxMessagePtr(j, AUXDM_GETDEVCAPS, 0, (DWORD_PTR)&caps, sizeof(caps));
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
insert.hParent = type;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_PARAM;
|
2006-08-19 05:19:57 +02:00
|
|
|
insert.u.item.pszText = caps.szPname;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.lParam = j + DEVICE_MASK;
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_mxd)
|
|
|
|
{
|
2006-08-19 05:19:57 +02:00
|
|
|
LoadStringW (GetModuleHandle (NULL), IDS_DEVICES_MIXER, dev_type,
|
|
|
|
sizeof(dev_type)/sizeof(dev_type[0]));
|
2006-07-07 20:42:27 +02:00
|
|
|
|
2005-12-07 12:50:52 +01:00
|
|
|
insert.hParent = driver[i];
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_CHILDREN;
|
2006-08-19 05:19:57 +02:00
|
|
|
insert.u.item.pszText = dev_type;
|
2005-12-08 11:57:44 +01:00
|
|
|
insert.u.item.cChildren = 1;
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
type = (HTREEITEM)SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
for (j = 0; j < num_mxd; j++)
|
|
|
|
{
|
|
|
|
MIXERCAPSW caps;
|
|
|
|
|
2006-06-06 07:33:34 +02:00
|
|
|
mxdMessagePtr(j, MXDM_GETDEVCAPS, 0, (DWORD_PTR)&caps, sizeof(caps));
|
2005-12-07 12:50:52 +01:00
|
|
|
|
|
|
|
insert.hParent = type;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.mask = TVIF_TEXT | TVIF_PARAM;
|
2006-08-19 05:19:57 +02:00
|
|
|
insert.u.item.pszText = caps.szPname;
|
2005-12-17 12:30:06 +01:00
|
|
|
insert.u.item.lParam = j + DEVICE_MASK;
|
2005-12-07 12:50:52 +01:00
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
SendDlgItemMessageW (hDlg, IDC_AUDIO_TREE, TVM_INSERTITEMW, 0, (LPARAM)&insert);
|
2005-12-07 12:50:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-04-12 00:32:30 +02:00
|
|
|
CloseDriver(hdrv, 0, 0);
|
2005-12-07 12:50:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-26 12:55:40 +01:00
|
|
|
/* restore the original cursor */
|
|
|
|
SetCursor(old_cursor);
|
|
|
|
|
2005-12-07 12:50:52 +01:00
|
|
|
SendDlgItemMessage(hDlg, IDC_AUDIO_TREE, TVM_SELECTITEM, 0, 0);
|
|
|
|
SendDlgItemMessage(hDlg, IDC_AUDIO_TREE, TVM_EXPAND, TVE_EXPAND, (LPARAM)root);
|
|
|
|
for (j = 0; j < i; j++)
|
|
|
|
SendDlgItemMessage(hDlg, IDC_AUDIO_TREE, TVM_EXPAND, TVE_EXPAND, (LPARAM)driver[j]);
|
|
|
|
}
|
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
/* find all drivers that can be loaded */
|
|
|
|
static void findAudioDrivers(void)
|
2004-01-20 03:07:35 +01:00
|
|
|
{
|
2005-12-17 12:30:06 +01:00
|
|
|
int numFound = 0;
|
2005-01-14 20:48:41 +01:00
|
|
|
const AUDIO_DRIVER *pAudioDrv = NULL;
|
2005-12-26 12:55:40 +01:00
|
|
|
HCURSOR old_cursor;
|
2005-12-17 12:30:06 +01:00
|
|
|
|
|
|
|
/* delete an existing list */
|
2006-05-10 00:33:53 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, loadedAudioDrv);
|
|
|
|
loadedAudioDrv = 0;
|
2005-12-17 12:30:06 +01:00
|
|
|
|
2005-12-26 12:55:40 +01:00
|
|
|
/* change to the wait cursor because this can take a while if there is a
|
|
|
|
* misbehaving driver that takes a long time to open
|
|
|
|
*/
|
|
|
|
old_cursor = SetCursor(LoadCursor(0, IDC_WAIT));
|
|
|
|
|
2006-08-19 05:19:57 +02:00
|
|
|
for (pAudioDrv = sAudioDrivers; pAudioDrv->nameID; pAudioDrv++)
|
2005-12-17 12:30:06 +01:00
|
|
|
{
|
|
|
|
if (strlen(pAudioDrv->szDriver))
|
|
|
|
{
|
|
|
|
HDRVR hdrv;
|
|
|
|
char driver[MAX_PATH];
|
|
|
|
|
|
|
|
sprintf(driver, "wine%s.drv", pAudioDrv->szDriver);
|
|
|
|
|
|
|
|
if ((hdrv = OpenDriverA(driver, 0, 0)))
|
|
|
|
{
|
|
|
|
CloseDriver(hdrv, 0, 0);
|
|
|
|
|
|
|
|
if (loadedAudioDrv)
|
|
|
|
loadedAudioDrv = HeapReAlloc(GetProcessHeap(), 0, loadedAudioDrv, (numFound + 1) * sizeof(AUDIO_DRIVER));
|
|
|
|
else
|
|
|
|
loadedAudioDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(AUDIO_DRIVER));
|
|
|
|
|
|
|
|
CopyMemory(&loadedAudioDrv[numFound], pAudioDrv, sizeof(AUDIO_DRIVER));
|
|
|
|
numFound++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-26 12:55:40 +01:00
|
|
|
/* restore the original cursor */
|
|
|
|
SetCursor(old_cursor);
|
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
/* terminate list with empty driver */
|
2006-05-08 05:28:40 +02:00
|
|
|
if (numFound) {
|
|
|
|
loadedAudioDrv = HeapReAlloc(GetProcessHeap(), 0, loadedAudioDrv, (numFound + 1) * sizeof(AUDIO_DRIVER));
|
|
|
|
CopyMemory(&loadedAudioDrv[numFound], pAudioDrv, sizeof(AUDIO_DRIVER));
|
|
|
|
} else {
|
|
|
|
loadedAudioDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(AUDIO_DRIVER));
|
|
|
|
ZeroMemory(&loadedAudioDrv[0], sizeof(AUDIO_DRIVER));
|
|
|
|
}
|
2005-12-17 12:30:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check local copy of registry string for unloadable drivers */
|
|
|
|
static void checkRegistrySetting(HWND hDlg)
|
|
|
|
{
|
|
|
|
const AUDIO_DRIVER *pAudioDrv;
|
|
|
|
char * token, * tokens = strdup(curAudioDriver);
|
|
|
|
|
|
|
|
start_over:
|
|
|
|
token = strtok(tokens, ",");
|
|
|
|
while (token != NULL)
|
|
|
|
{
|
|
|
|
BOOL found = FALSE;
|
2006-08-19 05:19:57 +02:00
|
|
|
for (pAudioDrv = loadedAudioDrv; pAudioDrv->nameID; pAudioDrv++)
|
2005-12-17 12:30:06 +01:00
|
|
|
{
|
|
|
|
if (strcmp(token, pAudioDrv->szDriver) == 0)
|
|
|
|
{
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (found == FALSE)
|
|
|
|
{
|
2006-08-19 05:19:57 +02:00
|
|
|
WCHAR tokenW[MAX_NAME_LENGTH+1];
|
|
|
|
WCHAR messageStr[256];
|
|
|
|
WCHAR str[1024];
|
|
|
|
WCHAR caption[64];
|
|
|
|
|
|
|
|
MultiByteToWideChar (CP_ACP, 0, token, -1, tokenW, sizeof(tokenW)/sizeof(tokenW[0]));
|
|
|
|
|
|
|
|
LoadStringW (GetModuleHandle (NULL), IDS_UNAVAILABLE_DRIVER, messageStr,
|
|
|
|
sizeof(messageStr)/sizeof(messageStr[0]));
|
|
|
|
wsprintfW (str, messageStr, tokenW);
|
|
|
|
LoadStringW (GetModuleHandle (NULL), IDS_WARNING, caption,
|
|
|
|
sizeof(caption)/sizeof(caption[0]));
|
|
|
|
if (MessageBoxW (hDlg, str, caption, MB_ICONWARNING | MB_YESNOCANCEL) == IDYES)
|
2005-12-17 12:30:06 +01:00
|
|
|
{
|
|
|
|
removeDriver(token);
|
|
|
|
strcpy(tokens, curAudioDriver);
|
|
|
|
goto start_over;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
token = strtok(NULL, ",");
|
|
|
|
}
|
|
|
|
free(tokens);
|
|
|
|
}
|
|
|
|
|
2005-12-21 20:07:56 +01:00
|
|
|
static void selectDriver(HWND hDlg, const char * driver)
|
|
|
|
{
|
|
|
|
WCHAR text[1024];
|
|
|
|
WCHAR caption[64];
|
|
|
|
|
|
|
|
strcpy(curAudioDriver, driver);
|
|
|
|
set_reg_key(config_key, "Drivers", "Audio", curAudioDriver);
|
|
|
|
|
|
|
|
if (LoadStringW(GetModuleHandle(NULL), IDS_AUDIO_MISSING, text, sizeof(text)/sizeof(text[0])))
|
|
|
|
{
|
|
|
|
if (LoadStringW(GetModuleHandle(NULL), IDS_WINECFG_TITLE, caption, sizeof(caption)/sizeof(caption[0])))
|
|
|
|
MessageBoxW(hDlg, text, caption, MB_OK | MB_ICONINFORMATION);
|
|
|
|
}
|
|
|
|
|
|
|
|
SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM) hDlg, 0); /* enable apply button */
|
|
|
|
}
|
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
static void initAudioDlg (HWND hDlg)
|
|
|
|
{
|
2005-01-14 20:48:41 +01:00
|
|
|
int i;
|
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-12-17 12:30:06 +01:00
|
|
|
/* make a list of all drivers that can be loaded */
|
|
|
|
findAudioDrivers();
|
|
|
|
|
2005-12-21 20:07:56 +01:00
|
|
|
/* get current registry setting if available */
|
|
|
|
buf = get_reg_key(config_key, "Drivers", "Audio", NULL);
|
|
|
|
|
|
|
|
/* check for first time install and set a default driver
|
|
|
|
* select in this order: oss, alsa, first available driver, none
|
|
|
|
*/
|
|
|
|
if (buf == NULL)
|
|
|
|
{
|
|
|
|
const AUDIO_DRIVER *pAudioDrv = NULL;
|
|
|
|
|
|
|
|
/* select oss if available */
|
2006-08-19 05:19:57 +02:00
|
|
|
for (pAudioDrv = loadedAudioDrv; pAudioDrv->nameID; pAudioDrv++)
|
2005-12-21 20:07:56 +01:00
|
|
|
{
|
|
|
|
if (strcmp(pAudioDrv->szDriver, "oss") == 0)
|
|
|
|
{
|
|
|
|
selectDriver(hDlg, "oss");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(curAudioDriver) == 0)
|
|
|
|
{
|
|
|
|
/* select alsa if available */
|
2006-08-19 05:19:57 +02:00
|
|
|
for (pAudioDrv = loadedAudioDrv; pAudioDrv->nameID; pAudioDrv++)
|
2005-12-21 20:07:56 +01:00
|
|
|
{
|
|
|
|
if (strcmp(pAudioDrv->szDriver, "alsa") == 0)
|
|
|
|
{
|
|
|
|
selectDriver(hDlg, "alsa");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(curAudioDriver) == 0)
|
|
|
|
{
|
|
|
|
/* select first available driver */
|
|
|
|
if (*loadedAudioDrv->szDriver)
|
|
|
|
selectDriver(hDlg, loadedAudioDrv->szDriver);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* make a local copy of the current registry setting */
|
|
|
|
strcpy(curAudioDriver, buf);
|
|
|
|
|
|
|
|
WINE_TRACE("curAudioDriver = %s\n", curAudioDriver);
|
|
|
|
|
2005-12-17 12:30:06 +01:00
|
|
|
/* check for drivers that can't be loaded */
|
|
|
|
checkRegistrySetting(hDlg);
|
2005-07-11 12:24:28 +02:00
|
|
|
|
2005-12-07 12:50:52 +01:00
|
|
|
initAudioDeviceTree(hDlg);
|
2005-07-11 12:24:28 +02:00
|
|
|
|
|
|
|
SendDlgItemMessage(hDlg, IDC_DSOUND_HW_ACCEL, CB_RESETCONTENT, 0, 0);
|
2006-08-19 05:19:57 +02:00
|
|
|
for (i = 0; 0 != DSound_HW_Accels[i].displayID; ++i) {
|
|
|
|
WCHAR accelStr[64];
|
|
|
|
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);
|
2005-12-17 12:30:06 +01:00
|
|
|
}
|
|
|
|
buf = get_reg_key(config_key, keypath("DirectSound"), "HardwareAcceleration", "Full");
|
2006-08-19 05:19:57 +02:00
|
|
|
for (i = 0; NULL != DSound_HW_Accels[i].settingStr; ++i) {
|
|
|
|
if (strcmp(buf, DSound_HW_Accels[i].settingStr) == 0) {
|
2005-07-11 12:24:28 +02:00
|
|
|
SendDlgItemMessage(hDlg, IDC_DSOUND_HW_ACCEL, CB_SETCURSEL, i, 0);
|
|
|
|
break ;
|
|
|
|
}
|
|
|
|
}
|
2006-08-19 05:19:57 +02:00
|
|
|
if (NULL == DSound_HW_Accels[i].settingStr) {
|
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
|
|
|
buf = get_reg_key(config_key, keypath("DirectSound"), "EmulDriver", "N");
|
|
|
|
if (IS_OPTION_TRUE(*buf))
|
|
|
|
CheckDlgButton(hDlg, IDC_DSOUND_DRV_EMUL, BST_CHECKED);
|
|
|
|
else
|
|
|
|
CheckDlgButton(hDlg, IDC_DSOUND_DRV_EMUL, BST_UNCHECKED);
|
|
|
|
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:
|
|
|
|
switch (LOWORD(wParam)) {
|
2005-06-28 21:12:52 +02:00
|
|
|
case IDC_AUDIO_CONFIGURE:
|
2005-12-17 12:30:06 +01:00
|
|
|
configureAudioDriver(hDlg);
|
2005-06-28 21:12:52 +02:00
|
|
|
break;
|
2007-04-03 22:09:02 +02:00
|
|
|
case IDC_AUDIO_TEST:
|
|
|
|
MessageBox(NULL, "Audio Test not implemented yet!", "Fixme", MB_OK | MB_ICONERROR);
|
|
|
|
break;
|
2005-06-28 21:12:52 +02:00
|
|
|
case IDC_AUDIO_CONTROL_PANEL:
|
|
|
|
MessageBox(NULL, "Launching audio control panel not implemented yet!", "Fixme", MB_OK | MB_ICONERROR);
|
|
|
|
break;
|
2005-07-11 12:24:28 +02:00
|
|
|
case IDC_DSOUND_HW_ACCEL:
|
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE) {
|
|
|
|
int selected_dsound_accel;
|
|
|
|
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
|
|
|
|
selected_dsound_accel = SendDlgItemMessage(hDlg, IDC_DSOUND_HW_ACCEL, CB_GETCURSEL, 0, 0);
|
2006-08-19 05:19:57 +02:00
|
|
|
set_reg_key(config_key, keypath("DirectSound"), "HardwareAcceleration",
|
|
|
|
DSound_HW_Accels[selected_dsound_accel].settingStr);
|
2005-07-11 12:24:28 +02:00
|
|
|
}
|
|
|
|
break;
|
2006-04-06 02:53:02 +02:00
|
|
|
case IDC_DSOUND_RATES:
|
|
|
|
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;
|
|
|
|
case IDC_DSOUND_BITS:
|
|
|
|
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;
|
2005-07-11 12:24:28 +02:00
|
|
|
case IDC_DSOUND_DRV_EMUL:
|
|
|
|
if (HIWORD(wParam) == BN_CLICKED) {
|
2005-12-17 12:30:06 +01:00
|
|
|
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
|
2005-07-11 12:24:28 +02:00
|
|
|
if (IsDlgButtonChecked(hDlg, IDC_DSOUND_DRV_EMUL) == BST_CHECKED)
|
|
|
|
set_reg_key(config_key, keypath("DirectSound"), "EmulDriver", "Y");
|
|
|
|
else
|
|
|
|
set_reg_key(config_key, keypath("DirectSound"), "EmulDriver", "N");
|
|
|
|
}
|
|
|
|
break;
|
2004-01-20 03:07:35 +01: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:
|
|
|
|
switch(((LPNMHDR)lParam)->code) {
|
|
|
|
case PSN_KILLACTIVE:
|
2005-02-15 22:51:06 +01:00
|
|
|
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
|
2004-01-20 03:07:35 +01:00
|
|
|
break;
|
|
|
|
case PSN_APPLY:
|
2005-12-17 12:30:06 +01:00
|
|
|
set_reg_key(config_key, "Drivers", "Audio", curAudioDriver);
|
2004-09-28 05:55:16 +02:00
|
|
|
apply();
|
2005-02-15 22:51:06 +01:00
|
|
|
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
|
2004-01-20 03:07:35 +01:00
|
|
|
break;
|
|
|
|
case PSN_SETACTIVE:
|
|
|
|
break;
|
2005-12-17 12:30:06 +01:00
|
|
|
case NM_CLICK:
|
|
|
|
if (((LPNMHDR)lParam)->idFrom == IDC_AUDIO_TREE)
|
|
|
|
{
|
|
|
|
TVHITTESTINFO ht;
|
|
|
|
DWORD dwPos = GetMessagePos();
|
|
|
|
HWND tree = ((LPNMHDR)lParam)->hwndFrom;
|
|
|
|
ZeroMemory(&ht, sizeof(ht));
|
2006-03-17 15:26:20 +01:00
|
|
|
ht.pt.x = (short)LOWORD(dwPos);
|
|
|
|
ht.pt.y = (short)HIWORD(dwPos);
|
2005-12-17 12:30:06 +01:00
|
|
|
MapWindowPoints(HWND_DESKTOP, tree, &ht.pt, 1);
|
2006-03-03 04:32:00 +01:00
|
|
|
SendMessageW( tree, TVM_HITTEST, 0, (LPARAM)&ht );
|
2005-12-17 12:30:06 +01:00
|
|
|
if (TVHT_ONITEMSTATEICON & ht.flags)
|
|
|
|
{
|
|
|
|
TVITEM tvItem;
|
|
|
|
int index;
|
|
|
|
ZeroMemory(&tvItem, sizeof(tvItem));
|
|
|
|
tvItem.hItem = ht.hItem;
|
2006-03-03 04:32:00 +01:00
|
|
|
SendMessageW( tree, TVM_GETITEMW, 0, (LPARAM) &tvItem );
|
2005-12-17 12:30:06 +01:00
|
|
|
|
|
|
|
index = TreeView_GetItemState(tree, ht.hItem, TVIS_STATEIMAGEMASK);
|
|
|
|
if (index == INDEXTOSTATEIMAGEMASK(1))
|
|
|
|
{
|
|
|
|
TreeView_SetItemState(tree, ht.hItem, INDEXTOSTATEIMAGEMASK(2), TVIS_STATEIMAGEMASK);
|
|
|
|
addDriver(loadedAudioDrv[tvItem.lParam & 0xff].szDriver);
|
|
|
|
SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM) hDlg, 0); /* enable apply button */
|
|
|
|
}
|
|
|
|
else if (index == INDEXTOSTATEIMAGEMASK(2))
|
|
|
|
{
|
|
|
|
TreeView_SetItemState(tree, ht.hItem, INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK);
|
|
|
|
removeDriver(loadedAudioDrv[tvItem.lParam & 0xff].szDriver);
|
|
|
|
SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM) hDlg, 0); /* enable apply button */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NM_RCLICK:
|
|
|
|
if (((LPNMHDR)lParam)->idFrom == IDC_AUDIO_TREE)
|
|
|
|
{
|
|
|
|
TVHITTESTINFO ht;
|
|
|
|
DWORD dwPos = GetMessagePos();
|
|
|
|
HWND tree = ((LPNMHDR)lParam)->hwndFrom;
|
|
|
|
POINT pt;
|
|
|
|
ZeroMemory(&ht, sizeof(ht));
|
2006-03-17 15:26:20 +01:00
|
|
|
pt.x = (short)LOWORD(dwPos);
|
|
|
|
pt.y = (short)HIWORD(dwPos);
|
2005-12-17 12:30:06 +01:00
|
|
|
ht.pt = pt;
|
|
|
|
MapWindowPoints(HWND_DESKTOP, tree, &ht.pt, 1);
|
2006-03-03 04:32:00 +01:00
|
|
|
SendMessageW( tree, TVM_HITTEST, 0, (LPARAM)&ht );
|
2005-12-17 12:30:06 +01:00
|
|
|
if (TVHT_ONITEMLABEL & ht.flags)
|
|
|
|
{
|
|
|
|
TVITEM tvItem;
|
|
|
|
ZeroMemory(&tvItem, sizeof(tvItem));
|
|
|
|
tvItem.hItem = ht.hItem;
|
|
|
|
tvItem.mask = TVIF_PARAM;
|
|
|
|
tvItem.lParam = -1;
|
|
|
|
if (TreeView_GetItem(tree, &tvItem))
|
|
|
|
{
|
|
|
|
if (tvItem.lParam & DRIVER_MASK)
|
|
|
|
{
|
|
|
|
if (hPopupMenus)
|
|
|
|
{
|
|
|
|
TrackPopupMenu(GetSubMenu(hPopupMenus, 0), TPM_RIGHTBUTTON, pt.x, pt.y, 0, tree, NULL);
|
|
|
|
toConfigure = tvItem.lParam & ~DRIVER_MASK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (tvItem.lParam & DEVICE_MASK)
|
|
|
|
{
|
|
|
|
/* FIXME TBD */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-01-20 03:07:35 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
initAudioDlg(hDlg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|