Robert Reif : winecfg: Select an audio driver on fresh install.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Dec 21 14:26:08 CST 2005


Module: wine
Branch: refs/heads/master
Commit: 9f34fd378754b3e8632cd29bef8dd2205865028a
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=9f34fd378754b3e8632cd29bef8dd2205865028a

Author: Robert Reif <reif at earthlink.net>
Date:   Wed Dec 21 20:07:56 2005 +0100

winecfg: Select an audio driver on fresh install.

---

 programs/winecfg/En.rc      |    1 +
 programs/winecfg/audio.c    |   67 ++++++++++++++++++++++++++++++++++++++++---
 programs/winecfg/resource.h |    1 +
 3 files changed, 64 insertions(+), 5 deletions(-)

diff --git a/programs/winecfg/En.rc b/programs/winecfg/En.rc
index 5a750ff..3f37bf8 100644
--- a/programs/winecfg/En.rc
+++ b/programs/winecfg/En.rc
@@ -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
 
 
diff --git a/programs/winecfg/audio.c b/programs/winecfg/audio.c
index ae079df..1d0a424 100644
--- a/programs/winecfg/audio.c
+++ b/programs/winecfg/audio.c
@@ -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);
 
diff --git a/programs/winecfg/resource.h b/programs/winecfg/resource.h
index e79f861..df7f0b9 100644
--- a/programs/winecfg/resource.h
+++ b/programs/winecfg/resource.h
@@ -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-cvs mailing list