ReactOS  0.4.14-dev-115-g4576127
sndvol32.c File Reference
#include "sndvol32.h"
#include <shellapi.h>
Include dependency graph for sndvol32.c:

Go to the source code of this file.

Classes

struct  _PREFERENCES_FILL_DEVICES
 

Macros

#define GetDialogData(hwndDlg, type)   ( P##type )GetWindowLongPtr((hwndDlg), DWLP_USER)
 
#define GetWindowData(hwnd, type)   ( P##type )GetWindowLongPtr((hwnd), GWL_USERDATA)
 

Typedefs

typedef struct _PREFERENCES_FILL_DEVICES PREFERENCES_FILL_DEVICES
 
typedef struct _PREFERENCES_FILL_DEVICESPPREFERENCES_FILL_DEVICES
 

Functions

static BOOL CALLBACK FillDeviceComboBox (PSND_MIXER Mixer, UINT Id, LPCTSTR ProductName, PVOID Context)
 
static BOOL CALLBACK PrefDlgAddLine (PSND_MIXER Mixer, LPMIXERLINE Line, UINT DisplayControls, PVOID Context)
 
static BOOL CALLBACK PrefDlgAddConnection (PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVOID Context)
 
static VOID UpdatePrefDlgControls (PPREFERENCES_CONTEXT Context, DWORD LineID)
 
static VOID WriteLineSettings (PPREFERENCES_CONTEXT Context, HWND hwndDlg)
 
static INT_PTR CALLBACK DlgPreferencesProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID DeleteMixerWindowControls (PMIXER_WINDOW MixerWindow)
 
static BOOL RebuildMixerWindowControls (PPREFERENCES_CONTEXT PrefContext)
 
static BOOL CALLBACK SetVolumeCallback (PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVOID Ctx)
 
static BOOL CALLBACK MixerControlChangeCallback (PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVOID Context)
 
static LRESULT CALLBACK MainWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL RegisterApplicationClasses (VOID)
 
static VOID UnregisterApplicationClasses (VOID)
 
static HWND CreateApplicationWindow (WINDOW_MODE WindowMode, UINT MixerId)
 
static BOOL HandleCommandLine (LPTSTR cmdline, DWORD dwStyle, PWINDOW_MODE pMode, PUINT pMixerId)
 
int WINAPI _tWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmdLine, int nCmdShow)
 

Variables

HINSTANCE hAppInstance
 
ATOM MainWindowClass
 
HWND hMainWnd
 
HANDLE hAppHeap
 
LPTSTR lpAppTitle
 
PREFERENCES_CONTEXT Preferences
 

Macro Definition Documentation

◆ GetDialogData

#define GetDialogData (   hwndDlg,
  type 
)    ( P##type )GetWindowLongPtr((hwndDlg), DWLP_USER)

Definition at line 37 of file sndvol32.c.

◆ GetWindowData

#define GetWindowData (   hwnd,
  type 
)    ( P##type )GetWindowLongPtr((hwnd), GWL_USERDATA)

Definition at line 39 of file sndvol32.c.

Typedef Documentation

◆ PPREFERENCES_FILL_DEVICES

◆ PREFERENCES_FILL_DEVICES

Function Documentation

◆ _tWinMain()

int WINAPI _tWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPTSTR  lpszCmdLine,
int  nCmdShow 
)

Definition at line 1433 of file sndvol32.c.

1437 {
1438  MSG Msg;
1439  int Ret = 1;
1440  INITCOMMONCONTROLSEX Controls;
1441  WINDOW_MODE WindowMode = SMALL_MODE;
1442  UINT MixerId = 0;
1443  DWORD dwStyle;
1444 
1445  UNREFERENCED_PARAMETER(hPrevInstance);
1446  UNREFERENCED_PARAMETER(nCmdShow);
1447 
1450 
1451  if (InitAppConfig())
1452  {
1453  dwStyle = GetStyleValue();
1454  HandleCommandLine(lpszCmdLine, dwStyle, &WindowMode, &MixerId);
1455 
1456  /* load the application title */
1458  hAppInstance,
1459  IDS_SNDVOL32))
1460  {
1461  lpAppTitle = NULL;
1462  }
1463 
1464  Controls.dwSize = sizeof(INITCOMMONCONTROLSEX);
1466 
1467  InitCommonControlsEx(&Controls);
1468 
1469  if (WindowMode == TRAY_MODE)
1470  {
1473  NULL,
1474  TrayDlgProc,
1475  0);
1476  }
1477  else
1478  {
1480  {
1481  hMainWnd = CreateApplicationWindow(WindowMode, MixerId);
1482  if (hMainWnd != NULL)
1483  {
1484  BOOL bRet;
1485  while ((bRet =GetMessage(&Msg,
1486  NULL,
1487  0,
1488  0)) != 0)
1489  {
1490  if (bRet != -1)
1491  {
1493  DispatchMessage(&Msg);
1494  }
1495  }
1496 
1498  Ret = 0;
1499  }
1500  else
1501  {
1502  DPRINT("Failed to create application window (LastError: %d)!\n", GetLastError());
1503  }
1504 
1506  }
1507  else
1508  {
1509  DPRINT("Failed to register application classes (LastError: %d)!\n", GetLastError());
1510  }
1511  }
1512 
1513  if (lpAppTitle != NULL)
1514  {
1516  }
1517 
1518  CloseAppConfig();
1519  }
1520  else
1521  {
1522  DPRINT("Unable to open the Volume Control registry key!\n");
1523  }
1524 
1525  return Ret;
1526 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DispatchMessage
Definition: winuser.h:5666
BOOL WINAPI TranslateMessage(_In_ const MSG *)
LPTSTR lpAppTitle
Definition: sndvol32.c:34
VOID CloseAppConfig(VOID)
Definition: misc.c:152
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
enum _WINDOW_MODE WINDOW_MODE
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
static BOOL RegisterApplicationClasses(VOID)
Definition: sndvol32.c:1278
HINSTANCE hAppInstance
Definition: sndvol32.c:30
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static BOOL HandleCommandLine(LPTSTR cmdline, DWORD dwStyle, PWINDOW_MODE pMode, PUINT pMixerId)
Definition: sndvol32.c:1372
INT_PTR CALLBACK TrayDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: tray.c:262
static INT AllocAndLoadString(OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:60
BOOL WINAPI DestroyWindow(_In_ HWND)
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
HANDLE hAppHeap
Definition: sndvol32.c:33
#define IDS_SNDVOL32
Definition: resources.h:41
HINSTANCE hInstance
Definition: charmap.c:20
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static HWND CreateApplicationWindow(WINDOW_MODE WindowMode, UINT MixerId)
Definition: sndvol32.c:1309
#define ICC_BAR_CLASSES
Definition: commctrl.h:60
#define GetProcessHeap()
Definition: compat.h:395
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DialogBoxParam
Definition: winuser.h:5665
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
struct @1580 Msg[]
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
BOOL InitAppConfig(VOID)
Definition: misc.c:138
unsigned int UINT
Definition: ndis.h:50
#define GetMessage
Definition: winuser.h:5691
#define ICC_STANDARD_CLASSES
Definition: commctrl.h:73
static VOID UnregisterApplicationClasses(VOID)
Definition: sndvol32.c:1302
DWORD GetStyleValue(VOID)
Definition: misc.c:278
HWND hMainWnd
Definition: sndvol32.c:32
#define IDD_TRAY_MASTER
Definition: resources.h:52

◆ CreateApplicationWindow()

static HWND CreateApplicationWindow ( WINDOW_MODE  WindowMode,
UINT  MixerId 
)
static

Definition at line 1309 of file sndvol32.c.

1312 {
1313  HWND hWnd;
1314 
1315  PMIXER_WINDOW MixerWindow = HeapAlloc(hAppHeap,
1317  sizeof(MIXER_WINDOW));
1318  if (MixerWindow == NULL)
1319  {
1320  return NULL;
1321  }
1322 
1323  MixerWindow->Mode = WindowMode;
1324  MixerWindow->MixerId = MixerId;
1325 
1326  if (mixerGetNumDevs() > 0)
1327  {
1329  SZ_APP_CLASS,
1330  lpAppTitle,
1332  0, 0, 300, 315,
1333  NULL,
1336  hAppInstance,
1337  MixerWindow);
1338  }
1339  else
1340  {
1341  LPTSTR lpErrMessage;
1342 
1343  /*
1344  * no mixer devices are available!
1345  */
1346 
1347  hWnd = NULL;
1348  if (AllocAndLoadString(&lpErrMessage,
1349  hAppInstance,
1351  {
1352  MessageBox(NULL,
1353  lpErrMessage,
1354  lpAppTitle,
1356  LocalFree(lpErrMessage);
1357  }
1358  }
1359 
1360  if (hWnd == NULL)
1361  {
1363  0,
1364  MixerWindow);
1365  }
1366 
1367  return hWnd;
1368 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
LPTSTR lpAppTitle
Definition: sndvol32.c:34
UINT MixerId
Definition: sndvol32.h:52
HWND hWnd
Definition: settings.c:17
HINSTANCE hAppInstance
Definition: sndvol32.c:30
#define WS_DLGFRAME
Definition: pedump.c:626
static INT AllocAndLoadString(OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:60
#define WS_CLIPCHILDREN
Definition: pedump.c:619
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define SZ_APP_CLASS
Definition: sndvol32.h:65
HANDLE hAppHeap
Definition: sndvol32.c:33
#define WS_EX_CONTROLPARENT
Definition: winuser.h:387
#define CreateWindowEx
Definition: winuser.h:5656
smooth NULL
Definition: ftsmooth.c:416
#define IDM_MAINMENU
Definition: resources.h:3
#define WS_CAPTION
Definition: pedump.c:624
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
WINDOW_MODE Mode
Definition: sndvol32.h:51
#define MB_ICONINFORMATION
Definition: winuser.h:796
#define MessageBox
Definition: winuser.h:5723
#define LoadMenu
Definition: winuser.h:5718
#define WS_MINIMIZEBOX
Definition: pedump.c:631
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
UINT WINAPI mixerGetNumDevs(void)
Definition: winmm.c:283
#define IDS_NOMIXERDEVICES
Definition: resources.h:42
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_SYSMENU
Definition: pedump.c:629
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by _tWinMain().

◆ DeleteMixerWindowControls()

static VOID DeleteMixerWindowControls ( PMIXER_WINDOW  MixerWindow)
static

Definition at line 597 of file sndvol32.c.

598 {
599  DWORD Index;
600 
601  for(Index = 0; Index < MixerWindow->WindowCount; Index++)
602  {
603  /* destroys the window */
604  DestroyWindow(MixerWindow->Window[Index]);
605  }
606 
607  /* free memory */
608  HeapFree(GetProcessHeap(), 0, MixerWindow->Window);
609 
610  /* set to null */
611  MixerWindow->Window = NULL;
612  MixerWindow->WindowCount = 0;
613 }
BOOL WINAPI DestroyWindow(_In_ HWND)
HWND * Window
Definition: sndvol32.h:48
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
UINT WindowCount
Definition: sndvol32.h:47
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by RebuildMixerWindowControls().

◆ DlgPreferencesProc()

static INT_PTR CALLBACK DlgPreferencesProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 407 of file sndvol32.c.

411 {
413 
414  switch (uMsg)
415  {
416  case WM_COMMAND:
417  {
418  Context = GetDialogData(hwndDlg,
420  switch (LOWORD(wParam))
421  {
422  case IDC_MIXERDEVICE:
423  {
424  if (HIWORD(wParam) == CBN_SELCHANGE)
425  {
427  (DWORD)-1);
428  }
429  break;
430  }
431 
432  case IDC_LINE:
433  {
434  if (HIWORD(wParam) == CBN_SELCHANGE)
435  {
436  INT LineID;
437  INT Index;
438 
439  Index = SendDlgItemMessage(hwndDlg,
440  IDC_LINE,
441  CB_GETCURSEL,
442  0,
443  0);
444  if (Index != CB_ERR)
445  {
446  LineID = SendDlgItemMessage(hwndDlg,
447  IDC_LINE,
449  Index,
450  0);
451  if (LineID != CB_ERR)
452  {
454  LineID);
455  }
456  }
457  }
458  break;
459  }
460 
461  case IDC_PLAYBACK:
462  {
464  Context->PlaybackID);
465  EnableWindow(GetDlgItem(hwndDlg,
466  IDC_LINE),
467  FALSE);
468  break;
469  }
470 
471  case IDC_RECORDING:
472  {
474  Context->RecordingID);
475  EnableWindow(GetDlgItem(hwndDlg,
476  IDC_LINE),
477  FALSE);
478  break;
479  }
480 
481  case IDC_OTHER:
482  {
483  INT LineCbIndex;
484  INT LineID;
485 
486  EnableWindow(GetDlgItem(hwndDlg,
487  IDC_LINE),
488  TRUE);
489 
490  LineCbIndex = SendDlgItemMessage(hwndDlg,
491  IDC_LINE,
492  CB_GETCURSEL,
493  0,
494  0);
495  if (LineCbIndex != CB_ERR)
496  {
497  LineID = SendDlgItemMessage(hwndDlg,
498  IDC_LINE,
500  LineCbIndex,
501  0);
502  if (LineID != CB_ERR)
503  {
505  LineID);
506  }
507  }
508  break;
509  }
510 
511  case IDOK:
512  {
513  /* write line settings */
514  WriteLineSettings(Context, hwndDlg);
515 
516  /* fall through */
517  }
518  case IDCANCEL:
519  {
520  EndDialog(hwndDlg,
521  LOWORD(wParam));
522  break;
523  }
524  }
525  break;
526  }
527 
528  case WM_INITDIALOG:
529  {
530  PREFERENCES_FILL_DEVICES FillDevContext;
531  LVCOLUMN lvc;
532  RECT rcClient;
533  HWND hwndControls;
534 
535  SetWindowLongPtr(hwndDlg,
536  DWLP_USER,
537  (LONG_PTR)lParam);
539  Context->hwndDlg = hwndDlg;
540  Context->Mixer = SndMixerCreate(hwndDlg, Context->MixerWindow->MixerId);
541  Context->Selected = (UINT)-1;
542 
543  FillDevContext.PrefContext = Context;
544  FillDevContext.hComboBox = GetDlgItem(hwndDlg,
546  FillDevContext.Selected = SndMixerGetSelection(Context->Mixer);
549  &FillDevContext);
550 
551  /* initialize the list view control */
552  hwndControls = GetDlgItem(hwndDlg,
553  IDC_CONTROLS);
556 
557  GetClientRect(hwndControls,
558  &rcClient);
559  lvc.mask = LVCF_TEXT | LVCF_WIDTH;
560  lvc.pszText = TEXT("");
561  lvc.cx = rcClient.right;
562  SendMessage(hwndControls,
564  0,
565  (LPARAM)&lvc);
566 
567  /* update all controls */
569  (DWORD)Context->SelectedLine);
570  return TRUE;
571  }
572 
573  case WM_CLOSE:
574  {
575  EndDialog(hwndDlg,
576  IDCANCEL);
577  break;
578  }
579 
580  case WM_SYSCOLORCHANGE:
581  {
582  HWND hwndControls;
583 
584  /* Forward WM_SYSCOLORCHANGE */
585  hwndControls = GetDlgItem(hwndDlg, IDC_CONTROLS);
586  SendMessage(hwndControls, WM_SYSCOLORCHANGE, 0, 0);
587  break;
588  }
589  }
590 
591  return 0;
592 }
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1608
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define IDC_MIXERDEVICE
Definition: resources.h:15
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define LVCF_WIDTH
Definition: commctrl.h:2559
#define LVCF_TEXT
Definition: commctrl.h:2560
#define IDC_CONTROLS
Definition: resources.h:21
#define CB_GETITEMDATA
Definition: winuser.h:1932
struct _PREFERENCES_CONTEXT * PPREFERENCES_CONTEXT
#define SendDlgItemMessage
Definition: winuser.h:5743
LONG right
Definition: windef.h:293
int32_t INT
Definition: typedefs.h:56
#define SetWindowLongPtr
Definition: treelist.c:70
#define CB_GETCURSEL
Definition: winuser.h:1925
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define LVM_INSERTCOLUMN
Definition: commctrl.h:2606
#define LVCOLUMN
Definition: commctrl.h:2553
#define IDC_LINE
Definition: resources.h:19
#define IDC_RECORDING
Definition: resources.h:17
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_ERR
Definition: winuser.h:2410
static BOOL CALLBACK FillDeviceComboBox(PSND_MIXER Mixer, UINT Id, LPCTSTR ProductName, PVOID Context)
Definition: sndvol32.c:54
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_CLOSE
Definition: winuser.h:1603
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
static VOID WriteLineSettings(PPREFERENCES_CONTEXT Context, HWND hwndDlg)
Definition: sndvol32.c:345
#define ListView_SetExtendedListViewStyle(hwndLV, dw)
Definition: commctrl.h:2697
UINT SndMixerGetSelection(PSND_MIXER Mixer)
Definition: mixer.c:361
#define LVS_EX_CHECKBOXES
Definition: commctrl.h:2703
#define GetDialogData(hwndDlg, type)
Definition: sndvol32.c:37
#define DWLP_USER
Definition: winuser.h:866
static VOID UpdatePrefDlgControls(PPREFERENCES_CONTEXT Context, DWORD LineID)
Definition: sndvol32.c:230
BOOL SndMixerEnumProducts(PSND_MIXER Mixer, PFNSNDMIXENUMPRODUCTS EnumProc, PVOID Context)
Definition: mixer.c:431
#define WM_COMMAND
Definition: winuser.h:1722
#define IDC_OTHER
Definition: resources.h:18
PPREFERENCES_CONTEXT PrefContext
Definition: sndvol32.c:48
#define IDC_PLAYBACK
Definition: resources.h:16
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define TEXT(s)
Definition: k32.h:26
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define CBN_SELCHANGE
Definition: winuser.h:1961
#define SendMessage
Definition: winuser.h:5744
struct tagContext Context
Definition: acpixf.h:1024
#define HIWORD(l)
Definition: typedefs.h:246
PSND_MIXER SndMixerCreate(HWND hWndNotification, UINT MixerId)
Definition: mixer.c:69
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by MainWindowProc().

◆ FillDeviceComboBox()

static BOOL CALLBACK FillDeviceComboBox ( PSND_MIXER  Mixer,
UINT  Id,
LPCTSTR  ProductName,
PVOID  Context 
)
static

Definition at line 54 of file sndvol32.c.

58 {
59  LRESULT lres;
61 
63 
64  lres = SendMessage(FillContext->hComboBox,
66  0,
67  (LPARAM)ProductName);
68  if (lres != CB_ERR)
69  {
70  /* save the index so we don't screw stuff when the combobox is sorted... */
71  SendMessage(FillContext->hComboBox,
73  (WPARAM)lres,
74  Id);
75 
76  if (Id == FillContext->Selected)
77  {
78  SendMessage(FillContext->hComboBox,
80  (WPARAM)lres,
81  0);
82  }
83  }
84 
85  return TRUE;
86 }
#define CB_SETITEMDATA
Definition: winuser.h:1948
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
UINT_PTR WPARAM
Definition: windef.h:207
DWORD Id
struct _PREFERENCES_FILL_DEVICES * PPREFERENCES_FILL_DEVICES
#define CB_ADDSTRING
Definition: winuser.h:1918
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_ERR
Definition: winuser.h:2410
#define CB_SETCURSEL
Definition: winuser.h:1943
#define SendMessage
Definition: winuser.h:5744
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by DlgPreferencesProc().

◆ HandleCommandLine()

static BOOL HandleCommandLine ( LPTSTR  cmdline,
DWORD  dwStyle,
PWINDOW_MODE  pMode,
PUINT  pMixerId 
)
static

Definition at line 1372 of file sndvol32.c.

1376 {
1377  TCHAR option;
1378 
1379  *pMixerId = PLAY_MIXER;
1380  *pMode = (dwStyle & 0x20) ? SMALL_MODE : NORMAL_MODE;
1381 
1382  while (*cmdline == _T(' ') || *cmdline == _T('-') || *cmdline == _T('/'))
1383  {
1384  if (*cmdline++ == _T(' '))
1385  continue;
1386 
1387  option = *cmdline;
1388  if (option)
1389  cmdline++;
1390  while (*cmdline == _T(' '))
1391  cmdline++;
1392 
1393  switch (option)
1394  {
1395  case 'd': /* Device */
1396  case 'D':
1397  break;
1398 
1399  case 'n': /* Small size */
1400  case 'N':
1401  *pMode = NORMAL_MODE;
1402  break;
1403 
1404  case 's': /* Small size */
1405  case 'S':
1406  *pMode = SMALL_MODE;
1407  break;
1408 
1409  case 't': /* Tray size */
1410  case 'T':
1411  *pMode = TRAY_MODE;
1412  break;
1413 
1414  case 'p': /* Play mode */
1415  case 'P':
1416  *pMixerId = PLAY_MIXER;
1417  break;
1418 
1419  case 'r': /* Record mode */
1420  case 'R':
1421  *pMixerId = RECORD_MIXER;
1422  break;
1423 
1424  default:
1425  return FALSE;
1426  }
1427  }
1428 
1429  return TRUE;
1430 }
#define TRUE
Definition: types.h:120
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define RECORD_MIXER
Definition: sndvol32.h:30
Definition: getopt.h:108
GLuint GLenum option
Definition: glext.h:11211
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define PLAY_MIXER
Definition: sndvol32.h:29

Referenced by _tWinMain().

◆ MainWindowProc()

static LRESULT CALLBACK MainWindowProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 876 of file sndvol32.c.

880 {
881  PMIXER_WINDOW MixerWindow;
882  DWORD CtrlID, LineOffset;
883  LRESULT Result = 0;
885 
886  switch (uMsg)
887  {
888  case WM_COMMAND:
889  {
890  MixerWindow = GetWindowData(hwnd,
891  MIXER_WINDOW);
892 
893  switch (LOWORD(wParam))
894  {
895  case IDM_PROPERTIES:
896  {
897  PREFERENCES_CONTEXT Pref;
898 
899  Pref.MixerWindow = MixerWindow;
900  Pref.Mixer = NULL;
902 
905  hwnd,
907  (LPARAM)&Pref) == IDOK)
908  {
909  /* update window */
910  TCHAR szProduct[MAXPNAMELEN];
911 
912  /* get mixer product name */
913  if (SndMixerGetProductName(Pref.Mixer,
914  szProduct,
915  sizeof(szProduct) / sizeof(szProduct[0])) == -1)
916  {
917  /* failed to get name */
918  szProduct[0] = L'\0';
919  }
920  else
921  {
922  /* copy product */
923  wcscpy(Preferences.DeviceName, szProduct);
924  }
925 
926  /* destroy old status bar */
927  if (MixerWindow->Mode == NORMAL_MODE)
928  DestroyWindow(MixerWindow->hStatusBar);
929 
930  /* update details */
931  Preferences.SelectedLine = Pref.SelectedLine;
932 
933  /* destroy old mixer */
935 
936  /* use new selected mixer */
937  Preferences.MixerWindow->Mixer = Pref.Mixer;
938 
939  /* create status window */
940  if (MixerWindow->Mode == NORMAL_MODE)
941  {
943  NULL,
944  hwnd,
945  0);
946  if (MixerWindow->hStatusBar)
947  {
948  /* Set status bar */
949  SendMessage(MixerWindow->hStatusBar,
950  WM_SETTEXT,
951  0,
952  (LPARAM)szProduct);
953  }
954  }
955 
956  /* rebuild dialog controls */
958  }
959  break;
960  }
961 
963  MixerWindow->bShowExtendedControls = !MixerWindow->bShowExtendedControls;
968  break;
969 
970  case IDM_EXIT:
971  {
972  PostQuitMessage(0);
973  break;
974  }
975 
976  case IDM_ABOUT:
977  {
978  HICON hAppIcon = (HICON)GetClassLongPtrW(hwnd,
979  GCLP_HICON);
981  lpAppTitle,
982  NULL,
983  hAppIcon);
984  break;
985  }
986 
987  default:
988  {
989  /* get button id */
990  CtrlID = LOWORD(wParam);
991 
992  /* check if the message is from the line switch */
993  if (HIWORD(wParam) == BN_CLICKED)
994  {
995  if (CtrlID % IDC_LINE_SWITCH == 0)
996  {
997  /* compute line offset */
998  LineOffset = CtrlID / IDC_LINE_SWITCH;
999 
1000  /* compute window id of line name static control */
1001  CtrlID = LineOffset * IDC_LINE_NAME;
1002 
1003  if (Preferences.MixerWindow->Mixer->MixerId == PLAY_MIXER)
1004  {
1005  /* get line name */
1006  if (GetDlgItemTextW(hwnd, CtrlID, Context.LineName, MIXER_LONG_NAME_CHARS) != 0)
1007  {
1008  /* setup context */
1009  Context.SliderPos = SendMessage((HWND)lParam, BM_GETCHECK, 0, 0);
1010  Context.bVertical = FALSE;
1011  Context.bSwitch = TRUE;
1012 
1013  /* set volume */
1015  }
1016  }
1017  else if (Preferences.MixerWindow->Mixer->MixerId == RECORD_MIXER)
1018  {
1019  UINT i;
1020 
1021  for (i = 0; i < Preferences.MixerWindow->DialogCount; i++)
1022  {
1023  SendDlgItemMessageW(hwnd, (i + 1) * IDC_LINE_SWITCH, BM_SETCHECK, (WPARAM)((i + 1) == LineOffset), 0);
1024  }
1025  }
1026  }
1027  else if (CtrlID % IDC_LINE_ADVANCED == 0)
1028  {
1029  ADVANCED_CONTEXT AdvancedContext;
1030 
1031  /* compute line offset */
1032  LineOffset = CtrlID / IDC_LINE_ADVANCED;
1033 
1034  /* compute window id of line name static control */
1035  CtrlID = LineOffset * IDC_LINE_NAME;
1036 
1037  /* get line name */
1038  if (GetDlgItemTextW(hwnd, CtrlID, AdvancedContext.LineName, MIXER_LONG_NAME_CHARS) != 0)
1039  {
1040  AdvancedContext.MixerWindow = Preferences.MixerWindow;
1041  AdvancedContext.Mixer = Preferences.MixerWindow->Mixer;
1044  AdvancedContext.LineName);
1045  if (AdvancedContext.Line)
1046  {
1049  hwnd,
1051  (LPARAM)&AdvancedContext);
1052  }
1053  }
1054  }
1055  }
1056  }
1057  }
1058  break;
1059  }
1060 
1061  case MM_MIXM_LINE_CHANGE:
1062  {
1063  DPRINT("MM_MIXM_LINE_CHANGE\n");
1064  break;
1065  }
1066 
1068  {
1069  DPRINT("MM_MIXM_CONTROL_CHANGE\n");
1070 
1071  /* get mixer window */
1072  MixerWindow = GetWindowData(hwnd,
1073  MIXER_WINDOW);
1074 
1075  /* sanity checks */
1076  assert(MixerWindow);
1077  assert(MixerWindow->Mixer->hmx == (HMIXER)wParam);
1078 
1080  break;
1081  }
1082 
1083  case WM_VSCROLL:
1084  switch (LOWORD(wParam))
1085  {
1086  case TB_THUMBTRACK:
1087  /* get dialog item ctrl */
1088  CtrlID = GetDlgCtrlID((HWND)lParam);
1089 
1090  /* get line index */
1091  LineOffset = CtrlID / IDC_LINE_SLIDER_VERT;
1092 
1093  /* compute window id of line name static control */
1094  CtrlID = LineOffset * IDC_LINE_NAME;
1095 
1096  /* get line name */
1097  if (GetDlgItemTextW(hwnd, CtrlID, Context.LineName, MIXER_LONG_NAME_CHARS) != 0)
1098  {
1099  /* setup context */
1100  Context.SliderPos = LineOffset;
1101  Context.bVertical = TRUE;
1102  Context.bSwitch = FALSE;
1103 
1104  /* set volume */
1106  }
1107  break;
1108 
1109  case TB_ENDTRACK:
1110  MixerWindow = GetWindowData(hwnd,
1111  MIXER_WINDOW);
1112 
1113  /* get dialog item ctrl */
1114  CtrlID = GetDlgCtrlID((HWND)lParam);
1115 
1116  /* get line index */
1117  LineOffset = CtrlID / IDC_LINE_SLIDER_VERT;
1118 
1119  if (LineOffset == 1 && MixerWindow->Mixer->MixerId == 0)
1121  break;
1122 
1123  default:
1124  break;
1125  }
1126  break;
1127 
1128  case WM_HSCROLL:
1129  switch (LOWORD(wParam))
1130  {
1131  case TB_THUMBTRACK:
1132  /* get dialog item ctrl */
1133  CtrlID = GetDlgCtrlID((HWND)lParam);
1134 
1135  /* get line index */
1136  LineOffset = CtrlID / IDC_LINE_SLIDER_HORZ;
1137 
1138  /* compute window id of line name static control */
1139  CtrlID = LineOffset * IDC_LINE_NAME;
1140 
1141  /* get line name */
1142  if (GetDlgItemTextW(hwnd, CtrlID, Context.LineName, MIXER_LONG_NAME_CHARS) != 0)
1143  {
1144  /* setup context */
1145  Context.SliderPos = LineOffset;
1146  Context.bVertical = TRUE;
1147  Context.bSwitch = FALSE;
1148 
1149  /* set volume */
1151  }
1152  break;
1153 
1154  case TB_ENDTRACK:
1155  MixerWindow = GetWindowData(hwnd,
1156  MIXER_WINDOW);
1157 
1158  /* get dialog item ctrl */
1159  CtrlID = GetDlgCtrlID((HWND)lParam);
1160 
1161  /* get line index */
1162  LineOffset = CtrlID / IDC_LINE_SLIDER_HORZ;
1163 
1164  if (LineOffset == 1 && MixerWindow->Mixer->MixerId == 0)
1166  break;
1167 
1168  default:
1169  break;
1170  }
1171  break;
1172 
1173 
1174  case WM_CREATE:
1175  {
1176  MixerWindow = ((LPCREATESTRUCT)lParam)->lpCreateParams;
1178  GWL_USERDATA,
1179  (LONG_PTR)MixerWindow);
1180  MixerWindow->hWnd = hwnd;
1181  MixerWindow->Mixer = SndMixerCreate(MixerWindow->hWnd, MixerWindow->MixerId);
1182  if (MixerWindow->Mixer != NULL)
1183  {
1184  TCHAR szProduct[MAXPNAMELEN];
1185 
1186  /* get mixer product name */
1187  if (SndMixerGetProductName(MixerWindow->Mixer,
1188  szProduct,
1189  sizeof(szProduct) / sizeof(szProduct[0])) == -1)
1190  {
1191  /* failed to get name */
1192  szProduct[0] = L'\0';
1193  }
1194 
1195 
1196  /* initialize preferences */
1197  ZeroMemory(&Preferences, sizeof(Preferences));
1198 
1199  /* store mixer */
1200  Preferences.Mixer = MixerWindow->Mixer;
1201 
1202  /* store mixer window */
1203  Preferences.MixerWindow = MixerWindow;
1204 
1205  /* first destination line id */
1206  Preferences.SelectedLine = 0xFFFF0000;
1207 
1208  /* copy product */
1209  wcscpy(Preferences.DeviceName, szProduct);
1210 
1211  /* Disable the 'Advanced Controls' menu item */
1213 
1214  /* create status window */
1215  if (MixerWindow->Mode == NORMAL_MODE)
1216  {
1218  NULL,
1219  hwnd,
1220  0);
1221  if (MixerWindow->hStatusBar)
1222  {
1223  SendMessage(MixerWindow->hStatusBar,
1224  WM_SETTEXT,
1225  0,
1226  (LPARAM)szProduct);
1227  }
1228  }
1229 
1231  {
1232  DPRINT("Rebuilding mixer window controls failed!\n");
1233  SndMixerDestroy(MixerWindow->Mixer);
1234  MixerWindow->Mixer = NULL;
1235  Result = -1;
1236  }
1237  }
1238  break;
1239  }
1240 
1241  case WM_DESTROY:
1242  {
1243  MixerWindow = GetWindowData(hwnd,
1244  MIXER_WINDOW);
1245  if (MixerWindow != NULL)
1246  {
1247  if (MixerWindow->Mixer != NULL)
1248  {
1249  SndMixerDestroy(MixerWindow->Mixer);
1250  }
1251  if (MixerWindow->hFont)
1252  DeleteObject(MixerWindow->hFont);
1253  HeapFree(hAppHeap, 0, MixerWindow);
1254  }
1255  break;
1256  }
1257 
1258  case WM_CLOSE:
1259  {
1260  PostQuitMessage(0);
1261  break;
1262  }
1263 
1264  default:
1265  {
1267  uMsg,
1268  wParam,
1269  lParam);
1270  break;
1271  }
1272  }
1273 
1274  return Result;
1275 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
LPMIXERLINE Line
Definition: sndvol32.h:132
#define TB_THUMBTRACK
Definition: commctrl.h:2050
#define IDC_LINE_SLIDER_VERT
Definition: resources.h:25
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define SND_ALIAS_ID
Definition: mmsystem.h:161
static HICON
Definition: imagelist.c:84
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2208
#define TRUE
Definition: types.h:120
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define IDOK
Definition: winuser.h:824
LPTSTR lpAppTitle
Definition: sndvol32.c:34
#define IDD_PREFERENCES
Definition: resources.h:53
UINT MixerId
Definition: sndvol32.h:52
#define MF_BYCOMMAND
Definition: winuser.h:202
#define IDM_ABOUT
Definition: resource.h:29
static BOOL RebuildMixerWindowControls(PPREFERENCES_CONTEXT PrefContext)
Definition: sndvol32.c:616
PREFERENCES_CONTEXT Preferences
Definition: sndvol32.c:35
HFONT hFont
Definition: sndvol32.h:56
HINSTANCE hAppInstance
Definition: sndvol32.c:30
BOOL SndMixerEnumConnections(PSND_MIXER Mixer, DWORD LineID, PFNSNDMIXENUMCONNECTIONS EnumProc, PVOID Context)
Definition: mixer.c:552
#define assert(x)
Definition: debug.h:53
#define ZeroMemory
Definition: winbase.h:1642
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define GWL_USERDATA
Definition: winuser.h:855
static BOOL CALLBACK SetVolumeCallback(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVOID Ctx)
Definition: sndvol32.c:630
UINT_PTR WPARAM
Definition: windef.h:207
#define WS_CHILD
Definition: pedump.c:617
PSND_MIXER Mixer
Definition: sndvol32.h:106
CREATESTRUCTA * LPCREATESTRUCT
Definition: winuser.h:5627
BOOL WINAPI DestroyWindow(_In_ HWND)
#define RECORD_MIXER
Definition: sndvol32.h:30
#define SetWindowLongPtr
Definition: treelist.c:70
#define IDM_ADVANCED_CONTROLS
Definition: resources.h:10
WPARAM wParam
Definition: combotst.c:138
int WINAPI GetDlgCtrlID(_In_ HWND)
INT_PTR CALLBACK AdvancedDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: advanced.c:225
HANDLE hAppHeap
Definition: sndvol32.c:33
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define CreateStatusWindow
Definition: commctrl.h:1905
struct _SND_MIXER * Mixer
Definition: sndvol32.h:45
#define IDC_LINE_NAME
Definition: resources.h:22
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LONG_PTR LPARAM
Definition: windef.h:208
void DPRINT(...)
Definition: polytest.cpp:61
#define BM_GETCHECK
Definition: winuser.h:1900
PMIXER_WINDOW MixerWindow
Definition: sndvol32.h:130
#define WM_SETTEXT
Definition: winuser.h:1599
BOOL bShowExtendedControls
Definition: sndvol32.h:54
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define SND_ALIAS_SYSTEMDEFAULT
Definition: mmsystem.h:175
UINT DialogCount
Definition: sndvol32.h:49
#define MF_CHECKED
Definition: winuser.h:132
char TCHAR
Definition: xmlstorage.h:189
#define BM_SETCHECK
Definition: winuser.h:1903
PSND_MIXER Mixer
Definition: sndvol32.h:131
#define IDC_LINE_ADVANCED
Definition: resources.h:26
#define WM_CLOSE
Definition: winuser.h:1603
#define GetWindowData(hwnd, type)
Definition: sndvol32.c:39
#define BN_CLICKED
Definition: winuser.h:1907
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define ShellAbout
Definition: shellapi.h:688
#define SND_ASYNC
Definition: mmsystem.h:154
WINDOW_MODE Mode
Definition: sndvol32.h:51
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define TB_ENDTRACK
Definition: commctrl.h:2053
#define DialogBoxParam
Definition: winuser.h:5665
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define GCLP_HICON
Definition: winuser.h:669
#define IDM_PROPERTIES
Definition: resources.h:9
#define WM_COMMAND
Definition: winuser.h:1722
#define MIXER_LONG_NAME_CHARS
Definition: mmsystem.h:294
#define MF_UNCHECKED
Definition: winuser.h:204
TCHAR DeviceName[128]
Definition: sndvol32.h:114
#define PlaySound
Definition: mmsystem.h:2832
#define IDC_LINE_SLIDER_HORZ
Definition: resources.h:24
VOID SndMixerDestroy(PSND_MIXER Mixer)
Definition: mixer.c:91
static BOOL CALLBACK MixerControlChangeCallback(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVOID Context)
Definition: sndvol32.c:755
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
WCHAR LineName[MIXER_LONG_NAME_CHARS]
Definition: sndvol32.h:129
unsigned int UINT
Definition: ndis.h:50
#define WM_HSCROLL
Definition: winuser.h:1725
static INT_PTR CALLBACK DlgPreferencesProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: sndvol32.c:407
#define IDM_EXIT
Definition: resource.h:27
#define PLAY_MIXER
Definition: sndvol32.h:29
#define MAXPNAMELEN
Definition: mmsystem.h:24
#define SendMessage
Definition: winuser.h:5744
#define WM_CREATE
Definition: winuser.h:1590
struct tagContext Context
Definition: acpixf.h:1024
#define HIWORD(l)
Definition: typedefs.h:246
INT SndMixerGetProductName(PSND_MIXER Mixer, LPTSTR lpBuffer, UINT uSize)
Definition: mixer.c:367
#define MM_MIXM_LINE_CHANGE
Definition: mmsystem.h:82
PSND_MIXER SndMixerCreate(HWND hWndNotification, UINT MixerId)
Definition: mixer.c:69
#define MF_GRAYED
Definition: winuser.h:129
LONG_PTR LRESULT
Definition: windef.h:209
#define WS_VISIBLE
Definition: pedump.c:620
#define IDD_ADVANCED
Definition: resource.h:10
HMENU WINAPI GetMenu(_In_ HWND)
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:394
#define GetClassLongPtrW
Definition: winuser.h:4465
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
HWND hStatusBar
Definition: sndvol32.h:44
#define WM_VSCROLL
Definition: winuser.h:1726
PMIXER_WINDOW MixerWindow
Definition: sndvol32.h:105
LPMIXERLINE SndMixerGetLineByName(PSND_MIXER Mixer, DWORD LineID, LPWSTR LineName)
Definition: mixer.c:615
#define IDC_LINE_SWITCH
Definition: resources.h:23
#define MM_MIXM_CONTROL_CHANGE
Definition: mmsystem.h:83

Referenced by RegisterApplicationClasses().

◆ MixerControlChangeCallback()

static BOOL CALLBACK MixerControlChangeCallback ( PSND_MIXER  Mixer,
DWORD  LineID,
LPMIXERLINE  Line,
PVOID  Context 
)
static

Definition at line 755 of file sndvol32.c.

756 {
757  PMIXERCONTROLDETAILS_UNSIGNED pVolumeDetails = NULL;
758  UINT ControlCount = 0, Index;
760 
761  /* check if the line has controls */
762  if (Line->cControls == 0)
763  {
764  /* no controls */
765  return TRUE;
766  }
767 
768  /* query controls */
769  if (SndMixerQueryControls(Mixer, &ControlCount, Line, &Control) == FALSE)
770  {
771  /* failed to query for controls */
772  return FALSE;
773  }
774 
775  pVolumeDetails = HeapAlloc(GetProcessHeap(),
776  0,
777  Line->cChannels * sizeof(MIXERCONTROLDETAILS_UNSIGNED));
778  if (pVolumeDetails == NULL)
779  goto done;
780 
781  /* now go through all controls and compare control ids */
782  for (Index = 0; Index < ControlCount; Index++)
783  {
784  if (Control[Index].dwControlID == PtrToUlong(Context))
785  {
786  if (Control[Index].dwControlType == MIXERCONTROL_CONTROLTYPE_MUTE)
787  {
789 
790  /* get volume control details */
792  {
793  /* update dialog control */
795  }
796  }
797  else if (Control[Index].dwControlType == MIXERCONTROL_CONTROLTYPE_VOLUME)
798  {
799  /* get volume control details */
800  if (SndMixerGetVolumeControlDetails(Preferences.MixerWindow->Mixer, Control[Index].dwControlID, Line->cChannels, sizeof(MIXERCONTROLDETAILS_UNSIGNED), (LPVOID)pVolumeDetails) != -1)
801  {
802  /* update dialog control */
803  DWORD volumePosition, volumeStep, maxVolume, i;
804  DWORD balancePosition, balanceStep;
805 
806  volumeStep = (Control[Index].Bounds.dwMaximum - Control[Index].Bounds.dwMinimum) / (VOLUME_MAX - VOLUME_MIN);
807 
808  maxVolume = 0;
809  for (i = 0; i < Line->cChannels; i++)
810  {
811  if (pVolumeDetails[i].dwValue > maxVolume)
812  maxVolume = pVolumeDetails[i].dwValue;
813  }
814 
815  volumePosition = (maxVolume - Control[Index].Bounds.dwMinimum) / volumeStep;
816 
817  if (Line->cChannels == 1)
818  {
819  balancePosition = BALANCE_CENTER;
820  }
821  else if (Line->cChannels == 2)
822  {
823  if (pVolumeDetails[0].dwValue == pVolumeDetails[1].dwValue)
824  {
825  balancePosition = BALANCE_CENTER;
826  }
827  else if (pVolumeDetails[0].dwValue == Control[Index].Bounds.dwMinimum)
828  {
829  balancePosition = BALANCE_RIGHT;
830  }
831  else if (pVolumeDetails[1].dwValue == Control[Index].Bounds.dwMinimum)
832  {
833  balancePosition = BALANCE_LEFT;
834  }
835  else
836  {
837  balanceStep = (maxVolume - Control[Index].Bounds.dwMinimum) / (BALANCE_STEPS / 2);
838 
839  if (pVolumeDetails[0].dwValue < pVolumeDetails[1].dwValue)
840  {
841  balancePosition = (pVolumeDetails[0].dwValue - Control[Index].Bounds.dwMinimum) / balanceStep;
842  balancePosition = BALANCE_RIGHT - balancePosition;
843  }
844  else if (pVolumeDetails[1].dwValue < pVolumeDetails[0].dwValue)
845  {
846  balancePosition = (pVolumeDetails[1].dwValue - Control[Index].Bounds.dwMinimum) / balanceStep;
847  balancePosition = BALANCE_LEFT + balancePosition;
848  }
849  }
850  }
851 
852  /* Update the volume control slider */
854 
855  /* Update the balance control slider */
857  }
858  }
859  break;
860  }
861  }
862 
863 done:
864  /* Free the volume details */
865  if (pVolumeDetails)
866  HeapFree(GetProcessHeap(), 0, pVolumeDetails);
867 
868  /* free controls */
870 
871  /* done */
872  return TRUE;
873 }
#define IDC_LINE_SLIDER_VERT
Definition: resources.h:25
#define TRUE
Definition: types.h:120
PREFERENCES_CONTEXT Preferences
Definition: sndvol32.c:35
#define BALANCE_LEFT
Definition: sndvol32.h:22
VOID UpdateDialogLineSliderControl(PPREFERENCES_CONTEXT PrefContext, LPMIXERLINE Line, DWORD dwDialogID, DWORD Position)
Definition: dialog.c:813
#define VOLUME_MAX
Definition: sndvol32.h:19
#define BALANCE_CENTER
Definition: sndvol32.h:23
BOOL SndMixerQueryControls(PSND_MIXER Mixer, PUINT DisplayControls, LPMIXERLINE LineInfo, LPMIXERCONTROL *Controls)
Definition: mixer.c:112
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID UpdateDialogLineSwitchControl(PPREFERENCES_CONTEXT PrefContext, LPMIXERLINE Line, LONG fValue)
Definition: dialog.c:767
#define BALANCE_RIGHT
Definition: sndvol32.h:24
struct _SND_MIXER * Mixer
Definition: sndvol32.h:45
smooth NULL
Definition: ftsmooth.c:416
#define PtrToUlong(u)
Definition: config.h:107
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
INT SndMixerGetVolumeControlDetails(PSND_MIXER Mixer, DWORD dwControlID, DWORD cChannels, DWORD cbDetails, LPVOID paDetails)
Definition: mixer.c:498
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: ncftp.h:79
static const WCHAR Control[]
Definition: interface.c:27
#define BALANCE_STEPS
Definition: sndvol32.h:25
#define MIXERCONTROL_CONTROLTYPE_VOLUME
Definition: mmsystem.h:398
#define MIXERCONTROL_CONTROLTYPE_MUTE
Definition: mmsystem.h:384
#define IDC_LINE_SLIDER_HORZ
Definition: resources.h:24
#define VOLUME_MIN
Definition: sndvol32.h:18
unsigned int UINT
Definition: ndis.h:50
#define HeapFree(x, y, z)
Definition: compat.h:394
PMIXER_WINDOW MixerWindow
Definition: sndvol32.h:105

Referenced by MainWindowProc().

◆ PrefDlgAddConnection()

static BOOL CALLBACK PrefDlgAddConnection ( PSND_MIXER  Mixer,
DWORD  LineID,
LPMIXERLINE  Line,
PVOID  Context 
)
static

Definition at line 166 of file sndvol32.c.

170 {
172  HWND hwndControls;
173  LVITEM lvi;
174  UINT i;
175 
176  UNREFERENCED_PARAMETER(Mixer);
177  UNREFERENCED_PARAMETER(LineID);
178 
179  if (Line->cControls != 0)
180  {
181  hwndControls = GetDlgItem(PrefContext->hwndDlg,
182  IDC_CONTROLS);
183 
184  lvi.mask = LVIF_TEXT | LVIF_PARAM;
185  lvi.iItem = PrefContext->tmp++;
186  lvi.iSubItem = 0;
187  lvi.pszText = Line->szName;
188  lvi.lParam = (LPARAM)Line->dwSource;
189 
190  i = SendMessage(hwndControls,
192  0,
193  (LPARAM)&lvi);
194  if (i != (UINT)-1)
195  {
196  TCHAR LineName[MIXER_LONG_NAME_CHARS];
197  DWORD Flags;
198  BOOL SelLine = FALSE;
199 
200  if (SndMixerGetLineName(PrefContext->Mixer,
201  PrefContext->SelectedLine,
202  LineName,
204  TRUE) == -1)
205  {
206  LineName[0] = TEXT('\0');
207  }
208 
209  if (ReadLineConfig(PrefContext->DeviceName,
210  LineName,
211  Line->szName,
212  &Flags))
213  {
214  if (Flags != 0x4)
215  {
216  SelLine = TRUE;
217  }
218  }
219 
220  ListView_SetCheckState(hwndControls,
221  i,
222  SelLine);
223  }
224  }
225 
226  return TRUE;
227 }
BOOL ReadLineConfig(IN LPTSTR szDeviceName, IN LPTSTR szLineName, IN LPTSTR szControlName, OUT DWORD *Flags)
Definition: misc.c:197
#define TRUE
Definition: types.h:120
INT SndMixerGetLineName(PSND_MIXER Mixer, DWORD LineID, LPTSTR lpBuffer, UINT uSize, BOOL LongName)
Definition: mixer.c:390
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define IDC_CONTROLS
Definition: resources.h:21
struct _PREFERENCES_CONTEXT * PPREFERENCES_CONTEXT
PSND_MIXER Mixer
Definition: sndvol32.h:106
#define LVIF_TEXT
Definition: commctrl.h:2281
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
#define LVM_INSERTITEM
Definition: commctrl.h:2378
LONG_PTR LPARAM
Definition: windef.h:208
char TCHAR
Definition: xmlstorage.h:189
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: ncftp.h:79
#define MIXER_LONG_NAME_CHARS
Definition: mmsystem.h:294
TCHAR DeviceName[128]
Definition: sndvol32.h:114
#define TEXT(s)
Definition: k32.h:26
unsigned int UINT
Definition: ndis.h:50
#define ListView_SetCheckState(hwndLV, i, fCheck)
Definition: commctrl.h:2646
#define SendMessage
Definition: winuser.h:5744
#define LVIF_PARAM
Definition: commctrl.h:2283
#define LVITEM
Definition: commctrl.h:2347

Referenced by UpdatePrefDlgControls().

◆ PrefDlgAddLine()

static BOOL CALLBACK PrefDlgAddLine ( PSND_MIXER  Mixer,
LPMIXERLINE  Line,
UINT  DisplayControls,
PVOID  Context 
)
static

Definition at line 89 of file sndvol32.c.

93 {
95 
97  UNREFERENCED_PARAMETER(DisplayControls);
98 
99  switch (Line->dwComponentType)
100  {
102  if (PrefContext->PlaybackID == (DWORD)-1)
103  {
104  PrefContext->PlaybackID = Line->dwLineID;
105 
106  if (PrefContext->SelectedLine == (DWORD)-1)
107  {
108  PrefContext->SelectedLine = Line->dwLineID;
109  }
110  }
111  else
112  goto AddToOthersLines;
113 
114  break;
115 
117  if (PrefContext->RecordingID == (DWORD)-1)
118  {
119  PrefContext->RecordingID = Line->dwLineID;
120 
121  if (PrefContext->SelectedLine == (DWORD)-1)
122  {
123  PrefContext->SelectedLine = Line->dwLineID;
124  }
125  }
126  else
127  goto AddToOthersLines;
128 
129  break;
130 
131  default:
132  {
133  LRESULT lres;
134  HWND hwndCbOthers;
135 
136  if (PrefContext->SelectedLine == (DWORD)-1)
137  {
138  PrefContext->SelectedLine = Line->dwLineID;
139  }
140 
141 AddToOthersLines:
142  hwndCbOthers = GetDlgItem(PrefContext->hwndDlg,
143  IDC_LINE);
144 
145  lres = SendMessage(hwndCbOthers,
146  CB_ADDSTRING,
147  0,
148  (LPARAM)Line->szName);
149  if (lres != CB_ERR)
150  {
151  SendMessage(hwndCbOthers,
153  (WPARAM)lres,
154  Line->dwLineID);
155 
156  PrefContext->OtherLines++;
157  }
158  break;
159  }
160  }
161 
162  return TRUE;
163 }
#define CB_SETITEMDATA
Definition: winuser.h:1948
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
struct _PREFERENCES_CONTEXT * PPREFERENCES_CONTEXT
UINT_PTR WPARAM
Definition: windef.h:207
#define CB_ADDSTRING
Definition: winuser.h:1918
#define IDC_LINE
Definition: resources.h:19
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_ERR
Definition: winuser.h:2410
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: ncftp.h:79
#define MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
Definition: mmsystem.h:319
#define MIXERLINE_COMPONENTTYPE_DST_WAVEIN
Definition: mmsystem.h:322
#define SendMessage
Definition: winuser.h:5744
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by UpdatePrefDlgControls().

◆ RebuildMixerWindowControls()

static BOOL RebuildMixerWindowControls ( PPREFERENCES_CONTEXT  PrefContext)
static

Definition at line 616 of file sndvol32.c.

617 {
618  /* delete existing mixer controls */
620 
621  /* load new mixer controls */
622  LoadDialogCtrls(PrefContext);
623 
624  return TRUE;
625 }
#define TRUE
Definition: types.h:120
static VOID DeleteMixerWindowControls(PMIXER_WINDOW MixerWindow)
Definition: sndvol32.c:597
VOID LoadDialogCtrls(PPREFERENCES_CONTEXT PrefContext)
Definition: dialog.c:674
PMIXER_WINDOW MixerWindow
Definition: sndvol32.h:105

Referenced by MainWindowProc().

◆ RegisterApplicationClasses()

static BOOL RegisterApplicationClasses ( VOID  )
static

Definition at line 1278 of file sndvol32.c.

1279 {
1280  WNDCLASSEX wc;
1281 
1282  wc.cbSize = sizeof(WNDCLASSEX);
1283  wc.style = CS_HREDRAW | CS_VREDRAW;
1285  wc.cbClsExtra = 0;
1286  wc.cbWndExtra = sizeof(PMIXER_WINDOW);
1287  wc.hInstance = hAppInstance;
1290  wc.hCursor = LoadCursor(NULL,
1291  IDC_ARROW);
1292  wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
1293  wc.lpszMenuName = NULL;
1295  wc.hIconSm = NULL;
1297 
1298  return MainWindowClass != 0;
1299 }
UINT style
Definition: winuser.h:3176
#define MAKEINTRESOURCE
Definition: winuser.h:591
LPCSTR lpszMenuName
Definition: winuser.h:3184
#define RegisterClassEx
Definition: winuser.h:5738
HCURSOR hCursor
Definition: winuser.h:3182
WNDPROC lpfnWndProc
Definition: winuser.h:3177
LPCSTR lpszClassName
Definition: winuser.h:3185
ATOM MainWindowClass
Definition: sndvol32.c:31
HINSTANCE hAppInstance
Definition: sndvol32.c:30
#define CS_HREDRAW
Definition: winuser.h:648
HICON hIconSm
Definition: winuser.h:3186
#define SZ_APP_CLASS
Definition: sndvol32.h:65
HINSTANCE hInstance
Definition: winuser.h:3180
static LRESULT CALLBACK MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: sndvol32.c:876
smooth NULL
Definition: ftsmooth.c:416
UINT cbSize
Definition: winuser.h:3175
HBRUSH hbrBackground
Definition: winuser.h:3183
#define CS_VREDRAW
Definition: winuser.h:653
int cbWndExtra
Definition: winuser.h:3179
struct _MIXER_WINDOW * PMIXER_WINDOW
HICON hIcon
Definition: winuser.h:3181
#define COLOR_BTNFACE
Definition: winuser.h:918
#define LoadCursor
Definition: winuser.h:5713
int cbClsExtra
Definition: winuser.h:3178
#define IDC_ARROW
Definition: winuser.h:682
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5620
#define LoadIcon
Definition: winuser.h:5714
#define IDI_MAINAPP
Definition: resource.h:6

Referenced by _tWinMain().

◆ SetVolumeCallback()

static BOOL CALLBACK SetVolumeCallback ( PSND_MIXER  Mixer,
DWORD  LineID,
LPMIXERLINE  Line,
PVOID  Ctx 
)
static

Definition at line 630 of file sndvol32.c.

631 {
632  UINT ControlCount = 0, Index;
637 
638  /* check if the line name is equal */
639  if (wcsicmp(Line->szName, Context->LineName))
640  {
641  /* it is not */
642  return TRUE;
643  }
644 
645  /* query controls */
646  if (SndMixerQueryControls(Mixer, &ControlCount, Line, &Control) == FALSE)
647  {
648  /* failed to query for controls */
649  return FALSE;
650  }
651 
652  puDetails = HeapAlloc(GetProcessHeap(), 0, Line->cChannels * sizeof(MIXERCONTROLDETAILS_UNSIGNED));
653  if (puDetails == NULL)
654  return FALSE;
655 
656  /* now go through all controls and compare control ids */
657  for (Index = 0; Index < ControlCount; Index++)
658  {
659  if (Context->bVertical)
660  {
661  if (Control[Index].dwControlType == MIXERCONTROL_CONTROLTYPE_VOLUME)
662  {
663  DWORD LineOffset, volumePosition, balancePosition;
664  DWORD volumeStep, balanceStep;
665 
666  LineOffset = Context->SliderPos;
667 
668  volumePosition = (DWORD)SendDlgItemMessage(Preferences.MixerWindow->hWnd, LineOffset * IDC_LINE_SLIDER_VERT, TBM_GETPOS, 0, 0);
669  volumeStep = (Control[Index].Bounds.dwMaximum - Control[Index].Bounds.dwMinimum) / (VOLUME_MAX - VOLUME_MIN);
670 
671  if (Line->cChannels == 1)
672  {
673  /* set up details */
674  puDetails[0].dwValue = ((VOLUME_MAX - volumePosition) * volumeStep) + Control[Index].Bounds.dwMinimum;
675  }
676  else if (Line->cChannels == 2)
677  {
678  balancePosition = (DWORD)SendDlgItemMessage(Preferences.MixerWindow->hWnd, LineOffset * IDC_LINE_SLIDER_HORZ, TBM_GETPOS, 0, 0);
679  if (balancePosition == BALANCE_CENTER)
680  {
681  puDetails[0].dwValue = ((VOLUME_MAX - volumePosition) * volumeStep) + Control[Index].Bounds.dwMinimum;
682  puDetails[1].dwValue = ((VOLUME_MAX - volumePosition) * volumeStep) + Control[Index].Bounds.dwMinimum;
683  }
684  else if (balancePosition == BALANCE_LEFT)
685  {
686  puDetails[0].dwValue = ((VOLUME_MAX - volumePosition) * volumeStep) + Control[Index].Bounds.dwMinimum;
687  puDetails[1].dwValue = Control[Index].Bounds.dwMinimum;
688  }
689  else if (balancePosition == BALANCE_RIGHT)
690  {
691  puDetails[0].dwValue = Control[Index].Bounds.dwMinimum;
692  puDetails[1].dwValue = ((VOLUME_MAX - volumePosition) * volumeStep) + Control[Index].Bounds.dwMinimum;
693  }
694  else if (balancePosition < BALANCE_CENTER) // Left
695  {
696  puDetails[0].dwValue = ((VOLUME_MAX - volumePosition) * volumeStep) + Control[Index].Bounds.dwMinimum;
697 
698  balanceStep = (puDetails[0].dwValue - Control[Index].Bounds.dwMinimum) / (BALANCE_STEPS / 2);
699 
700  puDetails[1].dwValue = (balancePosition * balanceStep) + Control[Index].Bounds.dwMinimum;
701  }
702  else if (balancePosition > BALANCE_CENTER) // Right
703  {
704  puDetails[1].dwValue = ((VOLUME_MAX - volumePosition) * volumeStep) + Control[Index].Bounds.dwMinimum;
705 
706  balanceStep = (puDetails[1].dwValue - Control[Index].Bounds.dwMinimum) / (BALANCE_STEPS / 2);
707 
708  puDetails[0].dwValue = ((BALANCE_RIGHT - balancePosition) * balanceStep) + Control[Index].Bounds.dwMinimum;
709  }
710  }
711  else
712  {
714 
715  /* FIXME */
716  }
717 
718  /* set volume */
720 
721  /* done */
722  break;
723  }
724  }
725  else if (Context->bSwitch)
726  {
727  if (Control[Index].dwControlType == MIXERCONTROL_CONTROLTYPE_MUTE)
728  {
729  /* set up details */
730  bDetails.fValue = Context->SliderPos;
731 
732  /* set volume */
734 
735  /* done */
736  break;
737  }
738  }
739  }
740 
741  if (puDetails != NULL)
742  HeapFree(GetProcessHeap(), 0, puDetails);
743 
744  /* free controls */
746 
747 
748  /* done */
749  return TRUE;
750 }
#define IDC_LINE_SLIDER_VERT
Definition: resources.h:25
#define TRUE
Definition: types.h:120
PREFERENCES_CONTEXT Preferences
Definition: sndvol32.c:35
#define BALANCE_LEFT
Definition: sndvol32.h:22
struct _SET_VOLUME_CONTEXT * PSET_VOLUME_CONTEXT
#define VOLUME_MAX
Definition: sndvol32.h:19
#define SendDlgItemMessage
Definition: winuser.h:5743
#define DWORD
Definition: nt_native.h:44
INT SndMixerSetVolumeControlDetails(PSND_MIXER Mixer, DWORD dwControlID, DWORD cChannels, DWORD cbDetails, LPVOID paDetails)
Definition: mixer.c:474
#define BALANCE_CENTER
Definition: sndvol32.h:23
BOOL SndMixerQueryControls(PSND_MIXER Mixer, PUINT DisplayControls, LPMIXERLINE LineInfo, LPMIXERCONTROL *Controls)
Definition: mixer.c:112
#define BALANCE_RIGHT
Definition: sndvol32.h:24
#define TBM_GETPOS
Definition: commctrl.h:2003
struct _SND_MIXER * Mixer
Definition: sndvol32.h:45
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
INT SndMixerGetVolumeControlDetails(PSND_MIXER Mixer, DWORD dwControlID, DWORD cChannels, DWORD cbDetails, LPVOID paDetails)
Definition: mixer.c:498
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: ncftp.h:79
#define wcsicmp
Definition: string.h:1152
static const WCHAR Control[]
Definition: interface.c:27
#define BALANCE_STEPS
Definition: sndvol32.h:25
#define MIXERCONTROL_CONTROLTYPE_VOLUME
Definition: mmsystem.h:398
#define MIXERCONTROL_CONTROLTYPE_MUTE
Definition: mmsystem.h:384
#define IDC_LINE_SLIDER_HORZ
Definition: resources.h:24
#define VOLUME_MIN
Definition: sndvol32.h:18
unsigned int UINT
Definition: ndis.h:50
#define HeapFree(x, y, z)
Definition: compat.h:394
PMIXER_WINDOW MixerWindow
Definition: sndvol32.h:105

Referenced by MainWindowProc().

◆ UnregisterApplicationClasses()

static VOID UnregisterApplicationClasses ( VOID  )
static

Definition at line 1302 of file sndvol32.c.

1303 {
1305  hAppInstance);
1306 }
HINSTANCE hAppInstance
Definition: sndvol32.c:30
#define SZ_APP_CLASS
Definition: sndvol32.h:65
#define UnregisterClass
Definition: winuser.h:5762

Referenced by _tWinMain().

◆ UpdatePrefDlgControls()

static VOID UpdatePrefDlgControls ( PPREFERENCES_CONTEXT  Context,
DWORD  LineID 
)
static

Definition at line 230 of file sndvol32.c.

232 {
233  INT OldID, MixerID = 0;
234  INT DeviceCbIndex;
235 
236  /* select the mixer */
237  DeviceCbIndex = SendDlgItemMessage(Context->hwndDlg,
239  CB_GETCURSEL,
240  0,
241  0);
242  if (DeviceCbIndex != CB_ERR)
243  {
244  MixerID = SendDlgItemMessage(Context->hwndDlg,
247  DeviceCbIndex,
248  0);
249  if (MixerID == CB_ERR)
250  {
251  MixerID = 0;
252  }
253  }
254 
255  OldID = Context->Selected;
256  if (MixerID != OldID &&
257  SndMixerSelect(Context->Mixer,
258  MixerID))
259  {
260  Context->Selected = SndMixerGetSelection(Context->Mixer);
261 
262  /* update the controls */
263  Context->PlaybackID = (DWORD)-1;
264  Context->RecordingID = (DWORD)-1;
265  Context->OtherLines = 0;
266  Context->SelectedLine = (DWORD)-1;
267 
269  Context->DeviceName,
270  sizeof(Context->DeviceName) / sizeof(Context->DeviceName[0]));
271 
272  if (SndMixerEnumLines(Context->Mixer,
274  Context))
275  {
276  UINT SelBox = 0;
277 
278  /* enable/disable controls and make default selection */
280  IDC_PLAYBACK),
281  Context->PlaybackID != (DWORD)-1);
282  CheckDlgButton(Context->hwndDlg,
283  IDC_PLAYBACK,
284  (Context->PlaybackID != (DWORD)-1 && SelBox++ == 0) ?
286 
288  IDC_RECORDING),
289  Context->RecordingID != (DWORD)-1);
290  CheckDlgButton(Context->hwndDlg,
292  (Context->RecordingID != (DWORD)-1 && SelBox++ == 0) ?
294 
295  if (Context->OtherLines != 0)
296  {
297  /* select the first item in the other lines combo box by default */
298  SendDlgItemMessage(Context->hwndDlg,
299  IDC_LINE,
300  CB_SETCURSEL,
301  0,
302  0);
303  }
305  IDC_LINE),
306  FALSE);
308  IDC_OTHER),
309  Context->OtherLines != 0);
310  CheckDlgButton(Context->hwndDlg,
311  IDC_LINE,
312  (Context->OtherLines != 0 && SelBox++ == 0) ?
314 
315  /* disable the OK button if the device doesn't have any lines */
317  IDOK),
318  Context->PlaybackID != (DWORD)-1 ||
319  Context->RecordingID != (DWORD)-1 ||
320  Context->OtherLines != 0);
321 
322  LineID = Context->SelectedLine;
323  }
324  }
325 
326  /* update the line sources list */
327  if ((MixerID != OldID && Context->SelectedLine != (DWORD)-1) ||
328  (Context->SelectedLine != LineID && LineID != (DWORD)-1))
329  {
330  Context->SelectedLine = LineID;
331 
333  IDC_CONTROLS));
334 
335  Context->tmp = 0;
337  LineID,
339  Context);
340  }
341 }
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define IDOK
Definition: winuser.h:824
#define IDC_MIXERDEVICE
Definition: resources.h:15
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define IDC_CONTROLS
Definition: resources.h:21
#define CB_GETITEMDATA
Definition: winuser.h:1932
BOOL SndMixerEnumConnections(PSND_MIXER Mixer, DWORD LineID, PFNSNDMIXENUMCONNECTIONS EnumProc, PVOID Context)
Definition: mixer.c:552
#define SendDlgItemMessage
Definition: winuser.h:5743
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:56
#define CB_GETCURSEL
Definition: winuser.h:1925
BOOL SndMixerEnumLines(PSND_MIXER Mixer, PFNSNDMIXENUMLINES EnumProc, PVOID Context)
Definition: mixer.c:526
static BOOL CALLBACK PrefDlgAddConnection(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVOID Context)
Definition: sndvol32.c:166
#define IDC_LINE
Definition: resources.h:19
#define IDC_RECORDING
Definition: resources.h:17
#define CB_ERR
Definition: winuser.h:2410
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
static BOOL CALLBACK PrefDlgAddLine(PSND_MIXER Mixer, LPMIXERLINE Line, UINT DisplayControls, PVOID Context)
Definition: sndvol32.c:89
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT SndMixerGetSelection(PSND_MIXER Mixer)
Definition: mixer.c:361
#define CB_SETCURSEL
Definition: winuser.h:1943
#define IDC_OTHER
Definition: resources.h:18
#define BST_UNCHECKED
Definition: winuser.h:199
#define IDC_PLAYBACK
Definition: resources.h:16
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
unsigned int UINT
Definition: ndis.h:50
#define BST_CHECKED
Definition: winuser.h:197
BOOL SndMixerSelect(PSND_MIXER Mixer, UINT MixerId)
Definition: mixer.c:304
INT SndMixerGetProductName(PSND_MIXER Mixer, LPTSTR lpBuffer, UINT uSize)
Definition: mixer.c:367
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2386

Referenced by DlgPreferencesProc().

◆ WriteLineSettings()

static VOID WriteLineSettings ( PPREFERENCES_CONTEXT  Context,
HWND  hwndDlg 
)
static

Definition at line 345 of file sndvol32.c.

346 {
347  HWND hwndControls;
348  INT Count, Index;
349  WCHAR LineName[MIXER_LONG_NAME_CHARS];
350  WCHAR DestinationName[MIXER_LONG_NAME_CHARS];
351  DWORD Flags;
352  PSNDVOL_REG_LINESTATE LineStates;
353 
354  /* get list view */
355  hwndControls = GetDlgItem(hwndDlg, IDC_CONTROLS);
356 
357  /* get list item count */
358  Count = ListView_GetItemCount(hwndControls);
359 
360  /* sanity check */
361  assert(Count);
362 
363  if (SndMixerGetLineName(Context->Mixer, Context->SelectedLine, DestinationName, MIXER_LONG_NAME_CHARS, TRUE) == -1)
364  {
365  /* failed to get destination line name */
366  return;
367  }
368 
369  /* allocate line states array */
371  if (LineStates == NULL)
372  {
373  /* failed to allocate line states array */
374  return;
375  }
376 
377 
378  for(Index = 0; Index < Count; Index++)
379  {
380  /* set to empty */
381  LineName[0] = L'\0';
382 
383  /* get item text */
384  ListView_GetItemText(hwndControls, Index, 0, LineName, MIXER_LONG_NAME_CHARS);
385 
386  /* make sure it is null terminated */
387  LineName[MIXER_LONG_NAME_CHARS-1] = L'\0';
388 
389  /* get check state */
390  Flags = (ListView_GetCheckState(hwndControls, Index) == 0 ? 0x4 : 0);
391 
392  /* copy line name */
393  wcscpy(LineStates[Index].LineName, LineName);
394 
395  /* store flags */
396  LineStates[Index].Flags = Flags;
397  }
398 
399  /* now write the line config */
400  WriteLineConfig(Context->DeviceName, DestinationName, LineStates, sizeof(SNDVOL_REG_LINESTATE) * Count);
401 
402  /* free line states */
403  HeapFree(GetProcessHeap(), 0, LineStates);
404 }
#define TRUE
Definition: types.h:120
INT SndMixerGetLineName(PSND_MIXER Mixer, DWORD LineID, LPTSTR lpBuffer, UINT uSize, BOOL LongName)
Definition: mixer.c:390
#define IDC_CONTROLS
Definition: resources.h:21
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2656
#define assert(x)
Definition: debug.h:53
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
int32_t INT
Definition: typedefs.h:56
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
smooth NULL
Definition: ftsmooth.c:416
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2279
BOOL WriteLineConfig(IN LPTSTR szDeviceName, IN LPTSTR szLineName, IN PSNDVOL_REG_LINESTATE LineState, IN DWORD cbSize)
Definition: misc.c:162
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define MIXER_LONG_NAME_CHARS
Definition: mmsystem.h:294
#define ListView_GetCheckState(hwndLV, i)
Definition: commctrl.h:2649
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by DlgPreferencesProc().

Variable Documentation

◆ hAppHeap

HANDLE hAppHeap

Definition at line 33 of file sndvol32.c.

Referenced by _tWinMain(), CreateApplicationWindow(), and MainWindowProc().

◆ hAppInstance

◆ hMainWnd

HWND hMainWnd

Definition at line 32 of file sndvol32.c.

Referenced by _tWinMain().

◆ lpAppTitle

LPTSTR lpAppTitle

Definition at line 34 of file sndvol32.c.

Referenced by _tWinMain(), CreateApplicationWindow(), and MainWindowProc().

◆ MainWindowClass

ATOM MainWindowClass

Definition at line 31 of file sndvol32.c.

Referenced by RegisterApplicationClasses().

◆ Preferences

PREFERENCES_CONTEXT Preferences

Definition at line 35 of file sndvol32.c.

Referenced by MainWindowProc(), MixerControlChangeCallback(), and SetVolumeCallback().