This is a proof of concept patch that adds a simple audio test to winecfg. All it does is use PlaySound to play a wave file. I am using LoadLibrary("winmm.dll") and FreeLibrary to change drivers. You must press the apply button for the driver change to take effect. There is no error recovery for a missing winmm.dll. The wave file name is in the rc file so a different file can be played for each language. This is probably overkill. I'm not sure where to put the wave file so the program will only work when the wave file is in the current directory.
Sorry about the binary wave file.
Comments please?
Index: programs/winecfg/En.rc =================================================================== RCS file: /home/wine/wine/programs/winecfg/En.rc,v retrieving revision 1.54 diff -p -u -r1.54 En.rc --- programs/winecfg/En.rc 27 Oct 2005 11:24:02 -0000 1.54 +++ programs/winecfg/En.rc 12 Nov 2005 04:21:54 -0000 @@ -157,13 +157,14 @@ BEGIN COMBOBOX IDC_AUDIO_DRIVER,70,18,85,85,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Autodetect",IDC_AUDIO_AUTODETECT,170,20,49,14 PUSHBUTTON "Configure",IDC_AUDIO_CONFIGURE,170,40,49,14 - PUSHBUTTON "Control Panel",IDC_AUDIO_CONTROL_PANEL,170,60,49,14 + PUSHBUTTON "Test",IDC_AUDIO_TEST,170,60,49,14 + PUSHBUTTON "Control Panel",IDC_AUDIO_CONTROL_PANEL,170,80,49,14
- GROUPBOX " DirectSound ",IDC_STATIC,8,75,244,120 + GROUPBOX " DirectSound ",IDC_STATIC,8,95,244,120
- LTEXT "Hardware Acceleration: ",IDC_STATIC,15,85,90,10 - COMBOBOX IDC_DSOUND_HW_ACCEL,100,83,150,70,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Driver Emulation",IDC_DSOUND_DRV_EMUL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,100,230,10 + LTEXT "Hardware Acceleration: ",IDC_STATIC,15,105,90,10 + COMBOBOX IDC_DSOUND_HW_ACCEL,100,103,150,70,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Driver Emulation",IDC_DSOUND_DRV_EMUL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,120,230,10
END
@@ -197,6 +198,9 @@ BEGIN IDS_WINECFG_TITLE "Wine configuration" IDS_THEMEFILE "Theme files" IDS_THEMEFILE_SELECT "Select a theme file" + IDS_AUDIO_FILE "winecfg.en.wav" + IDS_AUDIO_DONE "Done playing: " + IDS_AUDIO_ERROR "Couldn't play: " END
Index: programs/winecfg/Makefile.in =================================================================== RCS file: /home/wine/wine/programs/winecfg/Makefile.in,v retrieving revision 1.15 diff -p -u -r1.15 Makefile.in --- programs/winecfg/Makefile.in 24 Aug 2005 10:59:40 -0000 1.15 +++ programs/winecfg/Makefile.in 12 Nov 2005 04:21:54 -0000 @@ -4,7 +4,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = winecfg.exe APPMODE = -mwindows -IMPORTS = comdlg32 comctl32 shell32 ole32 winmm shlwapi uxtheme user32 advapi32 kernel32 +IMPORTS = comdlg32 comctl32 shell32 ole32 shlwapi uxtheme user32 advapi32 kernel32
C_SRCS = \ appdefaults.c \ Index: programs/winecfg/audio.c =================================================================== RCS file: /home/wine/wine/programs/winecfg/audio.c,v retrieving revision 1.15 diff -p -u -r1.15 audio.c --- programs/winecfg/audio.c 3 Nov 2005 19:31:45 -0000 1.15 +++ programs/winecfg/audio.c 12 Nov 2005 04:21:54 -0000 @@ -52,6 +52,13 @@ static const char* DSound_HW_Accels[] = NULL };
+static HINSTANCE hWINMM = 0; + +HDRVR (WINAPI * pOpenDriverA)(LPCSTR lpDriverName, LPCSTR lpSectionName, LONG lParam); +LRESULT (WINAPI *pSendDriverMessage)(HDRVR hdrvr, UINT msg, LONG lParam1, LONG lParam2); +LRESULT (WINAPI *pCloseDriver)(HDRVR hdrvr, LONG lParam1, LONG lParam2); +BOOL (WINAPI *pPlaySoundW)(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound); + /* Select the correct entry in the combobox based on drivername */ static void selectAudioDriver(HWND hDlg, const char *drivername) { @@ -89,19 +96,19 @@ static void configureAudioDriver(HWND hD HDRVR hdrvr; char wine_driver[MAX_NAME_LENGTH + 8]; sprintf(wine_driver, "wine%s.drv", pAudioDrv->szDriver); - hdrvr = OpenDriverA(wine_driver, 0, 0); + hdrvr = pOpenDriverA(wine_driver, 0, 0); if (hdrvr != 0) { - if (SendDriverMessage(hdrvr, DRV_QUERYCONFIGURE, 0, 0) != 0) + if (pSendDriverMessage(hdrvr, DRV_QUERYCONFIGURE, 0, 0) != 0) { DRVCONFIGINFO dci; LONG lRes; dci.dwDCISize = sizeof (dci); dci.lpszDCISectionName = NULL; dci.lpszDCIAliasName = NULL; - lRes = SendDriverMessage(hdrvr, DRV_CONFIGURE, 0, (LONG)&dci); + lRes = pSendDriverMessage(hdrvr, DRV_CONFIGURE, 0, (LONG)&dci); } - CloseDriver(hdrvr, 0, 0); + pCloseDriver(hdrvr, 0, 0); } else { @@ -116,6 +123,26 @@ static void configureAudioDriver(HWND hD } }
+static void loadWinmm() +{ + hWINMM = LoadLibrary("winmm.dll"); + if (!hWINMM) { + WINE_ERR("winmm.dll not found\n"); + /* FIXME do something */ + } + + pOpenDriverA = (void*)GetProcAddress(hWINMM, "OpenDriverA"); + pSendDriverMessage = (void*)GetProcAddress(hWINMM, "SendDriverMessage"); + pCloseDriver = (void*)GetProcAddress(hWINMM, "CloseDriver"); + pPlaySoundW = (void*)GetProcAddress(hWINMM, "PlaySoundW"); + + if (!pOpenDriverA || !pSendDriverMessage || !pCloseDriver || !pPlaySoundW) + { + WINE_ERR("winmm.dll not all entries found\n"); + /* FIXME do something */ + } +} + static void initAudioDlg (HWND hDlg) { char *curAudioDriver = get_reg_key(config_key, "Drivers", "Audio", "alsa"); @@ -125,6 +152,8 @@ static void initAudioDlg (HWND hDlg)
WINE_TRACE("\n");
+ loadWinmm(); + pAudioDrv = getAudioDrivers (); for (i = 0; *pAudioDrv->szName; i++, pAudioDrv++) { SendDlgItemMessage (hDlg, IDC_AUDIO_DRIVER, CB_ADDSTRING, @@ -272,6 +301,33 @@ AudioDlgProc (HWND hDlg, UINT uMsg, WPAR configureAudioDriver(hDlg, (char*)pAudioDrv[selected_driver].szDriver); } break; + case IDC_AUDIO_TEST: + { + WCHAR wave_file[MAX_PATH]; + WCHAR format[] = { '%','s','%','s',0 }; + WCHAR title[64]; + + LoadStringW(GetModuleHandle(NULL), IDS_AUDIO_FILE, wave_file, sizeof(wave_file)/sizeof(wave_file[0])); + LoadStringW(GetModuleHandle(NULL), IDS_WINECFG_TITLE, title, sizeof(title)/sizeof(title[0])); + + if (pPlaySoundW(wave_file, NULL, SND_FILENAME)) { + WCHAR done_msg[MAX_PATH + 64]; + WCHAR wave_done[64]; + + LoadStringW(GetModuleHandle(NULL), IDS_AUDIO_DONE, wave_done, sizeof(wave_done)/sizeof(wave_done[0])); + wsprintfW(done_msg, format, wave_done, wave_file); + MessageBoxW(NULL, done_msg, title, MB_OK); + pPlaySoundW(NULL, NULL, SND_FILENAME | SND_LOOP); + } else { + WCHAR error_msg[MAX_PATH + 64]; + WCHAR wave_error[64]; + + LoadStringW(GetModuleHandle(NULL), IDS_AUDIO_ERROR, wave_error, sizeof(wave_error)/sizeof(wave_error[0])); + wsprintfW(error_msg, format, wave_error, wave_file); + MessageBoxW(NULL, error_msg, title, MB_OK); + } + } + break; case IDC_AUDIO_CONTROL_PANEL: MessageBox(NULL, "Launching audio control panel not implemented yet!", "Fixme", MB_OK | MB_ICONERROR); break; @@ -305,6 +361,10 @@ AudioDlgProc (HWND hDlg, UINT uMsg, WPAR SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE); break; case PSN_APPLY: + /* unload the current sound driver */ + while (FreeLibrary(hWINMM)); + /* load the new driver */ + loadWinmm(); apply(); SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR); break; Index: programs/winecfg/resource.h =================================================================== RCS file: /home/wine/wine/programs/winecfg/resource.h,v retrieving revision 1.33 diff -p -u -r1.33 resource.h --- programs/winecfg/resource.h 27 Oct 2005 11:24:02 -0000 1.33 +++ programs/winecfg/resource.h 12 Nov 2005 04:21:54 -0000 @@ -39,6 +39,9 @@ #define IDS_WINECFG_TITLE 13 #define IDS_THEMEFILE 14 #define IDS_THEMEFILE_SELECT 15 +#define IDS_AUDIO_FILE 16 +#define IDS_AUDIO_DONE 17 +#define IDS_AUDIO_ERROR 18 #define IDD_MAINDLG 101 #define IDB_WINE 104 #define IDD_ABOUTCFG 107 @@ -136,9 +139,10 @@ #define IDC_AUDIO_AUTODETECT 1300 #define IDC_AUDIO_DRIVER 1301 #define IDC_AUDIO_CONFIGURE 1302 -#define IDC_AUDIO_CONTROL_PANEL 1303 -#define IDC_DSOUND_HW_ACCEL 1304 -#define IDC_DSOUND_DRV_EMUL 1305 +#define IDC_AUDIO_TEST 1303 +#define IDC_AUDIO_CONTROL_PANEL 1304 +#define IDC_DSOUND_HW_ACCEL 1305 +#define IDC_DSOUND_DRV_EMUL 1306
/* appearance tab */ #define IDC_THEME_COLORCOMBO 1401