Author: janderwald
Date: Fri Apr 8 22:04:41 2011
New Revision: 51286
URL:
http://svn.reactos.org/svn/reactos?rev=51286&view=rev
Log:
[SNDVOL32]
- Always write line states configuration values in one step
- Fixes the problem when old line state settings were not present
- Advantage is that it is faster and sndvol32 now works in ReactOS
Modified:
trunk/reactos/base/applications/sndvol32/misc.c
trunk/reactos/base/applications/sndvol32/sndvol32.c
trunk/reactos/base/applications/sndvol32/sndvol32.h
Modified: trunk/reactos/base/applications/sndvol32/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sndvol32…
==============================================================================
--- trunk/reactos/base/applications/sndvol32/misc.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/sndvol32/misc.c [iso-8859-1] Fri Apr 8 22:04:41 2011
@@ -160,8 +160,43 @@
BOOL
WriteLineConfig(IN LPTSTR szDeviceName,
IN LPTSTR szLineName,
- IN LPTSTR szControlName,
- IN DWORD Flags)
+ IN PSNDVOL_REG_LINESTATE LineState,
+ IN DWORD cbSize)
+{
+ HKEY hLineKey;
+ TCHAR szDevRegKey[MAX_PATH];
+ BOOL Ret = FALSE;
+
+ _stprintf(szDevRegKey,
+ TEXT("%s\\%s"),
+ szDeviceName,
+ szLineName);
+
+ if (RegCreateKeyEx(hAppSettingsKey,
+ szDevRegKey,
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_READ | KEY_WRITE,
+ NULL,
+ &hLineKey,
+ NULL) == ERROR_SUCCESS)
+ {
+ /* now update line states */
+ RegSetValueEx(hLineKey, LineStatesValue, 0, REG_BINARY, (const BYTE*)LineState,
cbSize);
+ Ret = TRUE;
+
+ RegCloseKey(hLineKey);
+ }
+
+ return Ret;
+}
+
+BOOL
+ReadLineConfig(IN LPTSTR szDeviceName,
+ IN LPTSTR szLineName,
+ IN LPTSTR szControlName,
+ OUT DWORD *Flags)
{
HKEY hLineKey;
DWORD Type;
@@ -221,16 +256,10 @@
if (!_tcscmp(szControlName,
LineStates[i].LineName))
{
- LineStates[i].Flags = Flags;
+ *Flags = LineStates[i].Flags;
Ret = TRUE;
break;
}
- }
-
- /* now update line states */
- if (Ret)
- {
- RegSetValueEx(hLineKey, LineStatesValue, 0, REG_BINARY, (const
BYTE*)LineStates, Size);
}
}
@@ -242,89 +271,4 @@
}
return Ret;
-
-
-
-
-}
-
-BOOL
-ReadLineConfig(IN LPTSTR szDeviceName,
- IN LPTSTR szLineName,
- IN LPTSTR szControlName,
- OUT DWORD *Flags)
-{
- HKEY hLineKey;
- DWORD Type;
- DWORD i, Size = 0;
- PSNDVOL_REG_LINESTATE LineStates = NULL;
- TCHAR szDevRegKey[MAX_PATH];
- BOOL Ret = FALSE;
-
- _stprintf(szDevRegKey,
- TEXT("%s\\%s"),
- szDeviceName,
- szLineName);
-
- if (RegCreateKeyEx(hAppSettingsKey,
- szDevRegKey,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_READ | KEY_WRITE,
- NULL,
- &hLineKey,
- NULL) == ERROR_SUCCESS)
- {
- if (RegQueryValueEx(hLineKey,
- LineStatesValue,
- NULL,
- &Type,
- NULL,
- &Size) != ERROR_SUCCESS ||
- Type != REG_BINARY ||
- Size == 0 || (Size % sizeof(SNDVOL_REG_LINESTATE) != 0))
- {
- goto ExitClose;
- }
-
- LineStates = HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- Size);
-
- if (LineStates != NULL)
- {
- if (RegQueryValueEx(hLineKey,
- LineStatesValue,
- NULL,
- &Type,
- (LPBYTE)LineStates,
- &Size) != ERROR_SUCCESS ||
- Type != REG_BINARY ||
- Size == 0 || (Size % sizeof(SNDVOL_REG_LINESTATE) != 0))
- {
- goto ExitClose;
- }
-
- /* try to find the control */
- for (i = 0; i < Size / sizeof(SNDVOL_REG_LINESTATE); i++)
- {
- if (!_tcscmp(szControlName,
- LineStates[i].LineName))
- {
- *Flags = LineStates[i].Flags;
- Ret = TRUE;
- break;
- }
- }
- }
-
-ExitClose:
- HeapFree(GetProcessHeap(),
- 0,
- LineStates);
- RegCloseKey(hLineKey);
- }
-
- return Ret;
-}
+}
Modified: trunk/reactos/base/applications/sndvol32/sndvol32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sndvol32…
==============================================================================
--- trunk/reactos/base/applications/sndvol32/sndvol32.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/sndvol32/sndvol32.c [iso-8859-1] Fri Apr 8 22:04:41
2011
@@ -347,6 +347,7 @@
WCHAR LineName[MIXER_LONG_NAME_CHARS];
WCHAR DestinationName[MIXER_LONG_NAME_CHARS];
DWORD Flags;
+ PSNDVOL_REG_LINESTATE LineStates;
/* get list view */
hwndControls = GetDlgItem(hwndDlg, IDC_CONTROLS);
@@ -364,6 +365,14 @@
}
/* allocate line states array */
+ LineStates = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(SNDVOL_REG_LINESTATE) * Count);
+ if (LineStates == NULL)
+ {
+ /* failed to allocate line states array */
+ return;
+ }
+
+
for(Index = 0; Index < Count; Index++)
{
/* set to empty */
@@ -378,11 +387,18 @@
/* get check state */
Flags = (ListView_GetCheckState(hwndControls, Index) == 0 ? 0x4 : 0);
- /* write configuration */
- WriteLineConfig(Preferences.DeviceName, DestinationName, LineName, Flags);
- }
-
-
+ /* copy line name */
+ wcscpy(LineStates[Index].LineName, LineName);
+
+ /* store flags */
+ LineStates[Index].Flags = Flags;
+ }
+
+ /* now write the line config */
+ WriteLineConfig(Preferences.DeviceName, DestinationName, LineStates,
sizeof(SNDVOL_REG_LINESTATE) * Count);
+
+ /* free line states */
+ HeapFree(GetProcessHeap(), 0, LineStates);
}
static INT_PTR CALLBACK
Modified: trunk/reactos/base/applications/sndvol32/sndvol32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sndvol32…
==============================================================================
--- trunk/reactos/base/applications/sndvol32/sndvol32.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/sndvol32/sndvol32.h [iso-8859-1] Fri Apr 8 22:04:41
2011
@@ -160,7 +160,7 @@
BOOL
WriteLineConfig(IN LPTSTR szDeviceName,
IN LPTSTR szLineName,
- IN LPTSTR szControlName,
- IN DWORD Flags);
+ IN PSNDVOL_REG_LINESTATE LineState,
+ IN DWORD cbSize);
#endif /* __SNDVOL32_H */