2004-12-29 22:37:14 +00:00
|
|
|
/*
|
|
|
|
* ReactOS Sound Volume Control
|
2005-09-26 19:15:27 +00:00
|
|
|
* Copyright (C) 2004-2005 Thomas Weidenmueller
|
2004-12-29 22:37:14 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2009-10-27 10:34:16 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2004-12-29 22:37:14 +00:00
|
|
|
*/
|
2013-03-16 20:08:56 +00:00
|
|
|
/*
|
2004-12-29 22:37:14 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Sound Volume Control
|
|
|
|
* FILE: subsys/system/sndvol32/sndvol32.c
|
|
|
|
* PROGRAMMERS: Thomas Weidenmueller <w3seek@reactos.com>
|
|
|
|
*/
|
2014-01-13 12:42:34 +00:00
|
|
|
|
2011-04-06 21:05:05 +00:00
|
|
|
#include "sndvol32.h"
|
2004-12-29 22:37:14 +00:00
|
|
|
|
2014-01-13 12:42:34 +00:00
|
|
|
#include <shellapi.h>
|
|
|
|
|
2004-12-29 22:37:14 +00:00
|
|
|
HINSTANCE hAppInstance;
|
|
|
|
ATOM MainWindowClass;
|
|
|
|
HWND hMainWnd;
|
|
|
|
HANDLE hAppHeap;
|
2005-09-27 01:02:15 +00:00
|
|
|
LPTSTR lpAppTitle;
|
2011-04-06 21:05:05 +00:00
|
|
|
PREFERENCES_CONTEXT Preferences;
|
2004-12-29 22:37:14 +00:00
|
|
|
|
|
|
|
#define GetDialogData(hwndDlg, type) \
|
2005-09-26 19:15:27 +00:00
|
|
|
( P##type )GetWindowLongPtr((hwndDlg), DWLP_USER)
|
2004-12-29 22:37:14 +00:00
|
|
|
#define GetWindowData(hwnd, type) \
|
2005-09-26 19:15:27 +00:00
|
|
|
( P##type )GetWindowLongPtr((hwnd), GWL_USERDATA)
|
2004-12-29 22:37:14 +00:00
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2004-12-29 22:37:14 +00:00
|
|
|
|
|
|
|
typedef struct _PREFERENCES_FILL_DEVICES
|
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
PPREFERENCES_CONTEXT PrefContext;
|
|
|
|
HWND hComboBox;
|
|
|
|
UINT Selected;
|
2004-12-29 22:37:14 +00:00
|
|
|
} PREFERENCES_FILL_DEVICES, *PPREFERENCES_FILL_DEVICES;
|
|
|
|
|
|
|
|
static BOOL CALLBACK
|
2005-09-26 19:15:27 +00:00
|
|
|
FillDeviceComboBox(PSND_MIXER Mixer,
|
|
|
|
UINT Id,
|
|
|
|
LPCTSTR ProductName,
|
|
|
|
PVOID Context)
|
2004-12-29 22:37:14 +00:00
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
LRESULT lres;
|
|
|
|
PPREFERENCES_FILL_DEVICES FillContext = (PPREFERENCES_FILL_DEVICES)Context;
|
|
|
|
|
2006-07-18 14:39:37 +00:00
|
|
|
UNREFERENCED_PARAMETER(Mixer);
|
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
lres = SendMessage(FillContext->hComboBox,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)ProductName);
|
|
|
|
if (lres != CB_ERR)
|
2004-12-29 22:37:14 +00:00
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
/* save the index so we don't screw stuff when the combobox is sorted... */
|
|
|
|
SendMessage(FillContext->hComboBox,
|
|
|
|
CB_SETITEMDATA,
|
|
|
|
(WPARAM)lres,
|
|
|
|
Id);
|
|
|
|
|
|
|
|
if (Id == FillContext->Selected)
|
|
|
|
{
|
|
|
|
SendMessage(FillContext->hComboBox,
|
|
|
|
CB_SETCURSEL,
|
|
|
|
(WPARAM)lres,
|
|
|
|
0);
|
|
|
|
}
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
return TRUE;
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
static BOOL CALLBACK
|
|
|
|
PrefDlgAddLine(PSND_MIXER Mixer,
|
|
|
|
LPMIXERLINE Line,
|
2005-09-27 13:42:20 +00:00
|
|
|
UINT DisplayControls,
|
2005-09-27 01:02:15 +00:00
|
|
|
PVOID Context)
|
|
|
|
{
|
|
|
|
PPREFERENCES_CONTEXT PrefContext = (PPREFERENCES_CONTEXT)Context;
|
2006-07-18 14:39:37 +00:00
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(Mixer);
|
|
|
|
UNREFERENCED_PARAMETER(DisplayControls);
|
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
switch (Line->dwComponentType)
|
|
|
|
{
|
|
|
|
case MIXERLINE_COMPONENTTYPE_DST_SPEAKERS:
|
|
|
|
if (PrefContext->PlaybackID == (DWORD)-1)
|
|
|
|
{
|
|
|
|
PrefContext->PlaybackID = Line->dwLineID;
|
|
|
|
|
|
|
|
if (PrefContext->SelectedLine == (DWORD)-1)
|
|
|
|
{
|
|
|
|
PrefContext->SelectedLine = Line->dwLineID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
goto AddToOthersLines;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MIXERLINE_COMPONENTTYPE_DST_WAVEIN:
|
|
|
|
if (PrefContext->RecordingID == (DWORD)-1)
|
|
|
|
{
|
|
|
|
PrefContext->RecordingID = Line->dwLineID;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
if (PrefContext->SelectedLine == (DWORD)-1)
|
|
|
|
{
|
|
|
|
PrefContext->SelectedLine = Line->dwLineID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
goto AddToOthersLines;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
LRESULT lres;
|
|
|
|
HWND hwndCbOthers;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
if (PrefContext->SelectedLine == (DWORD)-1)
|
|
|
|
{
|
|
|
|
PrefContext->SelectedLine = Line->dwLineID;
|
|
|
|
}
|
|
|
|
|
|
|
|
AddToOthersLines:
|
|
|
|
hwndCbOthers = GetDlgItem(PrefContext->hwndDlg,
|
|
|
|
IDC_LINE);
|
|
|
|
|
|
|
|
lres = SendMessage(hwndCbOthers,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)Line->szName);
|
|
|
|
if (lres != CB_ERR)
|
|
|
|
{
|
|
|
|
SendMessage(hwndCbOthers,
|
|
|
|
CB_SETITEMDATA,
|
|
|
|
(WPARAM)lres,
|
|
|
|
Line->dwLineID);
|
|
|
|
|
|
|
|
PrefContext->OtherLines++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL CALLBACK
|
|
|
|
PrefDlgAddConnection(PSND_MIXER Mixer,
|
|
|
|
DWORD LineID,
|
|
|
|
LPMIXERLINE Line,
|
|
|
|
PVOID Context)
|
|
|
|
{
|
|
|
|
PPREFERENCES_CONTEXT PrefContext = (PPREFERENCES_CONTEXT)Context;
|
2005-09-27 01:48:49 +00:00
|
|
|
HWND hwndControls;
|
2005-09-27 01:02:15 +00:00
|
|
|
LVITEM lvi;
|
2005-09-27 01:48:49 +00:00
|
|
|
UINT i;
|
2006-07-18 14:39:37 +00:00
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(Mixer);
|
|
|
|
UNREFERENCED_PARAMETER(LineID);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:48:49 +00:00
|
|
|
if (Line->cControls != 0)
|
|
|
|
{
|
|
|
|
hwndControls = GetDlgItem(PrefContext->hwndDlg,
|
|
|
|
IDC_CONTROLS);
|
|
|
|
|
|
|
|
lvi.mask = LVIF_TEXT | LVIF_PARAM;
|
|
|
|
lvi.iItem = PrefContext->tmp++;
|
|
|
|
lvi.iSubItem = 0;
|
|
|
|
lvi.pszText = Line->szName;
|
|
|
|
lvi.lParam = (LPARAM)Line->dwSource;
|
|
|
|
|
|
|
|
i = SendMessage(hwndControls,
|
|
|
|
LVM_INSERTITEM,
|
|
|
|
0,
|
|
|
|
(LPARAM)&lvi);
|
|
|
|
if (i != (UINT)-1)
|
|
|
|
{
|
2005-09-27 13:42:20 +00:00
|
|
|
TCHAR LineName[MIXER_LONG_NAME_CHARS];
|
|
|
|
DWORD Flags;
|
|
|
|
BOOL SelLine = FALSE;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 13:42:20 +00:00
|
|
|
if (SndMixerGetLineName(PrefContext->Mixer,
|
|
|
|
PrefContext->SelectedLine,
|
|
|
|
LineName,
|
|
|
|
MIXER_LONG_NAME_CHARS,
|
2011-04-09 10:36:25 +00:00
|
|
|
TRUE) == -1)
|
2005-09-27 13:42:20 +00:00
|
|
|
{
|
|
|
|
LineName[0] = TEXT('\0');
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 13:42:20 +00:00
|
|
|
if (ReadLineConfig(PrefContext->DeviceName,
|
|
|
|
LineName,
|
|
|
|
Line->szName,
|
|
|
|
&Flags))
|
|
|
|
{
|
|
|
|
if (Flags != 0x4)
|
|
|
|
{
|
|
|
|
SelLine = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-27 01:48:49 +00:00
|
|
|
ListView_SetCheckState(hwndControls,
|
|
|
|
i,
|
2005-09-27 13:42:20 +00:00
|
|
|
SelLine);
|
2005-09-27 01:48:49 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
UpdatePrefDlgControls(PPREFERENCES_CONTEXT Context,
|
|
|
|
DWORD LineID)
|
|
|
|
{
|
2008-12-03 17:34:49 +00:00
|
|
|
INT OldID, MixerID = 0;
|
2005-09-27 01:02:15 +00:00
|
|
|
INT DeviceCbIndex;
|
|
|
|
|
|
|
|
/* select the mixer */
|
2005-09-27 13:42:20 +00:00
|
|
|
DeviceCbIndex = SendDlgItemMessage(Context->hwndDlg,
|
|
|
|
IDC_MIXERDEVICE,
|
|
|
|
CB_GETCURSEL,
|
|
|
|
0,
|
|
|
|
0);
|
2005-09-27 01:02:15 +00:00
|
|
|
if (DeviceCbIndex != CB_ERR)
|
|
|
|
{
|
2005-09-27 13:42:20 +00:00
|
|
|
MixerID = SendDlgItemMessage(Context->hwndDlg,
|
|
|
|
IDC_MIXERDEVICE,
|
|
|
|
CB_GETITEMDATA,
|
|
|
|
DeviceCbIndex,
|
|
|
|
0);
|
2005-09-27 01:02:15 +00:00
|
|
|
if (MixerID == CB_ERR)
|
|
|
|
{
|
|
|
|
MixerID = 0;
|
|
|
|
}
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
OldID = Context->Selected;
|
|
|
|
if (MixerID != OldID &&
|
|
|
|
SndMixerSelect(Context->Mixer,
|
|
|
|
MixerID))
|
|
|
|
{
|
|
|
|
Context->Selected = SndMixerGetSelection(Context->Mixer);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
/* update the controls */
|
|
|
|
Context->PlaybackID = (DWORD)-1;
|
|
|
|
Context->RecordingID = (DWORD)-1;
|
|
|
|
Context->OtherLines = 0;
|
|
|
|
Context->SelectedLine = (DWORD)-1;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 13:42:20 +00:00
|
|
|
SndMixerGetProductName(Context->Mixer,
|
|
|
|
Context->DeviceName,
|
|
|
|
sizeof(Context->DeviceName) / sizeof(Context->DeviceName[0]));
|
2005-09-27 01:02:15 +00:00
|
|
|
|
|
|
|
if (SndMixerEnumLines(Context->Mixer,
|
|
|
|
PrefDlgAddLine,
|
|
|
|
Context))
|
|
|
|
{
|
|
|
|
UINT SelBox = 0;
|
|
|
|
|
|
|
|
/* enable/disable controls and make default selection */
|
|
|
|
EnableWindow(GetDlgItem(Context->hwndDlg,
|
|
|
|
IDC_PLAYBACK),
|
|
|
|
Context->PlaybackID != (DWORD)-1);
|
|
|
|
CheckDlgButton(Context->hwndDlg,
|
|
|
|
IDC_PLAYBACK,
|
|
|
|
(Context->PlaybackID != (DWORD)-1 && SelBox++ == 0) ?
|
|
|
|
BST_CHECKED : BST_UNCHECKED);
|
|
|
|
|
|
|
|
EnableWindow(GetDlgItem(Context->hwndDlg,
|
|
|
|
IDC_RECORDING),
|
|
|
|
Context->RecordingID != (DWORD)-1);
|
|
|
|
CheckDlgButton(Context->hwndDlg,
|
|
|
|
IDC_RECORDING,
|
|
|
|
(Context->RecordingID != (DWORD)-1 && SelBox++ == 0) ?
|
|
|
|
BST_CHECKED : BST_UNCHECKED);
|
|
|
|
|
|
|
|
if (Context->OtherLines != 0)
|
|
|
|
{
|
|
|
|
/* select the first item in the other lines combo box by default */
|
2005-09-27 13:42:20 +00:00
|
|
|
SendDlgItemMessage(Context->hwndDlg,
|
|
|
|
IDC_LINE,
|
|
|
|
CB_SETCURSEL,
|
|
|
|
0,
|
|
|
|
0);
|
2005-09-27 01:02:15 +00:00
|
|
|
}
|
|
|
|
EnableWindow(GetDlgItem(Context->hwndDlg,
|
|
|
|
IDC_LINE),
|
2005-09-27 01:48:49 +00:00
|
|
|
FALSE);
|
|
|
|
EnableWindow(GetDlgItem(Context->hwndDlg,
|
|
|
|
IDC_OTHER),
|
2005-09-27 01:02:15 +00:00
|
|
|
Context->OtherLines != 0);
|
|
|
|
CheckDlgButton(Context->hwndDlg,
|
|
|
|
IDC_LINE,
|
|
|
|
(Context->OtherLines != 0 && SelBox++ == 0) ?
|
|
|
|
BST_CHECKED : BST_UNCHECKED);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
/* disable the OK button if the device doesn't have any lines */
|
|
|
|
EnableWindow(GetDlgItem(Context->hwndDlg,
|
|
|
|
IDOK),
|
|
|
|
Context->PlaybackID != (DWORD)-1 ||
|
|
|
|
Context->RecordingID != (DWORD)-1 ||
|
|
|
|
Context->OtherLines != 0);
|
|
|
|
|
|
|
|
LineID = Context->SelectedLine;
|
|
|
|
}
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
/* update the line sources list */
|
|
|
|
if ((MixerID != OldID && Context->SelectedLine != (DWORD)-1) ||
|
|
|
|
(Context->SelectedLine != LineID && LineID != (DWORD)-1))
|
|
|
|
{
|
|
|
|
Context->SelectedLine = LineID;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2006-06-01 21:18:22 +00:00
|
|
|
(void)ListView_DeleteAllItems(GetDlgItem(Context->hwndDlg,
|
|
|
|
IDC_CONTROLS));
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:48:49 +00:00
|
|
|
Context->tmp = 0;
|
2005-09-27 01:02:15 +00:00
|
|
|
SndMixerEnumConnections(Context->Mixer,
|
|
|
|
LineID,
|
|
|
|
PrefDlgAddConnection,
|
|
|
|
Context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-07 21:31:21 +00:00
|
|
|
static
|
|
|
|
VOID
|
2011-04-09 10:36:25 +00:00
|
|
|
WriteLineSettings(PPREFERENCES_CONTEXT Context, HWND hwndDlg)
|
2011-04-07 21:31:21 +00:00
|
|
|
{
|
|
|
|
HWND hwndControls;
|
|
|
|
INT Count, Index;
|
|
|
|
WCHAR LineName[MIXER_LONG_NAME_CHARS];
|
|
|
|
WCHAR DestinationName[MIXER_LONG_NAME_CHARS];
|
|
|
|
DWORD Flags;
|
2011-04-08 22:04:41 +00:00
|
|
|
PSNDVOL_REG_LINESTATE LineStates;
|
2011-04-07 21:31:21 +00:00
|
|
|
|
|
|
|
/* get list view */
|
|
|
|
hwndControls = GetDlgItem(hwndDlg, IDC_CONTROLS);
|
|
|
|
|
|
|
|
/* get list item count */
|
|
|
|
Count = ListView_GetItemCount(hwndControls);
|
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
assert(Count);
|
|
|
|
|
2011-04-09 10:36:25 +00:00
|
|
|
if (SndMixerGetLineName(Context->Mixer, Context->SelectedLine, DestinationName, MIXER_LONG_NAME_CHARS, TRUE) == -1)
|
2011-04-07 21:31:21 +00:00
|
|
|
{
|
|
|
|
/* failed to get destination line name */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate line states array */
|
2011-04-08 22:04:41 +00:00
|
|
|
LineStates = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SNDVOL_REG_LINESTATE) * Count);
|
|
|
|
if (LineStates == NULL)
|
|
|
|
{
|
|
|
|
/* failed to allocate line states array */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-07 21:31:21 +00:00
|
|
|
for(Index = 0; Index < Count; Index++)
|
|
|
|
{
|
|
|
|
/* set to empty */
|
|
|
|
LineName[0] = L'\0';
|
|
|
|
|
|
|
|
/* get item text */
|
|
|
|
ListView_GetItemText(hwndControls, Index, 0, LineName, MIXER_LONG_NAME_CHARS);
|
|
|
|
|
|
|
|
/* make sure it is null terminated */
|
|
|
|
LineName[MIXER_LONG_NAME_CHARS-1] = L'\0';
|
|
|
|
|
|
|
|
/* get check state */
|
|
|
|
Flags = (ListView_GetCheckState(hwndControls, Index) == 0 ? 0x4 : 0);
|
|
|
|
|
2011-04-08 22:04:41 +00:00
|
|
|
/* copy line name */
|
|
|
|
wcscpy(LineStates[Index].LineName, LineName);
|
|
|
|
|
|
|
|
/* store flags */
|
|
|
|
LineStates[Index].Flags = Flags;
|
2011-04-07 21:31:21 +00:00
|
|
|
}
|
|
|
|
|
2011-04-08 22:04:41 +00:00
|
|
|
/* now write the line config */
|
2011-04-09 10:36:25 +00:00
|
|
|
WriteLineConfig(Context->DeviceName, DestinationName, LineStates, sizeof(SNDVOL_REG_LINESTATE) * Count);
|
2011-04-07 21:31:21 +00:00
|
|
|
|
2011-04-08 22:04:41 +00:00
|
|
|
/* free line states */
|
|
|
|
HeapFree(GetProcessHeap(), 0, LineStates);
|
2011-04-07 21:31:21 +00:00
|
|
|
}
|
|
|
|
|
2004-12-29 22:37:14 +00:00
|
|
|
static INT_PTR CALLBACK
|
2005-09-26 19:15:27 +00:00
|
|
|
DlgPreferencesProc(HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
2004-12-29 22:37:14 +00:00
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
PPREFERENCES_CONTEXT Context;
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
switch (uMsg)
|
2004-12-29 22:37:14 +00:00
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
case WM_COMMAND:
|
2004-12-29 22:37:14 +00:00
|
|
|
{
|
2005-09-27 01:02:15 +00:00
|
|
|
Context = GetDialogData(hwndDlg,
|
|
|
|
PREFERENCES_CONTEXT);
|
2005-09-26 19:15:27 +00:00
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2005-09-27 01:02:15 +00:00
|
|
|
case IDC_MIXERDEVICE:
|
|
|
|
{
|
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
UpdatePrefDlgControls(Context,
|
|
|
|
(DWORD)-1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
case IDC_LINE:
|
|
|
|
{
|
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
|
|
|
{
|
2008-12-03 17:34:49 +00:00
|
|
|
INT LineID;
|
|
|
|
INT Index;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 13:42:20 +00:00
|
|
|
Index = SendDlgItemMessage(hwndDlg,
|
|
|
|
IDC_LINE,
|
|
|
|
CB_GETCURSEL,
|
|
|
|
0,
|
|
|
|
0);
|
2005-09-27 01:48:49 +00:00
|
|
|
if (Index != CB_ERR)
|
|
|
|
{
|
2005-09-27 13:42:20 +00:00
|
|
|
LineID = SendDlgItemMessage(hwndDlg,
|
|
|
|
IDC_LINE,
|
|
|
|
CB_GETITEMDATA,
|
|
|
|
Index,
|
|
|
|
0);
|
2005-09-27 01:48:49 +00:00
|
|
|
if (LineID != CB_ERR)
|
|
|
|
{
|
|
|
|
UpdatePrefDlgControls(Context,
|
|
|
|
LineID);
|
|
|
|
}
|
|
|
|
}
|
2005-09-27 01:02:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
case IDC_PLAYBACK:
|
|
|
|
{
|
|
|
|
UpdatePrefDlgControls(Context,
|
|
|
|
Context->PlaybackID);
|
2005-09-27 01:48:49 +00:00
|
|
|
EnableWindow(GetDlgItem(hwndDlg,
|
|
|
|
IDC_LINE),
|
|
|
|
FALSE);
|
2005-09-27 01:02:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
case IDC_RECORDING:
|
|
|
|
{
|
|
|
|
UpdatePrefDlgControls(Context,
|
|
|
|
Context->RecordingID);
|
2005-09-27 01:48:49 +00:00
|
|
|
EnableWindow(GetDlgItem(hwndDlg,
|
|
|
|
IDC_LINE),
|
|
|
|
FALSE);
|
2005-09-27 01:02:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
case IDC_OTHER:
|
|
|
|
{
|
|
|
|
INT LineCbIndex;
|
2008-12-03 17:34:49 +00:00
|
|
|
INT LineID;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:48:49 +00:00
|
|
|
EnableWindow(GetDlgItem(hwndDlg,
|
|
|
|
IDC_LINE),
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
LineCbIndex = SendDlgItemMessage(hwndDlg,
|
|
|
|
IDC_LINE,
|
|
|
|
CB_GETCURSEL,
|
|
|
|
0,
|
|
|
|
0);
|
2005-09-27 01:02:15 +00:00
|
|
|
if (LineCbIndex != CB_ERR)
|
|
|
|
{
|
2005-09-27 01:48:49 +00:00
|
|
|
LineID = SendDlgItemMessage(hwndDlg,
|
|
|
|
IDC_LINE,
|
|
|
|
CB_GETITEMDATA,
|
|
|
|
LineCbIndex,
|
|
|
|
0);
|
2005-09-27 01:02:15 +00:00
|
|
|
if (LineID != CB_ERR)
|
|
|
|
{
|
|
|
|
UpdatePrefDlgControls(Context,
|
|
|
|
LineID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
case IDOK:
|
2011-04-07 21:31:21 +00:00
|
|
|
{
|
|
|
|
/* write line settings */
|
2011-04-09 10:36:25 +00:00
|
|
|
WriteLineSettings(Context, hwndDlg);
|
2011-04-07 21:31:21 +00:00
|
|
|
|
|
|
|
/* fall through */
|
|
|
|
}
|
2005-09-26 19:15:27 +00:00
|
|
|
case IDCANCEL:
|
|
|
|
{
|
|
|
|
EndDialog(hwndDlg,
|
|
|
|
LOWORD(wParam));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
PREFERENCES_FILL_DEVICES FillDevContext;
|
2005-09-27 01:02:15 +00:00
|
|
|
LVCOLUMN lvc;
|
|
|
|
RECT rcClient;
|
|
|
|
HWND hwndControls;
|
2005-09-26 19:15:27 +00:00
|
|
|
|
|
|
|
SetWindowLongPtr(hwndDlg,
|
|
|
|
DWLP_USER,
|
|
|
|
(LONG_PTR)lParam);
|
|
|
|
Context = (PPREFERENCES_CONTEXT)((LONG_PTR)lParam);
|
|
|
|
Context->hwndDlg = hwndDlg;
|
|
|
|
Context->Mixer = SndMixerCreate(hwndDlg);
|
2005-09-27 01:02:15 +00:00
|
|
|
Context->Selected = (UINT)-1;
|
2005-09-26 19:15:27 +00:00
|
|
|
|
|
|
|
FillDevContext.PrefContext = Context;
|
|
|
|
FillDevContext.hComboBox = GetDlgItem(hwndDlg,
|
|
|
|
IDC_MIXERDEVICE);
|
|
|
|
FillDevContext.Selected = SndMixerGetSelection(Context->Mixer);
|
|
|
|
SndMixerEnumProducts(Context->Mixer,
|
|
|
|
FillDeviceComboBox,
|
|
|
|
&FillDevContext);
|
2005-09-27 01:02:15 +00:00
|
|
|
|
|
|
|
/* initialize the list view control */
|
|
|
|
hwndControls = GetDlgItem(hwndDlg,
|
|
|
|
IDC_CONTROLS);
|
2006-06-01 21:18:22 +00:00
|
|
|
(void)ListView_SetExtendedListViewStyle(hwndControls,
|
|
|
|
LVS_EX_CHECKBOXES);
|
2005-09-27 01:02:15 +00:00
|
|
|
|
|
|
|
GetClientRect(hwndControls,
|
|
|
|
&rcClient);
|
|
|
|
lvc.mask = LVCF_TEXT | LVCF_WIDTH;
|
|
|
|
lvc.pszText = TEXT("");
|
|
|
|
lvc.cx = rcClient.right;
|
|
|
|
SendMessage(hwndControls,
|
|
|
|
LVM_INSERTCOLUMN,
|
|
|
|
0,
|
|
|
|
(LPARAM)&lvc);
|
|
|
|
|
|
|
|
/* update all controls */
|
|
|
|
UpdatePrefDlgControls(Context,
|
2011-04-09 10:36:25 +00:00
|
|
|
(DWORD)Context->SelectedLine);
|
2005-09-26 19:15:27 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
case WM_CLOSE:
|
|
|
|
{
|
|
|
|
EndDialog(hwndDlg,
|
|
|
|
IDCANCEL);
|
|
|
|
break;
|
|
|
|
}
|
2011-04-30 19:32:37 +00:00
|
|
|
|
|
|
|
case WM_SYSCOLORCHANGE:
|
|
|
|
{
|
|
|
|
HWND hwndControls;
|
|
|
|
|
2011-05-01 12:53:10 +00:00
|
|
|
/* Forward WM_SYSCOLORCHANGE */
|
2011-04-30 19:32:37 +00:00
|
|
|
hwndControls = GetDlgItem(hwndDlg, IDC_CONTROLS);
|
|
|
|
SendMessage(hwndControls, WM_SYSCOLORCHANGE, 0, 0);
|
|
|
|
break;
|
|
|
|
}
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
return 0;
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
|
|
|
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2004-12-29 22:37:14 +00:00
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
DeleteMixerWindowControls(PMIXER_WINDOW MixerWindow)
|
|
|
|
{
|
2011-04-06 21:05:05 +00:00
|
|
|
DWORD Index;
|
|
|
|
|
|
|
|
for(Index = 0; Index < MixerWindow->WindowCount; Index++)
|
|
|
|
{
|
|
|
|
/* destroys the window */
|
|
|
|
DestroyWindow(MixerWindow->Window[Index]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free memory */
|
|
|
|
HeapFree(GetProcessHeap(), 0, MixerWindow->Window);
|
|
|
|
|
|
|
|
/* set to null */
|
|
|
|
MixerWindow->Window = NULL;
|
|
|
|
MixerWindow->WindowCount = 0;
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
|
|
|
|
2005-09-28 13:00:05 +00:00
|
|
|
static BOOL
|
2011-04-06 21:05:05 +00:00
|
|
|
RebuildMixerWindowControls(PPREFERENCES_CONTEXT PrefContext)
|
2004-12-29 22:37:14 +00:00
|
|
|
{
|
2011-04-06 21:05:05 +00:00
|
|
|
/* delete existing mixer controls */
|
|
|
|
DeleteMixerWindowControls(PrefContext->MixerWindow);
|
|
|
|
|
|
|
|
/* load new mixer controls */
|
|
|
|
LoadDialogCtrls(PrefContext);
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
return TRUE;
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
|
|
|
|
2011-04-07 21:31:21 +00:00
|
|
|
static
|
|
|
|
BOOL
|
|
|
|
CALLBACK
|
|
|
|
SetVolumeCallback(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVOID Ctx)
|
|
|
|
{
|
|
|
|
UINT ControlCount = 0, Index;
|
|
|
|
LPMIXERCONTROL Control = NULL;
|
|
|
|
MIXERCONTROLDETAILS_UNSIGNED uDetails;
|
|
|
|
MIXERCONTROLDETAILS_BOOLEAN bDetails;
|
|
|
|
PSET_VOLUME_CONTEXT Context = (PSET_VOLUME_CONTEXT)Ctx;
|
|
|
|
|
|
|
|
/* check if the line name is equal */
|
|
|
|
if (wcsicmp(Line->szName, Context->LineName))
|
|
|
|
{
|
|
|
|
/* it is not */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* query controls */
|
|
|
|
if (SndMixerQueryControls(Mixer, &ControlCount, Line, &Control) == FALSE)
|
|
|
|
{
|
|
|
|
/* failed to query for controls */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now go through all controls and compare control ids */
|
|
|
|
for(Index = 0; Index < ControlCount; Index++)
|
|
|
|
{
|
|
|
|
if (Context->bVertical)
|
|
|
|
{
|
|
|
|
if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_FADER)
|
|
|
|
{
|
|
|
|
/* FIXME: give me granularity */
|
|
|
|
DWORD Step = 0x10000 / 5;
|
|
|
|
|
|
|
|
/* set up details */
|
|
|
|
uDetails.dwValue = 0x10000 - Step * Context->SliderPos;
|
|
|
|
|
|
|
|
/* set volume */
|
|
|
|
SndMixerSetVolumeControlDetails(Preferences.MixerWindow->Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_UNSIGNED), (LPVOID)&uDetails);
|
|
|
|
|
|
|
|
/* done */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (Context->bSwitch)
|
|
|
|
{
|
|
|
|
if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_SWITCH)
|
|
|
|
{
|
|
|
|
/* set up details */
|
|
|
|
bDetails.fValue = Context->SliderPos;
|
|
|
|
|
|
|
|
/* set volume */
|
|
|
|
SndMixerSetVolumeControlDetails(Preferences.MixerWindow->Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_BOOLEAN), (LPVOID)&bDetails);
|
|
|
|
|
|
|
|
/* done */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FIXME: implement left - right channel switch support */
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free controls */
|
|
|
|
HeapFree(GetProcessHeap(), 0, Control);
|
|
|
|
|
|
|
|
|
|
|
|
/* done */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
BOOL
|
|
|
|
CALLBACK
|
|
|
|
MixerControlChangeCallback(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVOID Context)
|
|
|
|
{
|
|
|
|
UINT ControlCount = 0, Index;
|
|
|
|
LPMIXERCONTROL Control = NULL;
|
|
|
|
|
|
|
|
/* check if the line has controls */
|
|
|
|
if (Line->cControls == 0)
|
|
|
|
{
|
|
|
|
/* no controls */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* query controls */
|
|
|
|
if (SndMixerQueryControls(Mixer, &ControlCount, Line, &Control) == FALSE)
|
|
|
|
{
|
|
|
|
/* failed to query for controls */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now go through all controls and compare control ids */
|
|
|
|
for(Index = 0; Index < ControlCount; Index++)
|
|
|
|
{
|
|
|
|
if (Control[Index].dwControlID == PtrToUlong(Context))
|
|
|
|
{
|
|
|
|
if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_SWITCH)
|
|
|
|
{
|
|
|
|
MIXERCONTROLDETAILS_BOOLEAN Details;
|
|
|
|
|
|
|
|
/* get volume control details */
|
|
|
|
if (SndMixerGetVolumeControlDetails(Preferences.MixerWindow->Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_BOOLEAN), (LPVOID)&Details) != -1)
|
|
|
|
{
|
|
|
|
/* update dialog control */
|
|
|
|
UpdateDialogLineSwitchControl(&Preferences, Line, Details.fValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_FADER)
|
|
|
|
{
|
|
|
|
MIXERCONTROLDETAILS_UNSIGNED Details;
|
|
|
|
|
|
|
|
/* get volume control details */
|
|
|
|
if (SndMixerGetVolumeControlDetails(Preferences.MixerWindow->Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_UNSIGNED), (LPVOID)&Details) != -1)
|
|
|
|
{
|
|
|
|
/* update dialog control */
|
|
|
|
DWORD Position;
|
|
|
|
DWORD Step = 0x10000 / 5;
|
|
|
|
|
|
|
|
/* FIXME: give me granularity */
|
|
|
|
Position = 5 - (Details.dwValue / Step);
|
|
|
|
|
|
|
|
/* update volume control slider */
|
|
|
|
UpdateDialogLineSliderControl(&Preferences, Line, Control[Index].dwControlID, IDC_LINE_SLIDER_VERT, Position);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free controls */
|
|
|
|
HeapFree(GetProcessHeap(), 0, Control);
|
|
|
|
|
|
|
|
|
|
|
|
/* done */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-28 13:00:05 +00:00
|
|
|
static LRESULT CALLBACK
|
2005-09-26 19:15:27 +00:00
|
|
|
MainWindowProc(HWND hwnd,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
2004-12-29 22:37:14 +00:00
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
PMIXER_WINDOW MixerWindow;
|
2011-04-07 21:31:21 +00:00
|
|
|
DWORD CtrlID, LineOffset;
|
2005-09-26 19:15:27 +00:00
|
|
|
LRESULT Result = 0;
|
2011-04-07 21:31:21 +00:00
|
|
|
SET_VOLUME_CONTEXT Context;
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
switch (uMsg)
|
2004-12-29 22:37:14 +00:00
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
case WM_COMMAND:
|
2004-12-29 22:37:14 +00:00
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
MixerWindow = GetWindowData(hwnd,
|
|
|
|
MIXER_WINDOW);
|
|
|
|
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDC_PROPERTIES:
|
|
|
|
{
|
2011-04-09 10:36:25 +00:00
|
|
|
PREFERENCES_CONTEXT Pref;
|
2005-09-26 19:15:27 +00:00
|
|
|
|
2011-04-09 10:36:25 +00:00
|
|
|
Pref.MixerWindow = MixerWindow;
|
|
|
|
Pref.Mixer = NULL;
|
|
|
|
Pref.SelectedLine = Preferences.SelectedLine;
|
2005-09-26 19:15:27 +00:00
|
|
|
|
|
|
|
if (DialogBoxParam(hAppInstance,
|
|
|
|
MAKEINTRESOURCE(IDD_PREFERENCES),
|
|
|
|
hwnd,
|
|
|
|
DlgPreferencesProc,
|
2011-04-09 10:36:25 +00:00
|
|
|
(LPARAM)&Pref) == IDOK)
|
2005-09-26 19:15:27 +00:00
|
|
|
{
|
2011-04-07 21:31:21 +00:00
|
|
|
/* update window */
|
|
|
|
TCHAR szProduct[MAXPNAMELEN];
|
|
|
|
|
|
|
|
/* get mixer product name */
|
|
|
|
if (SndMixerGetProductName(MixerWindow->Mixer,
|
|
|
|
szProduct,
|
|
|
|
sizeof(szProduct) / sizeof(szProduct[0])) == -1)
|
|
|
|
{
|
|
|
|
/* failed to get name */
|
|
|
|
szProduct[0] = L'\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* copy product */
|
|
|
|
wcscpy(Preferences.DeviceName, szProduct);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* destroy old status bar */
|
|
|
|
DestroyWindow(MixerWindow->hStatusBar);
|
|
|
|
|
2011-04-09 10:36:25 +00:00
|
|
|
/* update details */
|
|
|
|
Preferences.SelectedLine = Pref.SelectedLine;
|
|
|
|
|
|
|
|
/* destroy old mixer */
|
|
|
|
SndMixerDestroy(Preferences.MixerWindow->Mixer);
|
|
|
|
|
|
|
|
/* use new selected mixer */
|
|
|
|
Preferences.MixerWindow->Mixer = Pref.Mixer;
|
|
|
|
|
2011-04-07 21:31:21 +00:00
|
|
|
/* rebuild dialog controls */
|
2011-04-09 10:36:25 +00:00
|
|
|
RebuildMixerWindowControls(&Preferences);
|
2011-04-07 21:31:21 +00:00
|
|
|
|
|
|
|
/* create status window */
|
|
|
|
MixerWindow->hStatusBar = CreateStatusWindow(WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS,
|
|
|
|
NULL,
|
|
|
|
hwnd,
|
|
|
|
0);
|
|
|
|
|
|
|
|
/* set status bar */
|
|
|
|
if (MixerWindow->hStatusBar)
|
|
|
|
{
|
|
|
|
SendMessage(MixerWindow->hStatusBar,
|
|
|
|
WM_SETTEXT,
|
|
|
|
0,
|
|
|
|
(LPARAM)szProduct);
|
|
|
|
}
|
2005-09-26 19:15:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case IDC_EXIT:
|
|
|
|
{
|
|
|
|
PostQuitMessage(0);
|
|
|
|
break;
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-27 01:02:15 +00:00
|
|
|
case IDC_ABOUT:
|
|
|
|
{
|
|
|
|
HICON hAppIcon = (HICON)GetClassLongPtrW(hwnd,
|
|
|
|
GCLP_HICON);
|
|
|
|
ShellAbout(hwnd,
|
|
|
|
lpAppTitle,
|
|
|
|
NULL,
|
|
|
|
hAppIcon);
|
|
|
|
break;
|
|
|
|
}
|
2011-04-07 21:31:21 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
/* get button id */
|
|
|
|
CtrlID = LOWORD(wParam);
|
|
|
|
|
|
|
|
/* check if the message is from the line switch */
|
|
|
|
if (HIWORD(wParam) == BN_CLICKED && (CtrlID % IDC_LINE_SWITCH == 0))
|
|
|
|
{
|
|
|
|
/* compute line offset */
|
|
|
|
LineOffset = CtrlID / IDC_LINE_SWITCH;
|
|
|
|
|
|
|
|
/* compute window id of line name static control */
|
|
|
|
CtrlID = LineOffset * IDC_LINE_NAME;
|
|
|
|
|
|
|
|
/* get line name */
|
|
|
|
if (GetDlgItemTextW(hwnd, CtrlID, Context.LineName, MIXER_LONG_NAME_CHARS) != 0)
|
|
|
|
{
|
|
|
|
/* setup context */
|
|
|
|
Context.SliderPos = SendMessage((HWND)lParam, BM_GETCHECK, 0, 0);
|
|
|
|
Context.bVertical = FALSE;
|
|
|
|
Context.bSwitch = TRUE;
|
|
|
|
|
|
|
|
/* set volume */
|
|
|
|
SndMixerEnumConnections(Preferences.MixerWindow->Mixer, Preferences.SelectedLine, SetVolumeCallback, (LPVOID)&Context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
case MM_MIXM_LINE_CHANGE:
|
2004-12-29 22:37:14 +00:00
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
DPRINT("MM_MIXM_LINE_CHANGE\n");
|
|
|
|
break;
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
case MM_MIXM_CONTROL_CHANGE:
|
2004-12-29 22:37:14 +00:00
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
DPRINT("MM_MIXM_CONTROL_CHANGE\n");
|
2011-04-07 21:31:21 +00:00
|
|
|
|
|
|
|
/* get mixer window */
|
|
|
|
MixerWindow = GetWindowData(hwnd,
|
|
|
|
MIXER_WINDOW);
|
|
|
|
|
|
|
|
/* sanity checks */
|
|
|
|
assert(MixerWindow);
|
|
|
|
assert(MixerWindow->Mixer->hmx == (HMIXER)wParam);
|
|
|
|
|
|
|
|
SndMixerEnumConnections(MixerWindow->Mixer, Preferences.SelectedLine, MixerControlChangeCallback, (PVOID)lParam);
|
2005-09-26 19:15:27 +00:00
|
|
|
break;
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
2005-09-26 19:15:27 +00:00
|
|
|
|
2011-04-07 21:31:21 +00:00
|
|
|
case WM_VSCROLL:
|
|
|
|
{
|
|
|
|
if (LOWORD(wParam) == TB_THUMBTRACK)
|
|
|
|
{
|
|
|
|
/* get dialog item ctrl */
|
|
|
|
CtrlID = GetDlgCtrlID((HWND)lParam);
|
|
|
|
|
|
|
|
/* get line index */
|
|
|
|
LineOffset = CtrlID / IDC_LINE_SLIDER_VERT;
|
|
|
|
|
|
|
|
/* compute window id of line name static control */
|
|
|
|
CtrlID = LineOffset * IDC_LINE_NAME;
|
|
|
|
|
|
|
|
/* get line name */
|
|
|
|
if (GetDlgItemTextW(hwnd, CtrlID, Context.LineName, MIXER_LONG_NAME_CHARS) != 0)
|
|
|
|
{
|
|
|
|
/* setup context */
|
|
|
|
Context.SliderPos = HIWORD(wParam);
|
|
|
|
Context.bVertical = TRUE;
|
|
|
|
Context.bSwitch = FALSE;
|
|
|
|
|
|
|
|
/* set volume */
|
|
|
|
SndMixerEnumConnections(Preferences.MixerWindow->Mixer, Preferences.SelectedLine, SetVolumeCallback, (LPVOID)&Context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
case WM_CREATE:
|
2004-12-29 22:37:14 +00:00
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
MixerWindow = ((LPCREATESTRUCT)lParam)->lpCreateParams;
|
|
|
|
SetWindowLongPtr(hwnd,
|
|
|
|
GWL_USERDATA,
|
|
|
|
(LONG_PTR)MixerWindow);
|
|
|
|
MixerWindow->hWnd = hwnd;
|
2011-04-06 21:05:05 +00:00
|
|
|
MixerWindow->Mixer = SndMixerCreate(MixerWindow->hWnd);
|
|
|
|
if (MixerWindow->Mixer != NULL)
|
2005-09-26 19:15:27 +00:00
|
|
|
{
|
2011-04-06 21:05:05 +00:00
|
|
|
TCHAR szProduct[MAXPNAMELEN];
|
|
|
|
|
|
|
|
/* get mixer product name */
|
|
|
|
if (SndMixerGetProductName(MixerWindow->Mixer,
|
|
|
|
szProduct,
|
|
|
|
sizeof(szProduct) / sizeof(szProduct[0])) == -1)
|
2005-09-26 19:15:27 +00:00
|
|
|
{
|
2011-04-06 21:05:05 +00:00
|
|
|
/* failed to get name */
|
|
|
|
szProduct[0] = L'\0';
|
|
|
|
}
|
2005-09-26 19:15:27 +00:00
|
|
|
|
|
|
|
|
2011-04-06 21:05:05 +00:00
|
|
|
/* initialize perferences */
|
|
|
|
ZeroMemory(&Preferences, sizeof(Preferences));
|
|
|
|
|
|
|
|
/* store mixer */
|
|
|
|
Preferences.Mixer = MixerWindow->Mixer;
|
|
|
|
|
|
|
|
/* store mixer window */
|
|
|
|
Preferences.MixerWindow = MixerWindow;
|
|
|
|
|
|
|
|
/* first destination line id */
|
|
|
|
Preferences.SelectedLine = 0xFFFF0000;
|
|
|
|
|
|
|
|
/* copy product */
|
|
|
|
wcscpy(Preferences.DeviceName, szProduct);
|
|
|
|
|
|
|
|
if (!RebuildMixerWindowControls(&Preferences))
|
2005-09-26 19:15:27 +00:00
|
|
|
{
|
2011-04-06 21:05:05 +00:00
|
|
|
DPRINT("Rebuilding mixer window controls failed!\n");
|
|
|
|
SndMixerDestroy(MixerWindow->Mixer);
|
|
|
|
MixerWindow->Mixer = NULL;
|
2005-09-26 19:15:27 +00:00
|
|
|
Result = -1;
|
|
|
|
}
|
2011-04-06 21:05:05 +00:00
|
|
|
|
|
|
|
/* create status window */
|
|
|
|
MixerWindow->hStatusBar = CreateStatusWindow(WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS,
|
|
|
|
NULL,
|
|
|
|
hwnd,
|
|
|
|
0);
|
|
|
|
if (MixerWindow->hStatusBar)
|
|
|
|
{
|
|
|
|
SendMessage(MixerWindow->hStatusBar,
|
|
|
|
WM_SETTEXT,
|
|
|
|
0,
|
|
|
|
(LPARAM)szProduct);
|
|
|
|
}
|
2005-09-26 19:15:27 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
case WM_DESTROY:
|
|
|
|
{
|
|
|
|
MixerWindow = GetWindowData(hwnd,
|
|
|
|
MIXER_WINDOW);
|
|
|
|
if (MixerWindow->Mixer != NULL)
|
|
|
|
{
|
|
|
|
SndMixerDestroy(MixerWindow->Mixer);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
case WM_CLOSE:
|
|
|
|
{
|
|
|
|
PostQuitMessage(0);
|
|
|
|
break;
|
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
Result = DefWindowProc(hwnd,
|
|
|
|
uMsg,
|
|
|
|
wParam,
|
|
|
|
lParam);
|
|
|
|
break;
|
|
|
|
}
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
return Result;
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL
|
|
|
|
RegisterApplicationClasses(VOID)
|
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
WNDCLASSEX wc;
|
|
|
|
|
|
|
|
wc.cbSize = sizeof(WNDCLASSEX);
|
|
|
|
wc.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
wc.lpfnWndProc = MainWindowProc;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = sizeof(PMIXER_WINDOW);
|
|
|
|
wc.hInstance = hAppInstance;
|
|
|
|
wc.hIcon = LoadIcon(hAppInstance,
|
|
|
|
MAKEINTRESOURCE(IDI_MAINAPP));
|
|
|
|
wc.hCursor = LoadCursor(NULL,
|
|
|
|
IDC_ARROW);
|
|
|
|
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
wc.lpszClassName = SZ_APP_CLASS;
|
|
|
|
wc.hIconSm = NULL;
|
|
|
|
MainWindowClass = RegisterClassEx(&wc);
|
|
|
|
|
|
|
|
return MainWindowClass != 0;
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
UnregisterApplicationClasses(VOID)
|
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
UnregisterClass(SZ_APP_CLASS,
|
|
|
|
hAppInstance);
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HWND
|
|
|
|
CreateApplicationWindow(VOID)
|
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
HWND hWnd;
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
PMIXER_WINDOW MixerWindow = HeapAlloc(hAppHeap,
|
2011-04-06 21:05:05 +00:00
|
|
|
HEAP_ZERO_MEMORY,
|
2005-09-26 19:15:27 +00:00
|
|
|
sizeof(MIXER_WINDOW));
|
|
|
|
if (MixerWindow == NULL)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
if (mixerGetNumDevs() > 0)
|
|
|
|
{
|
|
|
|
hWnd = CreateWindowEx(WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT,
|
|
|
|
SZ_APP_CLASS,
|
|
|
|
lpAppTitle,
|
2011-04-07 21:31:21 +00:00
|
|
|
WS_DLGFRAME | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE,
|
2011-04-06 21:05:05 +00:00
|
|
|
0, 0, 300, 315,
|
2005-09-26 19:15:27 +00:00
|
|
|
NULL,
|
|
|
|
LoadMenu(hAppInstance,
|
|
|
|
MAKEINTRESOURCE(IDM_MAINMENU)),
|
|
|
|
hAppInstance,
|
|
|
|
MixerWindow);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LPTSTR lpErrMessage;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* no mixer devices are available!
|
|
|
|
*/
|
|
|
|
|
|
|
|
hWnd = NULL;
|
2005-09-28 13:00:05 +00:00
|
|
|
if (AllocAndLoadString(&lpErrMessage,
|
|
|
|
hAppInstance,
|
|
|
|
IDS_NOMIXERDEVICES))
|
|
|
|
{
|
|
|
|
MessageBox(NULL,
|
|
|
|
lpErrMessage,
|
|
|
|
lpAppTitle,
|
|
|
|
MB_ICONINFORMATION);
|
|
|
|
LocalFree(lpErrMessage);
|
|
|
|
}
|
2005-09-26 19:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hWnd == NULL)
|
|
|
|
{
|
|
|
|
HeapFree(hAppHeap,
|
|
|
|
0,
|
|
|
|
MixerWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hWnd;
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|
|
|
|
|
2005-05-08 04:07:56 +00:00
|
|
|
int WINAPI
|
2008-05-08 18:26:15 +00:00
|
|
|
_tWinMain(HINSTANCE hInstance,
|
|
|
|
HINSTANCE hPrevInstance,
|
|
|
|
LPTSTR lpszCmdLine,
|
|
|
|
int nCmdShow)
|
2004-12-29 22:37:14 +00:00
|
|
|
{
|
2005-09-26 19:15:27 +00:00
|
|
|
MSG Msg;
|
2005-09-28 13:00:05 +00:00
|
|
|
int Ret = 1;
|
2011-04-06 21:05:05 +00:00
|
|
|
INITCOMMONCONTROLSEX Controls;
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2006-07-18 14:39:37 +00:00
|
|
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
|
|
|
UNREFERENCED_PARAMETER(lpszCmdLine);
|
|
|
|
UNREFERENCED_PARAMETER(nCmdShow);
|
|
|
|
|
2005-09-26 19:15:27 +00:00
|
|
|
hAppInstance = hInstance;
|
|
|
|
hAppHeap = GetProcessHeap();
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-28 13:00:05 +00:00
|
|
|
if (InitAppConfig())
|
2005-09-27 13:42:20 +00:00
|
|
|
{
|
2005-09-28 13:00:05 +00:00
|
|
|
/* load the application title */
|
|
|
|
if (!AllocAndLoadString(&lpAppTitle,
|
|
|
|
hAppInstance,
|
|
|
|
IDS_SNDVOL32))
|
|
|
|
{
|
|
|
|
lpAppTitle = NULL;
|
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2011-04-06 21:05:05 +00:00
|
|
|
Controls.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
|
|
|
Controls.dwICC = ICC_BAR_CLASSES | ICC_STANDARD_CLASSES;
|
|
|
|
|
|
|
|
InitCommonControlsEx(&Controls);
|
2004-12-29 22:37:14 +00:00
|
|
|
|
2005-09-28 13:00:05 +00:00
|
|
|
if (RegisterApplicationClasses())
|
|
|
|
{
|
|
|
|
hMainWnd = CreateApplicationWindow();
|
|
|
|
if (hMainWnd != NULL)
|
|
|
|
{
|
|
|
|
BOOL bRet;
|
|
|
|
while ((bRet =GetMessage(&Msg,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0)) != 0)
|
|
|
|
{
|
|
|
|
if (bRet != -1)
|
|
|
|
{
|
|
|
|
TranslateMessage(&Msg);
|
|
|
|
DispatchMessage(&Msg);
|
|
|
|
}
|
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-28 13:00:05 +00:00
|
|
|
DestroyWindow(hMainWnd);
|
|
|
|
Ret = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-03 10:19:12 +00:00
|
|
|
DPRINT("Failed to create application window (LastError: %d)!\n", GetLastError());
|
2005-09-28 13:00:05 +00:00
|
|
|
}
|
2004-12-29 22:37:14 +00:00
|
|
|
|
2005-09-28 13:00:05 +00:00
|
|
|
UnregisterApplicationClasses();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DPRINT("Failed to register application classes (LastError: %d)!\n", GetLastError());
|
|
|
|
}
|
2004-12-29 22:37:14 +00:00
|
|
|
|
2005-09-28 13:00:05 +00:00
|
|
|
if (lpAppTitle != NULL)
|
|
|
|
{
|
|
|
|
LocalFree(lpAppTitle);
|
|
|
|
}
|
2004-12-29 22:37:14 +00:00
|
|
|
|
2005-09-28 13:00:05 +00:00
|
|
|
CloseAppConfig();
|
|
|
|
}
|
|
|
|
else
|
2005-09-27 01:02:15 +00:00
|
|
|
{
|
2005-09-28 13:00:05 +00:00
|
|
|
DPRINT("Unable to open the Volume Control registry key!\n");
|
2005-09-27 01:02:15 +00:00
|
|
|
}
|
2004-12-29 22:37:14 +00:00
|
|
|
|
2005-09-28 13:00:05 +00:00
|
|
|
return Ret;
|
2004-12-29 22:37:14 +00:00
|
|
|
}
|