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