[ros-diffs] [janderwald] 43784: - Implement reading preferred playback / record device

janderwald at svn.reactos.org janderwald at svn.reactos.org
Mon Oct 26 20:40:22 CET 2009


Author: janderwald
Date: Mon Oct 26 20:40:21 2009
New Revision: 43784

URL: http://svn.reactos.org/svn/reactos?rev=43784&view=rev
Log:
- Implement reading preferred playback / record device

Modified:
    trunk/reactos/dll/cpl/mmsys/audio.c

Modified: trunk/reactos/dll/cpl/mmsys/audio.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/mmsys/audio.c?rev=43784&r1=43783&r2=43784&view=diff
==============================================================================
--- trunk/reactos/dll/cpl/mmsys/audio.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/mmsys/audio.c [iso-8859-1] Mon Oct 26 20:40:21 2009
@@ -20,7 +20,7 @@
 VOID
 InitAudioDlg(HWND hwnd)
 {
-    WAVEOUTCAPS waveOutputPaps;
+    WAVEOUTCAPSW waveOutputPaps;
     WAVEINCAPS waveInputPaps;
     MIDIOUTCAPS midiOutCaps;
     TCHAR szNoDevices[256];
@@ -42,20 +42,33 @@
     }
     else
     {
+        WCHAR DefaultDevice[MAX_PATH] = {0};
+        HKEY hKey;
+        DWORD dwSize = sizeof(DefaultDevice);
+        UINT DefaultIndex = 0;
+
+        if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Multimedia\\Sound Mapper", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
+        {
+            RegQueryValueExW(hKey, L"Playback", NULL, NULL, (LPBYTE)DefaultDevice, &dwSize);
+            DefaultDevice[MAX_PATH-1] = L'\0';
+            RegCloseKey(hKey);
+        }
+
         for (uIndex = 0; uIndex < DevsNum; uIndex++)
         {
-            if (waveOutGetDevCaps(uIndex, &waveOutputPaps, sizeof(waveOutputPaps)))
+            if (waveOutGetDevCapsW(uIndex, &waveOutputPaps, sizeof(waveOutputPaps)))
                 continue;
 
-            Res = SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM) waveOutputPaps.szPname);
+            Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM) waveOutputPaps.szPname);
 
             if (CB_ERR != Res)
             {
                 SendMessage(hCB, CB_SETITEMDATA, Res, (LPARAM) uIndex);
-                // TODO: Getting default device
-                SendMessage(hCB, CB_SETCURSEL, (WPARAM) Res, 0);
-            }
-        }
+                if (!wcsicmp(waveOutputPaps.szPname, DefaultDevice))
+                    DefaultIndex = Res;
+            }
+        }
+        SendMessage(hCB, CB_SETCURSEL, (WPARAM) DefaultIndex, 0);
     }
 
     // Init sound recording devices list
@@ -69,6 +82,19 @@
     }
     else
     {
+        WCHAR DefaultDevice[MAX_PATH] = {0};
+        HKEY hKey;
+        DWORD dwSize = sizeof(DefaultDevice);
+        UINT DefaultIndex = 0;
+
+        if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Multimedia\\Sound Mapper", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
+        {
+            RegQueryValueExW(hKey, L"Record", NULL, NULL, (LPBYTE)DefaultDevice, &dwSize);
+            DefaultDevice[MAX_PATH-1] = L'\0';
+            RegCloseKey(hKey);
+        }
+
+
         for (uIndex = 0; uIndex < DevsNum; uIndex++)
         {
             if (waveInGetDevCaps(uIndex, &waveInputPaps, sizeof(waveInputPaps)))
@@ -79,10 +105,11 @@
             if (CB_ERR != Res)
             {
                 SendMessage(hCB, CB_SETITEMDATA, Res, (LPARAM) uIndex);
-                // TODO: Getting default device
-                SendMessage(hCB, CB_SETCURSEL, (WPARAM) Res, 0);
-            }
-        }
+                if (!wcsicmp(waveInputPaps.szPname, DefaultDevice))
+                    DefaultIndex = Res;
+            }
+        }
+        SendMessage(hCB, CB_SETCURSEL, (WPARAM) DefaultIndex, 0);
     }
 
     // Init MIDI devices list




More information about the Ros-diffs mailing list