Add audio tab with first pass at autodetection of audio driver.

Double clicking a drive entry brings up drive edit window.
This commit is contained in:
Chris Morgan 2004-01-20 02:07:35 +00:00 committed by Alexandre Julliard
parent e14a1b262a
commit cde7f90903
9 changed files with 262 additions and 12 deletions

View File

@ -89,7 +89,6 @@ BEGIN
EDITTEXT IDC_DESKTOP_WIDTH,64,115,40,12,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED
EDITTEXT IDC_DESKTOP_HEIGHT,117,115,40,12,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED
END
IDD_DLLCFG DIALOG DISCARDABLE 0, 0, 260, 250
@ -173,10 +172,18 @@ BEGIN
CONTROL "Manually Assign:",IDC_RADIO_ASSIGN,"Button",
BS_AUTORADIOBUTTON,21,104,69,10
GROUPBOX "Label and Serial Number",IDC_BOX_LABELSERIAL,6,68,189,79
END
STRINGTABLE DISCARDABLE
IDD_AUDIOCFG DIALOG DISCARDABLE 0, 0, 260, 250
STYLE WS_CHILD | WS_DISABLED
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Audio driver: ",IDC_STATIC,10,20,60,8
COMBOBOX IDC_AUDIO_DRIVER,70,18,85,85,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Autodetect",IDC_AUDIO_AUTODETECT,170,15,45,18
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_WINE_VERSION "CVS"
IDS_TAB_GENERAL "General"

View File

@ -8,6 +8,7 @@ IMPORTS = comdlg32 comctl32 user32 advapi32
C_SRCS = \
appdefaults.c \
audio.c \
drive.c \
libraries.c \
main.c \

198
programs/winecfg/audio.c Normal file
View File

@ -0,0 +1,198 @@
/*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <wine/debug.h>
#include <shellapi.h>
#include <objbase.h>
#include <shlguid.h>
#include <shlwapi.h>
#include <shlobj.h>
#include "winecfg.h"
#include "resource.h"
WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
/* Select the correct entry in the combobox based on drivername */
void selectAudioDriver(HWND hDlg, char *drivername)
{
int i;
const AUDIO_DRIVER *pAudioDrv = NULL;
if ((pAudioDrv = getAudioDrivers()))
{
for (i = 0; *pAudioDrv->szName; i++, pAudioDrv++)
{
if (!strcmp (pAudioDrv->szDriver, drivername))
{
addTransaction("Winmm", "Drivers", ACTION_SET, pAudioDrv->szDriver);
SendDlgItemMessage(hDlg, IDC_AUDIO_DRIVER, CB_SETCURSEL,
(WPARAM) i, 0);
}
}
}
}
void
initAudioDlg (HWND hDlg)
{
char *curAudioDriver = getConfigValue("Winmm", "Drivers", "winealsa.drv");
const AUDIO_DRIVER *pAudioDrv = NULL;
int i;
if ((pAudioDrv = getAudioDrivers ()))
{
for (i = 0; *pAudioDrv->szName; i++, pAudioDrv++)
{
SendDlgItemMessage (hDlg, IDC_AUDIO_DRIVER, CB_ADDSTRING,
0, (LPARAM) pAudioDrv->szName);
if (!strcmp (pAudioDrv->szDriver, curAudioDriver))
selectAudioDriver(hDlg, (char*)pAudioDrv->szDriver);
}
}
}
char *audioAutoDetect(void)
{
struct stat buf;
const char *argv_new[4];
int fd;
char *driversFound[10];
char *name[10];
int numFound = 0;
argv_new[0] = "/bin/sh";
argv_new[1] = "-c";
argv_new[3] = NULL;
/* try to detect arts */
argv_new[2] = "ps awx|grep artsd|grep -v grep|grep artsd > /dev/null";
if(!spawnvp(_P_WAIT, "/bin/sh", argv_new))
{
driversFound[numFound] = "winearts.drv";
name[numFound] = "aRts";
numFound++;
}
/* try to detect jack */
argv_new[2] = "ps awx|grep jackd|grep -v grep|grep jackd > /dev/null";
if(!spawnvp(_P_WAIT, "/bin/sh", argv_new))
{
driversFound[numFound] = "winejack.drv";
name[numFound] = "jack";
numFound++;
}
/* try to detect nas */
/* TODO */
/* try to detect audioIO (solaris) */
/* TODO */
/* try to detect alsa */
if(!stat("/proc/asound", &buf))
{
driversFound[numFound] = "winealsa.drv";
name[numFound] = "Alsa";
numFound++;
}
/* try to detect oss */
fd = open("/dev/dsp", O_WRONLY | O_NONBLOCK);
if(fd)
{
close(fd);
driversFound[numFound] = "wineoss.drv";
name[numFound] = "OSS";
numFound++;
}
if(numFound == 0)
{
MessageBox(NULL, "Could not detect any audio devices/servers", "Failed", MB_OK);
return "";
}
else
{
/* TODO: possibly smarter handling of multiple drivers? */
char text[128];
snprintf(text, sizeof(text), "Found %s", name[0]);
MessageBox(NULL, (LPCTSTR)text, "Successful", MB_OK);
return driversFound[0];
}
}
INT_PTR CALLBACK
AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_AUDIO_AUTODETECT:
selectAudioDriver(hDlg, audioAutoDetect());
break;
case IDC_AUDIO_DRIVER:
if ((HIWORD(wParam) == CBN_SELCHANGE) ||
(HIWORD(wParam) == CBN_SELCHANGE))
{
const AUDIO_DRIVER *pAudioDrv = getAudioDrivers();
int selected_driver = SendDlgItemMessage(hDlg, IDC_AUDIO_DRIVER, CB_GETCURSEL, 0, 0);
selectAudioDriver(hDlg, (char*)pAudioDrv[selected_driver].szDriver);
}
break;
}
break;
case WM_NOTIFY:
switch(((LPNMHDR)lParam)->code) {
case PSN_KILLACTIVE:
SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
break;
case PSN_APPLY:
SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
break;
case PSN_SETACTIVE:
break;
}
break;
case WM_INITDIALOG:
initAudioDlg(hDlg);
break;
}
return FALSE;
}

View File

@ -525,7 +525,7 @@ void onEditChanged(HWND hDlg, WORD controlID) {
INT_PTR CALLBACK DriveEditDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
int selection;
switch (uMsg) {
case WM_INITDIALOG: {
editWindowLetter = (char) lParam;
@ -634,7 +634,6 @@ void onAddDriveClicked(HWND hDlg) {
INT_PTR CALLBACK
DriveDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
int selection = -1;
int nItem;
char letter;
@ -642,7 +641,10 @@ DriveDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_LIST_DRIVES:
if (HIWORD(wParam) == LBN_DBLCLK) selection = -1;
/* double click should open the edit window for the chosen drive */
if (HIWORD(wParam) == LBN_DBLCLK)
SendMessageA(hDlg, WM_COMMAND, IDC_BUTTON_EDIT, 0);
if (HIWORD(wParam) == LBN_SELCHANGE) lastSel = SendDlgItemMessage(hDlg, IDC_LIST_DRIVES, LB_GETCURSEL, 0, 0);
break;
@ -684,7 +686,6 @@ DriveDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
}
break;
}
return FALSE;

View File

@ -177,7 +177,8 @@ GeneralDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
#define NUM_PROPERTY_PAGES 5
#define NUM_PROPERTY_PAGES 6
INT_PTR
doPropertySheet (HINSTANCE hInstance, HWND hOwner)
{
@ -244,6 +245,15 @@ doPropertySheet (HINSTANCE hInstance, HWND hOwner)
psp[4].pfnDlgProc = DriveDlgProc;
psp[4].pszTitle = "Drives";
psp[4].lParam = 0;
psp[5].dwSize = sizeof (PROPSHEETPAGE);
psp[5].dwFlags = PSP_USETITLE;
psp[5].hInstance = hInstance;
psp[5].u.pszTemplate = MAKEINTRESOURCE (IDD_AUDIOCFG);
psp[5].u2.pszIcon = NULL;
psp[5].pfnDlgProc = AudioDlgProc;
psp[5].pszTitle = "Audio";
psp[5].lParam = 0;
/*
* Fill out the PROPSHEETHEADER

View File

@ -77,6 +77,18 @@ static DLL_DESC sDLLType[] = {
{"", -1}
};
static AUDIO_DRIVER sAudioDrivers[] = {
{"Alsa", "winealsa.drv"},
{"aRts", "winearts.drv"},
{"OSS", "wineoss.drv"},
{"Jack", "winejack.drv"},
{"Nas", "winenas.drv"},
{"Audio IO(Solaris)", "wineaudioio.drv"},
{"Disable sound", ""},
{"", ""}
};
/*****************************************************************************
*/
@ -108,3 +120,10 @@ DLL_DESC* getDLLDefaults(void)
{
return sDLLType;
}
/*****************************************************************************
*/
AUDIO_DRIVER* getAudioDrivers(void)
{
return sAudioDrivers;
}

View File

@ -60,6 +60,11 @@ typedef struct
HDPA DLLs;
} APP_DESC;
typedef struct
{
char szName[MAX_NAME_LENGTH];
char szDriver[MAX_NAME_LENGTH];
} AUDIO_DRIVER;
typedef struct
{
@ -86,5 +91,6 @@ VERSION_DESC *getWinVersions(void);
VERSION_DESC *getDOSVersions(void);
VERSION_DESC *getWinelook(void);
DLL_DESC *getDLLDefaults(void);
AUDIO_DRIVER *getAudioDrivers(void);
#endif

View File

@ -30,10 +30,11 @@
#define IDB_WINE 104
#define IDD_GENERALCFG 107
#define IDD_APPCFG 108
#define IDD_X11DRVCFG 109
#define IDD_DLLCFG 110
#define IDD_DRIVECFG 111
#define IDD_SYSTEMCFG 112
#define IDD_AUDIOCFG 109
#define IDD_X11DRVCFG 110
#define IDD_DLLCFG 111
#define IDD_DRIVECFG 112
#define IDD_SYSTEMCFG 113
#define IDD_DRIVE_EDIT 114
#define IDB_WINE_LOGO 200
#define IDC_TABABOUT 1001
@ -120,3 +121,7 @@
#define IDC_EDITING_APP 1082
#define IDC_ADD_APPDEFAULT 1083
#define IDC_REMOVE_APPDEFAULT 1084
/* audio tab */
#define IDC_AUDIO_AUTODETECT 1085
#define IDC_AUDIO_DRIVER 1086

View File

@ -111,6 +111,9 @@ INT_PTR CALLBACK DriveEditDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM l
INT_PTR CALLBACK AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK LibrariesDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
/* Audio config dialog */
INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
/* some basic utilities to make win32 suck less */
char *getDialogItemText(HWND hDlg, WORD controlID);
#define disable(id) EnableWindow(GetDlgItem(dialog, id), 0);