[SNDVOL32]

- Fix more subtle bugs:
- Check with long line name if the current connection is activated when adding lines to dialog or when adding lines to the preferences dialog
- Use the temporary preferences context when writing the line settings
- Don't destroy the mixer when the preferences dialog is closed. the new mixer will be used for the application when the preferences are changed
- Pass the current selected line to the preferences dialog





svn path=/trunk/; revision=51292
This commit is contained in:
Johannes Anderwald 2011-04-09 10:36:25 +00:00
parent 6301753d1d
commit 39dac2cce0
3 changed files with 23 additions and 28 deletions

View file

@ -340,7 +340,7 @@ EnumConnectionsCallback(
if (Line->cControls != 0)
{
/* get line name */
if (SndMixerGetLineName(PrefContext->MixerWindow->Mixer, PrefContext->SelectedLine, LineName, MIXER_LONG_NAME_CHARS, FALSE) == -1)
if (SndMixerGetLineName(PrefContext->MixerWindow->Mixer, PrefContext->SelectedLine, LineName, MIXER_LONG_NAME_CHARS, TRUE) == -1)
{
/* failed to get line name */
LineName[0] = L'\0';

View file

@ -199,7 +199,7 @@ PrefDlgAddConnection(PSND_MIXER Mixer,
PrefContext->SelectedLine,
LineName,
MIXER_LONG_NAME_CHARS,
FALSE) == -1)
TRUE) == -1)
{
LineName[0] = TEXT('\0');
}
@ -340,7 +340,7 @@ UpdatePrefDlgControls(PPREFERENCES_CONTEXT Context,
static
VOID
WriteLineSettings(PREFERENCES_CONTEXT Context, HWND hwndDlg)
WriteLineSettings(PPREFERENCES_CONTEXT Context, HWND hwndDlg)
{
HWND hwndControls;
INT Count, Index;
@ -358,7 +358,7 @@ WriteLineSettings(PREFERENCES_CONTEXT Context, HWND hwndDlg)
/* sanity check */
assert(Count);
if (SndMixerGetLineName(Preferences.MixerWindow->Mixer, Preferences.SelectedLine, DestinationName, MIXER_LONG_NAME_CHARS, TRUE) == -1)
if (SndMixerGetLineName(Context->Mixer, Context->SelectedLine, DestinationName, MIXER_LONG_NAME_CHARS, TRUE) == -1)
{
/* failed to get destination line name */
return;
@ -395,7 +395,7 @@ WriteLineSettings(PREFERENCES_CONTEXT Context, HWND hwndDlg)
}
/* now write the line config */
WriteLineConfig(Preferences.DeviceName, DestinationName, LineStates, sizeof(SNDVOL_REG_LINESTATE) * Count);
WriteLineConfig(Context->DeviceName, DestinationName, LineStates, sizeof(SNDVOL_REG_LINESTATE) * Count);
/* free line states */
HeapFree(GetProcessHeap(), 0, LineStates);
@ -509,7 +509,7 @@ DlgPreferencesProc(HWND hwndDlg,
case IDOK:
{
/* write line settings */
WriteLineSettings(Preferences, hwndDlg);
WriteLineSettings(Context, hwndDlg);
/* fall through */
}
@ -564,21 +564,10 @@ DlgPreferencesProc(HWND hwndDlg,
/* update all controls */
UpdatePrefDlgControls(Context,
(DWORD)-1);
(DWORD)Context->SelectedLine);
return TRUE;
}
case WM_DESTROY:
{
Context = GetDialogData(hwndDlg,
PREFERENCES_CONTEXT);
if (Context->Mixer != NULL)
{
SndMixerDestroy(Context->Mixer);
}
break;
}
case WM_CLOSE:
{
EndDialog(hwndDlg,
@ -789,16 +778,17 @@ MainWindowProc(HWND hwnd,
{
case IDC_PROPERTIES:
{
PREFERENCES_CONTEXT Preferences;
PREFERENCES_CONTEXT Pref;
Preferences.MixerWindow = MixerWindow;
Preferences.Mixer = NULL;
Pref.MixerWindow = MixerWindow;
Pref.Mixer = NULL;
Pref.SelectedLine = Preferences.SelectedLine;
if (DialogBoxParam(hAppInstance,
MAKEINTRESOURCE(IDD_PREFERENCES),
hwnd,
DlgPreferencesProc,
(LPARAM)&Preferences) == IDOK)
(LPARAM)&Pref) == IDOK)
{
/* update window */
TCHAR szProduct[MAXPNAMELEN];
@ -820,11 +810,17 @@ MainWindowProc(HWND hwnd,
/* destroy old status bar */
DestroyWindow(MixerWindow->hStatusBar);
/* update details */
Preferences.SelectedLine = Pref.SelectedLine;
/* destroy old mixer */
SndMixerDestroy(Preferences.MixerWindow->Mixer);
/* use new selected mixer */
Preferences.MixerWindow->Mixer = Pref.Mixer;
/* rebuild dialog controls */
if (RebuildMixerWindowControls(&Preferences))
{
DPRINT("Rebuilding mixer window controls failed!\n");
}
RebuildMixerWindowControls(&Preferences);
/* create status window */
MixerWindow->hStatusBar = CreateStatusWindow(WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS,

View file

@ -31,8 +31,7 @@ extern HANDLE hAppHeap;
#define SZ_APP_CLASS TEXT("Volume Control")
ULONG DbgPrint(PCH , ...);
#define DPRINT
//DbgPrint("SNDVOL32: %s:%i: ", __FILE__, __LINE__); DbgPrint
#define DPRINT DbgPrint("SNDVOL32: %s:%i: ", __FILE__, __LINE__); DbgPrint
/*