1 #ifndef __SNDVOL32_H
2 #define __SNDVOL32_H
3 
4 #include <stdarg.h>
5 
6 #include <windef.h>
7 #include <winbase.h>
8 #include <wingdi.h>
9 #include <winuser.h>
10 #include <mmsystem.h>
11 #include <commctrl.h>
12 #include <tchar.h>
13 #include <assert.h>
14 
15 #include "resources.h"
16 
17 #define VOLUME_MIN           0
18 #define VOLUME_MAX         500
19 #define VOLUME_TICKS         5
20 #define VOLUME_PAGE_SIZE   100
21 #define BALANCE_STEPS       64
22 #define BALANCE_TICKS        1
23 #define BALANCE_PAGE_SIZE   12
24 
25 typedef enum _WINDOW_MODE
26 {
27     NORMAL_MODE,
28     SMALL_MODE,
29     TRAY_MODE
30 } WINDOW_MODE, *PWINDOW_MODE;
31 
32 typedef struct _MIXER_WINDOW
33 {
34   HWND hWnd;
35   HWND hStatusBar;
36   struct _SND_MIXER *Mixer;
37   UINT SelectedLine;
38   UINT WindowCount;
39   HWND *Window;
40 
41     WINDOW_MODE Mode;
42     UINT MixerId;
43     RECT rect;
44     HFONT hFont;
45 } MIXER_WINDOW, *PMIXER_WINDOW;
46 
47 extern HINSTANCE hAppInstance;
48 extern ATOM MainWindowClass;
49 extern HWND hMainWnd;
50 extern HANDLE hAppHeap;
51 
52 #define SZ_APP_CLASS TEXT("Volume Control")
53 
54 ULONG DbgPrint(PCH , ...);
55 #define DPRINT DbgPrint("SNDVOL32: %s:%i: ", __FILE__, __LINE__); DbgPrint
56 
57 
58 /*
59  * MIXER
60  */
61 
62 typedef struct _SND_MIXER_CONNECTION
63 {
64   struct _SND_MIXER_CONNECTION *Next;
65   MIXERLINE Info;
66   LPMIXERCONTROL Controls;
67   UINT DisplayControls;
68 } SND_MIXER_CONNECTION, *PSND_MIXER_CONNECTION;
69 
70 
71 typedef struct _SND_MIXER_DESTINATION
72 {
73   struct _SND_MIXER_DESTINATION *Next;
74   MIXERLINE Info;
75   LPMIXERCONTROL Controls;
76   UINT DisplayControls;
77   PSND_MIXER_CONNECTION Connections;
78 } SND_MIXER_DESTINATION, *PSND_MIXER_DESTINATION;
79 
80 typedef struct _SND_MIXER
81 {
82   UINT MixersCount;
83   HWND hWndNotification;
84   UINT MixerId;
85   HMIXER hmx;
86   MIXERCAPS Caps;
87   PSND_MIXER_DESTINATION Lines;
88 } SND_MIXER, *PSND_MIXER;
89 
90 typedef struct _PREFERENCES_CONTEXT
91 {
92     PMIXER_WINDOW MixerWindow;
93     PSND_MIXER Mixer;
94     HWND hwndDlg;
95 
96     UINT Selected;
97     DWORD SelectedLine;
98     DWORD PlaybackID;
99     DWORD RecordingID;
100     UINT OtherLines;
101     TCHAR DeviceName[128];
102 
103     DWORD Count;
104     DWORD tmp;
105 } PREFERENCES_CONTEXT, *PPREFERENCES_CONTEXT;
106 
107 typedef struct
108 {
109     WCHAR LineName[MIXER_LONG_NAME_CHARS];
110     UINT SliderPos;
111     BOOL bVertical;
112     BOOL bSwitch;
113 
114 }SET_VOLUME_CONTEXT, *PSET_VOLUME_CONTEXT;
115 
116 /* NOTE: do NOT modify SNDVOL_REG_LINESTATE for binary compatibility with XP! */
117 typedef struct _SNDVOL_REG_LINESTATE
118 {
119     DWORD Flags;
120     WCHAR LineName[MIXER_LONG_NAME_CHARS];
121 } SNDVOL_REG_LINESTATE, *PSNDVOL_REG_LINESTATE;
122 
123 
124 typedef BOOL (CALLBACK *PFNSNDMIXENUMLINES)(PSND_MIXER Mixer, LPMIXERLINE Line, UINT DisplayControls, PVOID Context);
125 typedef BOOL (CALLBACK *PFNSNDMIXENUMCONNECTIONS)(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVOID Context);
126 typedef BOOL (CALLBACK *PFNSNDMIXENUMPRODUCTS)(PSND_MIXER Mixer, UINT Id, LPCTSTR ProductName, PVOID Context);
127 
128 PSND_MIXER SndMixerCreate(HWND hWndNotification, UINT MixerId);
129 VOID SndMixerDestroy(PSND_MIXER Mixer);
130 VOID SndMixerClose(PSND_MIXER Mixer);
131 BOOL SndMixerSelect(PSND_MIXER Mixer, UINT MixerId);
132 UINT SndMixerGetSelection(PSND_MIXER Mixer);
133 INT SndMixerSetVolumeControlDetails(PSND_MIXER Mixer, DWORD dwControlID, DWORD cbDetails, LPVOID paDetails);
134 INT SndMixerGetVolumeControlDetails(PSND_MIXER Mixer, DWORD dwControlID, DWORD cbDetails, LPVOID paDetails);
135 INT SndMixerGetProductName(PSND_MIXER Mixer, LPTSTR lpBuffer, UINT uSize);
136 INT SndMixerGetLineName(PSND_MIXER Mixer, DWORD LineID, LPTSTR lpBuffer, UINT uSize, BOOL LongName);
137 BOOL SndMixerEnumProducts(PSND_MIXER Mixer, PFNSNDMIXENUMPRODUCTS EnumProc, PVOID Context);
138 INT SndMixerGetDestinationCount(PSND_MIXER Mixer);
139 BOOL SndMixerEnumLines(PSND_MIXER Mixer, PFNSNDMIXENUMLINES EnumProc, PVOID Context);
140 BOOL SndMixerEnumConnections(PSND_MIXER Mixer, DWORD LineID, PFNSNDMIXENUMCONNECTIONS EnumProc, PVOID Context);
141 BOOL SndMixerIsDisplayControl(PSND_MIXER Mixer, LPMIXERCONTROL Control);
142 BOOL SndMixerQueryControls(PSND_MIXER Mixer, PUINT DisplayControls, LPMIXERLINE LineInfo, LPMIXERCONTROL *Controls);
143 
144 /*
145  * dialog.c
146  */
147 VOID LoadDialogCtrls(PPREFERENCES_CONTEXT PrefContext);
148 VOID UpdateDialogLineSliderControl(PPREFERENCES_CONTEXT PrefContext, LPMIXERLINE Line, DWORD dwControlID, DWORD DialogID, DWORD Position);
149 VOID UpdateDialogLineSwitchControl(PPREFERENCES_CONTEXT PrefContext, LPMIXERLINE Line, LONG fValue);
150 
151 /*
152  * MISC
153  */
154 
155 extern HKEY hAppSettingsKey;
156 
157 BOOL
158 InitAppConfig(VOID);
159 
160 VOID
161 CloseAppConfig(VOID);
162 
163 INT
164 AllocAndLoadString(OUT LPWSTR *lpTarget,
165                    IN HINSTANCE hInst,
166                    IN UINT uID);
167 
168 DWORD
169 LoadAndFormatString(IN HINSTANCE hInstance,
170                     IN UINT uID,
171                     OUT LPWSTR *lpTarget,
172                     ...);
173 
174 BOOL
175 ReadLineConfig(IN LPTSTR szDeviceName,
176                IN LPTSTR szLineName,
177                IN LPTSTR szControlName,
178                OUT DWORD *Flags);
179 
180 BOOL
181 WriteLineConfig(IN LPTSTR szDeviceName,
182                 IN LPTSTR szLineName,
183                 IN PSNDVOL_REG_LINESTATE LineState,
184                 IN DWORD cbSize);
185 
186 /* tray.c */
187 
188 INT_PTR
189 CALLBACK
190 TrayDlgProc(
191     HWND hwndDlg,
192     UINT uMsg,
193     WPARAM wParam,
194     LPARAM lParam);
195 
196 #endif /* __SNDVOL32_H */
197