[WINECFG] select audio driver on fresh install

Robert Reif reif at earthlink.net
Wed Dec 21 11:00:49 CST 2005


Changelog:
- Select an audio driver when Driver registry key missing.
-------------- next part --------------
Index: programs/winecfg/En.rc
===================================================================
RCS file: /home/wine/wine/programs/winecfg/En.rc,v
retrieving revision 1.56
diff -p -u -r1.56 En.rc
--- programs/winecfg/En.rc	17 Dec 2005 11:41:36 -0000	1.56
+++ programs/winecfg/En.rc	21 Dec 2005 16:55:57 -0000
@@ -201,6 +201,7 @@ BEGIN
     IDS_WINECFG_TITLE       "Wine configuration"
     IDS_THEMEFILE           "Theme files"
     IDS_THEMEFILE_SELECT    "Select a theme file"
+    IDS_AUDIO_MISSING       "There is no audio driver currently specified in the registry.\n\nA recommended driver has been selected for you.\nYou can use this driver or select another driver if available.\n\nYou must click Apply for the selection to take effect."
 END
 
 
Index: programs/winecfg/audio.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/audio.c,v
retrieving revision 1.20
diff -p -u -r1.20 audio.c
--- programs/winecfg/audio.c	17 Dec 2005 11:41:36 -0000	1.20
+++ programs/winecfg/audio.c	21 Dec 2005 16:55:58 -0000
@@ -516,6 +516,23 @@ start_over:
     free(tokens);
 }
 
+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 */
+}
+
 static void initAudioDlg (HWND hDlg)
 {
     int i;
@@ -523,14 +540,54 @@ static void initAudioDlg (HWND hDlg)
 
     WINE_TRACE("\n");
 
-    /* make a local copy of the current registry setting */
-    strcpy(curAudioDriver, get_reg_key(config_key, "Drivers", "Audio", ""));
-
-    WINE_TRACE("curAudioDriver = %s\n", curAudioDriver);
-
     /* make a list of all drivers that can be loaded */
     findAudioDrivers();
 
+    /* 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 */
+        for (pAudioDrv = loadedAudioDrv; *pAudioDrv->szName; pAudioDrv++)
+        {
+            if (strcmp(pAudioDrv->szDriver, "oss") == 0)
+            {
+                selectDriver(hDlg, "oss");
+                break;
+            }
+        }
+
+        if (strlen(curAudioDriver) == 0)
+        {
+            /* select alsa if available */
+            for (pAudioDrv = loadedAudioDrv; *pAudioDrv->szName; pAudioDrv++)
+            {
+                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);
+
     /* check for drivers that can't be loaded */
     checkRegistrySetting(hDlg);
 
Index: programs/winecfg/resource.h
===================================================================
RCS file: /home/wine/wine/programs/winecfg/resource.h,v
retrieving revision 1.35
diff -p -u -r1.35 resource.h
--- programs/winecfg/resource.h	17 Dec 2005 11:41:36 -0000	1.35
+++ programs/winecfg/resource.h	21 Dec 2005 16:55:58 -0000
@@ -141,6 +141,7 @@
 #define IDR_WINECFG			1305
 #define IDB_CHECKBOX                    1306
 #define IDB_DEVICE                      1307
+#define IDS_AUDIO_MISSING               1308
 
 /* appearance tab */
 #define IDC_THEME_COLORCOMBO            1401


More information about the wine-patches mailing list