[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

svn path=/trunk/; revision=51286
This commit is contained in:
Johannes Anderwald 2011-04-08 22:04:41 +00:00
parent fcdea4c19d
commit a54b06c8cd
3 changed files with 25 additions and 65 deletions

View file

@ -160,13 +160,10 @@ CloseAppConfig(VOID)
BOOL
WriteLineConfig(IN LPTSTR szDeviceName,
IN LPTSTR szLineName,
IN LPTSTR szControlName,
IN DWORD Flags)
IN PSNDVOL_REG_LINESTATE LineState,
IN DWORD cbSize)
{
HKEY hLineKey;
DWORD Type;
DWORD i, Size = 0;
PSNDVOL_REG_LINESTATE LineStates = NULL;
TCHAR szDevRegKey[MAX_PATH];
BOOL Ret = FALSE;
@ -185,67 +182,14 @@ WriteLineConfig(IN LPTSTR szDeviceName,
&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;
}
/* now update line states */
RegSetValueEx(hLineKey, LineStatesValue, 0, REG_BINARY, (const BYTE*)LineState, cbSize);
Ret = TRUE;
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))
{
LineStates[i].Flags = Flags;
Ret = TRUE;
break;
}
}
/* now update line states */
if (Ret)
{
RegSetValueEx(hLineKey, LineStatesValue, 0, REG_BINARY, (const BYTE*)LineStates, Size);
}
}
ExitClose:
HeapFree(GetProcessHeap(),
0,
LineStates);
RegCloseKey(hLineKey);
}
return Ret;
}
BOOL

View file

@ -347,6 +347,7 @@ WriteLineSettings(PREFERENCES_CONTEXT Context, HWND hwndDlg)
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 @@ WriteLineSettings(PREFERENCES_CONTEXT Context, HWND hwndDlg)
}
/* 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 @@ WriteLineSettings(PREFERENCES_CONTEXT Context, HWND hwndDlg)
/* 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

View file

@ -160,7 +160,7 @@ ReadLineConfig(IN LPTSTR szDeviceName,
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 */