winecfg audio question

Robert Reif reif at earthlink.net
Sun Jun 26 19:19:35 CDT 2005


Here is a patch that adds an audio driver configure button
and tries to send a DRV_CONFIGURE message to the
selected audio driver.

It doesn't work because it can't find the audio driver. However,
hard coding the driver name to "joystick.drv" does display
the joystick config dialog so it should work.  Any ideas why
it doesn't work?

Once this works, it should be possible to implement a real
config dialog for each audio driver.


-------------- next part --------------
Index: programs/winecfg/En.rc
===================================================================
RCS file: /home/wine/wine/programs/winecfg/En.rc,v
retrieving revision 1.41
diff -p -u -r1.41 En.rc
--- programs/winecfg/En.rc	19 May 2005 11:14:52 -0000	1.41
+++ programs/winecfg/En.rc	27 Jun 2005 00:07:29 -0000
@@ -139,6 +139,8 @@ 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,20,49,14
+    PUSHBUTTON	"Configure",IDC_AUDIO_CONFIGURE,170,40,49,14
+    PUSHBUTTON	"Control Panel",IDC_AUDIO_CONTROL_PANEL,170,60,49,14
 END
 
 STRINGTABLE DISCARDABLE
Index: programs/winecfg/Makefile.in
===================================================================
RCS file: /home/wine/wine/programs/winecfg/Makefile.in,v
retrieving revision 1.13
diff -p -u -r1.13 Makefile.in
--- programs/winecfg/Makefile.in	9 Mar 2005 16:41:30 -0000	1.13
+++ programs/winecfg/Makefile.in	27 Jun 2005 00:07:29 -0000
@@ -4,7 +4,7 @@ SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = winecfg.exe
 APPMODE   = -mwindows
-IMPORTS   = comdlg32 comctl32 shell32 ole32 shlwapi user32 advapi32 kernel32
+IMPORTS   = comdlg32 comctl32 shell32 ole32 shlwapi user32 advapi32 kernel32 winmm
 
 C_SRCS = \
 	appdefaults.c \
Index: programs/winecfg/audio.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/audio.c,v
retrieving revision 1.9
diff -p -u -r1.9 audio.c
--- programs/winecfg/audio.c	23 Jun 2005 11:42:54 -0000	1.9
+++ programs/winecfg/audio.c	27 Jun 2005 00:07:29 -0000
@@ -37,6 +37,7 @@
 #include <shlguid.h>
 #include <shlwapi.h>
 #include <shlobj.h>
+#include <mmsystem.h>
 
 #include "winecfg.h"
 #include "resource.h"
@@ -64,6 +65,46 @@ static void selectAudioDriver(HWND hDlg,
   }
 }
 
+static void configureAudioDriver(HWND hDlg, const char *drivername)
+{
+  int i;
+  const AUDIO_DRIVER *pAudioDrv = NULL;
+
+  if ((pAudioDrv = getAudioDrivers()))
+  {
+    for (i = 0; *pAudioDrv->szName; i++, pAudioDrv++)
+    {
+      if (!strcmp (pAudioDrv->szDriver, drivername))
+      {
+        HDRVR hdrvr;
+	char wine_driver[MAX_NAME_LENGTH + 8];
+	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 = (LPWSTR)0;
+            dci.lpszDCIAliasName = (LPWSTR)0;
+            lRes = SendDriverMessage(hdrvr, DRV_CONFIGURE, 0, (LONG)&dci);
+	  }
+	  CloseDriver(hdrvr, 0, 0);
+	}
+        else
+        {
+	  char str[1024];
+	  sprintf(str, "Couldn't open %s!", wine_driver);
+	  MessageBox(NULL, str, "ERROR", MB_OK | MB_ICONERROR);
+        }
+	break;
+      }
+    }
+  }
+}
+
 static void initAudioDlg (HWND hDlg)
 {
     char *curAudioDriver = get_reg_key(config_key, "Drivers", "Audio", "alsa");
@@ -172,6 +213,15 @@ AudioDlgProc (HWND hDlg, UINT uMsg, WPAR
 		selectAudioDriver(hDlg, (char*)pAudioDrv[selected_driver].szDriver);
 	     }
 	     break;
+          case IDC_AUDIO_CONFIGURE:
+	     {
+		const AUDIO_DRIVER *pAudioDrv = getAudioDrivers();
+		int selected_driver = SendDlgItemMessage(hDlg, IDC_AUDIO_DRIVER, CB_GETCURSEL, 0, 0);
+		configureAudioDriver(hDlg, (char*)pAudioDrv[selected_driver].szDriver);
+	     }
+	     break;
+          case IDC_AUDIO_CONTROL_PANEL:
+             break;
 	}
 	break;
 
Index: programs/winecfg/resource.h
===================================================================
RCS file: /home/wine/wine/programs/winecfg/resource.h,v
retrieving revision 1.24
diff -p -u -r1.24 resource.h
--- programs/winecfg/resource.h	19 May 2005 11:14:52 -0000	1.24
+++ programs/winecfg/resource.h	27 Jun 2005 00:07:29 -0000
@@ -123,3 +123,6 @@
 /* audio tab */
 #define IDC_AUDIO_AUTODETECT            1300
 #define IDC_AUDIO_DRIVER                1301
+#define IDC_AUDIO_CONFIGURE             1302
+#define IDC_AUDIO_CONTROL_PANEL         1303
+


More information about the wine-devel mailing list