xref: /reactos/dll/directx/dsound_new/precomp.h (revision 31876ba8)
1 #ifndef PRECOMP_H
2 #define PRECOMP_H
3 
4 #define COBJMACROS
5 #define NONAMELESSUNION
6 #define NONAMELESSSTRUCT
7 
8 #include <windows.h>
9 #include <setupapi.h>
10 #include <mmddk.h>
11 #include <objbase.h>
12 #include <olectl.h>
13 #include <unknwn.h>
14 #include <dsound.h>
15 #include <dsconf.h>
16 #include <vfwmsgs.h>
17 #include <setupapi.h>
18 #include <ks.h>
19 #include <ksmedia.h>
20 #include <limits.h>
21 #include <stdio.h>
22 
23 #include "resource.h"
24 
25 // #define NDEBUG
26 #include <debug.h>
27 
28 /* factory method */
29 typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject);
30 
31 /* factory table */
32 typedef struct
33 {
34     REFIID riid;
35     LPFNCREATEINSTANCE lpfnCI;
36 } INTERFACE_TABLE;
37 
38 typedef struct tagFILTERINFO
39 {
40     SP_DEVINFO_DATA DeviceData;
41     WCHAR DevicePath[MAX_PATH];
42     HANDLE hFilter;
43     ULONG PinCount;
44     PULONG Pin;
45     GUID DeviceGuid[2];
46     ULONG MappedId[2];
47 
48     struct tagFILTERINFO *lpNext;
49 }FILTERINFO, *LPFILTERINFO;
50 
51 #define INIT_GUID(guid, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)      \
52         guid.Data1 = l; guid.Data2 = w1; guid.Data3 = w2;               \
53         guid.Data4[0] = b1; guid.Data4[1] = b2; guid.Data4[2] = b3;     \
54         guid.Data4[3] = b4; guid.Data4[4] = b5; guid.Data4[5] = b6;     \
55         guid.Data4[6] = b7; guid.Data4[7] = b8;
56 
57 typedef enum
58 {
59     PIN_TYPE_NONE = 0,
60     PIN_TYPE_PLAYBACK = 1,
61     PIN_TYPE_RECORDING = 2
62 }PIN_TYPE;
63 
64 /* globals */
65 extern HINSTANCE dsound_hInstance;
66 extern LPFILTERINFO RootInfo;
67 
68 /* classfactory.c */
69 
70 IClassFactory *
71 IClassFactory_fnConstructor(
72     LPFNCREATEINSTANCE lpfnCI,
73     PLONG pcRefDll,
74     REFIID riidInst);
75 
76 /* devicelist.c */
77 
78 HRESULT
79 EnumAudioDeviceInterfaces(
80     LPFILTERINFO *OutRootInfo);
81 
82 BOOL
83 FindDeviceByGuid(
84     LPCGUID pGuidSrc,
85     LPFILTERINFO *Filter);
86 
87 BOOL
88 FindDeviceByMappedId(
89     IN ULONG DeviceID,
90     LPFILTERINFO *Filter,
91     BOOL bPlayback);
92 
93 ULONG
94 GetPinIdFromFilter(
95     LPFILTERINFO Filter,
96     BOOL bCapture,
97     ULONG Offset);
98 
99 /* directsound.c */
100 
101 HRESULT
102 CALLBACK
103 NewDirectSound(
104     IUnknown* pUnkOuter,
105     REFIID riid,
106     LPVOID* ppvObject);
107 
108 /* misc.c */
109 
110 VOID
111 PerformChannelConversion(
112     PUCHAR Buffer,
113     ULONG BufferLength,
114     PULONG BytesRead,
115     ULONG OldChannels,
116     ULONG NewChannels,
117     ULONG BitsPerSample,
118     PUCHAR Result,
119     ULONG ResultLength,
120     PULONG BytesWritten);
121 
122 BOOL
123 SetPinFormat(
124     IN HANDLE hPin,
125     IN LPWAVEFORMATEX WaveFormatEx);
126 
127 BOOL
128 CreateCompatiblePin(
129     IN HANDLE hFilter,
130     IN DWORD PinId,
131     IN BOOL bLoop,
132     IN LPWAVEFORMATEX WaveFormatEx,
133     OUT LPWAVEFORMATEX WaveFormatOut,
134     OUT PHANDLE hPin);
135 
136 DWORD
137 SyncOverlappedDeviceIoControl(
138     IN  HANDLE Handle,
139     IN  DWORD IoControlCode,
140     IN  LPVOID InBuffer,
141     IN  DWORD InBufferSize,
142     OUT LPVOID OutBuffer,
143     IN  DWORD OutBufferSize,
144     OUT LPDWORD BytesTransferred OPTIONAL);
145 
146 DWORD
147 PrimaryDirectSoundBuffer_Write(
148     LPDIRECTSOUNDBUFFER8 iface,
149     LPVOID Buffer,
150     DWORD  BufferSize);
151 
152 DWORD
153 OpenPin(
154     HANDLE hFilter,
155     ULONG PinId,
156     LPWAVEFORMATEX WaveFormatEx,
157     PHANDLE hPin,
158     BOOL bLoop);
159 
160 DWORD
161 OpenFilter(
162     IN LPCWSTR lpFileName,
163     IN PHANDLE OutHandle);
164 
165 DWORD
166 GetFilterPinCount(
167     IN HANDLE hFilter,
168     OUT PULONG NumPins);
169 
170 DWORD
171 GetFilterPinCommunication(
172     IN HANDLE hFilter,
173     IN ULONG PinId,
174     OUT PKSPIN_COMMUNICATION Communication);
175 
176 DWORD
177 GetFilterPinDataFlow(
178     IN HANDLE hFilter,
179     IN ULONG PinId,
180     OUT PKSPIN_DATAFLOW DataFlow);
181 
182 /* primary.c */
183 
184 HRESULT
185 PrimaryDirectSoundBuffer_GetPosition(
186     LPDIRECTSOUNDBUFFER8 iface,
187     LPDWORD pdwCurrentPlayCursor,
188     LPDWORD pdwCurrentWriteCursor);
189 
190 VOID
191 PrimaryDirectSoundBuffer_SetState(
192     LPDIRECTSOUNDBUFFER8 iface,
193     KSSTATE State);
194 
195 HRESULT
196 NewPrimarySoundBuffer(
197     LPDIRECTSOUNDBUFFER8 *OutBuffer,
198     LPFILTERINFO Filter,
199     DWORD dwLevel,
200     DWORD dwFlags);
201 
202 HRESULT
203 PrimaryDirectSoundBuffer_SetFormat(
204     LPDIRECTSOUNDBUFFER8 iface,
205     LPWAVEFORMATEX pcfxFormat,
206     BOOL bLooped);
207 
208 VOID
209 PrimaryDirectSoundBuffer_AcquireLock(
210     LPDIRECTSOUNDBUFFER8 iface);
211 
212 VOID
213 PrimaryDirectSoundBuffer_ReleaseLock(
214     LPDIRECTSOUNDBUFFER8 iface);
215 
216 /* secondary.c */
217 
218 HRESULT
219 NewSecondarySoundBuffer(
220     LPDIRECTSOUNDBUFFER8 *OutBuffer,
221     LPFILTERINFO Filter,
222     DWORD dwLevel,
223     LPCDSBUFFERDESC lpcDSBufferDesc,
224     LPDIRECTSOUNDBUFFER8 PrimaryBuffer);
225 
226 /* property.c */
227 
228 HRESULT
229 CALLBACK
230 NewKsPropertySet(
231     IUnknown* pUnkOuter,
232     REFIID riid,
233     LPVOID* ppvObject);
234 
235 /* capture.c */
236 
237 HRESULT
238 CALLBACK
239 NewDirectSoundCapture(
240     IUnknown* pUnkOuter,
241     REFIID riid,
242     LPVOID* ppvObject);
243 
244 /* capturebuffer.c */
245 
246 HRESULT
247 NewDirectSoundCaptureBuffer(
248     LPDIRECTSOUNDCAPTUREBUFFER8 *OutBuffer,
249     LPFILTERINFO Filter,
250     LPCDSCBUFFERDESC lpcDSBufferDesc);
251 
252 /* notify.c */
253 
254 VOID
255 DoNotifyPositionEvents(
256     LPDIRECTSOUNDNOTIFY iface,
257     DWORD OldPosition,
258     DWORD NewPosition);
259 
260 HRESULT
261 NewDirectSoundNotify(
262     LPDIRECTSOUNDNOTIFY * Notify,
263     BOOL bLoop,
264     BOOL bMix,
265     HANDLE hPin,
266     DWORD BufferSize);
267 
268 #endif
269