mirror of
https://github.com/reactos/reactos.git
synced 2024-10-02 15:34:13 +00:00
[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:
parent
fcdea4c19d
commit
a54b06c8cd
|
@ -160,13 +160,10 @@ CloseAppConfig(VOID)
|
||||||
BOOL
|
BOOL
|
||||||
WriteLineConfig(IN LPTSTR szDeviceName,
|
WriteLineConfig(IN LPTSTR szDeviceName,
|
||||||
IN LPTSTR szLineName,
|
IN LPTSTR szLineName,
|
||||||
IN LPTSTR szControlName,
|
IN PSNDVOL_REG_LINESTATE LineState,
|
||||||
IN DWORD Flags)
|
IN DWORD cbSize)
|
||||||
{
|
{
|
||||||
HKEY hLineKey;
|
HKEY hLineKey;
|
||||||
DWORD Type;
|
|
||||||
DWORD i, Size = 0;
|
|
||||||
PSNDVOL_REG_LINESTATE LineStates = NULL;
|
|
||||||
TCHAR szDevRegKey[MAX_PATH];
|
TCHAR szDevRegKey[MAX_PATH];
|
||||||
BOOL Ret = FALSE;
|
BOOL Ret = FALSE;
|
||||||
|
|
||||||
|
@ -185,67 +182,14 @@ WriteLineConfig(IN LPTSTR szDeviceName,
|
||||||
&hLineKey,
|
&hLineKey,
|
||||||
NULL) == ERROR_SUCCESS)
|
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))
|
|
||||||
{
|
|
||||||
LineStates[i].Flags = Flags;
|
|
||||||
Ret = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now update line states */
|
/* now update line states */
|
||||||
if (Ret)
|
RegSetValueEx(hLineKey, LineStatesValue, 0, REG_BINARY, (const BYTE*)LineState, cbSize);
|
||||||
{
|
Ret = TRUE;
|
||||||
RegSetValueEx(hLineKey, LineStatesValue, 0, REG_BINARY, (const BYTE*)LineStates, Size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ExitClose:
|
|
||||||
HeapFree(GetProcessHeap(),
|
|
||||||
0,
|
|
||||||
LineStates);
|
|
||||||
RegCloseKey(hLineKey);
|
RegCloseKey(hLineKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ret;
|
return Ret;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
|
|
|
@ -347,6 +347,7 @@ WriteLineSettings(PREFERENCES_CONTEXT Context, HWND hwndDlg)
|
||||||
WCHAR LineName[MIXER_LONG_NAME_CHARS];
|
WCHAR LineName[MIXER_LONG_NAME_CHARS];
|
||||||
WCHAR DestinationName[MIXER_LONG_NAME_CHARS];
|
WCHAR DestinationName[MIXER_LONG_NAME_CHARS];
|
||||||
DWORD Flags;
|
DWORD Flags;
|
||||||
|
PSNDVOL_REG_LINESTATE LineStates;
|
||||||
|
|
||||||
/* get list view */
|
/* get list view */
|
||||||
hwndControls = GetDlgItem(hwndDlg, IDC_CONTROLS);
|
hwndControls = GetDlgItem(hwndDlg, IDC_CONTROLS);
|
||||||
|
@ -364,6 +365,14 @@ WriteLineSettings(PREFERENCES_CONTEXT Context, HWND hwndDlg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate line states array */
|
/* 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++)
|
for(Index = 0; Index < Count; Index++)
|
||||||
{
|
{
|
||||||
/* set to empty */
|
/* set to empty */
|
||||||
|
@ -378,11 +387,18 @@ WriteLineSettings(PREFERENCES_CONTEXT Context, HWND hwndDlg)
|
||||||
/* get check state */
|
/* get check state */
|
||||||
Flags = (ListView_GetCheckState(hwndControls, Index) == 0 ? 0x4 : 0);
|
Flags = (ListView_GetCheckState(hwndControls, Index) == 0 ? 0x4 : 0);
|
||||||
|
|
||||||
/* write configuration */
|
/* copy line name */
|
||||||
WriteLineConfig(Preferences.DeviceName, DestinationName, LineName, Flags);
|
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
|
static INT_PTR CALLBACK
|
||||||
|
|
|
@ -160,7 +160,7 @@ ReadLineConfig(IN LPTSTR szDeviceName,
|
||||||
BOOL
|
BOOL
|
||||||
WriteLineConfig(IN LPTSTR szDeviceName,
|
WriteLineConfig(IN LPTSTR szDeviceName,
|
||||||
IN LPTSTR szLineName,
|
IN LPTSTR szLineName,
|
||||||
IN LPTSTR szControlName,
|
IN PSNDVOL_REG_LINESTATE LineState,
|
||||||
IN DWORD Flags);
|
IN DWORD cbSize);
|
||||||
|
|
||||||
#endif /* __SNDVOL32_H */
|
#endif /* __SNDVOL32_H */
|
||||||
|
|
Loading…
Reference in a new issue