[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) if (Line->cControls != 0)
{ {
/* get line name */ /* 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 */ /* failed to get line name */
LineName[0] = L'\0'; LineName[0] = L'\0';

View file

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