1 #pragma once 2 3 #define COBJMACROS 4 #define NONAMELESSUNION 5 #define NONAMELESSSTRUCT 6 7 #include <windows.h> 8 #include <setupapi.h> 9 #include <mmddk.h> 10 #include <objbase.h> 11 #include <olectl.h> 12 #include <unknwn.h> 13 #include <dsound.h> 14 #include <dsconf.h> 15 #include <vfwmsgs.h> 16 #include <setupapi.h> 17 #define YDEBUG 18 #include <debug.h> 19 #include <ks.h> 20 #include <ksmedia.h> 21 #include <limits.h> 22 #include <stdio.h> 23 24 #include "resource.h" 25 26 27 /* factory method */ 28 typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject); 29 30 /* factory table */ 31 typedef struct 32 { 33 REFIID riid; 34 LPFNCREATEINSTANCE lpfnCI; 35 } INTERFACE_TABLE; 36 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 77 /* devicelist.c */ 78 79 HRESULT 80 EnumAudioDeviceInterfaces( 81 LPFILTERINFO *OutRootInfo); 82 83 BOOL 84 FindDeviceByGuid( 85 LPCGUID pGuidSrc, 86 LPFILTERINFO *Filter); 87 88 BOOL 89 FindDeviceByMappedId( 90 IN ULONG DeviceID, 91 LPFILTERINFO *Filter, 92 BOOL bPlayback); 93 94 ULONG 95 GetPinIdFromFilter( 96 LPFILTERINFO Filter, 97 BOOL bCapture, 98 ULONG Offset); 99 100 /* directsound.c */ 101 102 HRESULT 103 CALLBACK 104 NewDirectSound( 105 IUnknown* pUnkOuter, 106 REFIID riid, 107 LPVOID* ppvObject); 108 109 110 /* misc.c */ 111 112 VOID 113 PerformChannelConversion( 114 PUCHAR Buffer, 115 ULONG BufferLength, 116 PULONG BytesRead, 117 ULONG OldChannels, 118 ULONG NewChannels, 119 ULONG BitsPerSample, 120 PUCHAR Result, 121 ULONG ResultLength, 122 PULONG BytesWritten); 123 124 BOOL 125 SetPinFormat( 126 IN HANDLE hPin, 127 IN LPWAVEFORMATEX WaveFormatEx); 128 129 BOOL 130 CreateCompatiblePin( 131 IN HANDLE hFilter, 132 IN DWORD PinId, 133 IN BOOL bLoop, 134 IN LPWAVEFORMATEX WaveFormatEx, 135 OUT LPWAVEFORMATEX WaveFormatOut, 136 OUT PHANDLE hPin); 137 138 139 DWORD 140 SyncOverlappedDeviceIoControl( 141 IN HANDLE Handle, 142 IN DWORD IoControlCode, 143 IN LPVOID InBuffer, 144 IN DWORD InBufferSize, 145 OUT LPVOID OutBuffer, 146 IN DWORD OutBufferSize, 147 OUT LPDWORD BytesTransferred OPTIONAL); 148 149 DWORD 150 PrimaryDirectSoundBuffer_Write( 151 LPDIRECTSOUNDBUFFER8 iface, 152 LPVOID Buffer, 153 DWORD BufferSize); 154 155 156 DWORD 157 OpenPin( 158 HANDLE hFilter, 159 ULONG PinId, 160 LPWAVEFORMATEX WaveFormatEx, 161 PHANDLE hPin, 162 BOOL bLoop); 163 164 DWORD 165 OpenFilter( 166 IN LPCWSTR lpFileName, 167 IN PHANDLE OutHandle); 168 169 DWORD 170 GetFilterPinCount( 171 IN HANDLE hFilter, 172 OUT PULONG NumPins); 173 174 DWORD 175 GetFilterPinCommunication( 176 IN HANDLE hFilter, 177 IN ULONG PinId, 178 OUT PKSPIN_COMMUNICATION Communication); 179 180 DWORD 181 GetFilterPinDataFlow( 182 IN HANDLE hFilter, 183 IN ULONG PinId, 184 OUT PKSPIN_DATAFLOW DataFlow); 185 186 /* primary.c */ 187 188 HRESULT 189 PrimaryDirectSoundBuffer_GetPosition( 190 LPDIRECTSOUNDBUFFER8 iface, 191 LPDWORD pdwCurrentPlayCursor, 192 LPDWORD pdwCurrentWriteCursor); 193 194 VOID 195 PrimaryDirectSoundBuffer_SetState( 196 LPDIRECTSOUNDBUFFER8 iface, 197 KSSTATE State); 198 199 HRESULT 200 NewPrimarySoundBuffer( 201 LPDIRECTSOUNDBUFFER8 *OutBuffer, 202 LPFILTERINFO Filter, 203 DWORD dwLevel, 204 DWORD dwFlags); 205 206 HRESULT 207 PrimaryDirectSoundBuffer_SetFormat( 208 LPDIRECTSOUNDBUFFER8 iface, 209 LPWAVEFORMATEX pcfxFormat, 210 BOOL bLooped); 211 212 VOID 213 PrimaryDirectSoundBuffer_AcquireLock( 214 LPDIRECTSOUNDBUFFER8 iface); 215 216 VOID 217 PrimaryDirectSoundBuffer_ReleaseLock( 218 LPDIRECTSOUNDBUFFER8 iface); 219 220 /* secondary.c */ 221 222 HRESULT 223 NewSecondarySoundBuffer( 224 LPDIRECTSOUNDBUFFER8 *OutBuffer, 225 LPFILTERINFO Filter, 226 DWORD dwLevel, 227 LPCDSBUFFERDESC lpcDSBufferDesc, 228 LPDIRECTSOUNDBUFFER8 PrimaryBuffer); 229 230 /* property.c */ 231 HRESULT 232 CALLBACK 233 NewKsPropertySet( 234 IUnknown* pUnkOuter, 235 REFIID riid, 236 LPVOID* ppvObject); 237 238 /* capture.c */ 239 240 HRESULT 241 CALLBACK 242 NewDirectSoundCapture( 243 IUnknown* pUnkOuter, 244 REFIID riid, 245 LPVOID* ppvObject); 246 247 248 /* capturebuffer.c */ 249 HRESULT 250 NewDirectSoundCaptureBuffer( 251 LPDIRECTSOUNDCAPTUREBUFFER8 *OutBuffer, 252 LPFILTERINFO Filter, 253 LPCDSCBUFFERDESC lpcDSBufferDesc); 254 255 /* notify.c */ 256 VOID 257 DoNotifyPositionEvents( 258 LPDIRECTSOUNDNOTIFY iface, 259 DWORD OldPosition, 260 DWORD NewPosition); 261 262 HRESULT 263 NewDirectSoundNotify( 264 LPDIRECTSOUNDNOTIFY * Notify, 265 BOOL bLoop, 266 BOOL bMix, 267 HANDLE hPin, 268 DWORD BufferSize); 269