ReactOS 0.4.15-dev-7961-gdcf9eb0
misc.c File Reference
#include "precomp.h"
Include dependency graph for misc.c:

Go to the source code of this file.

Functions

VOID PerformChannelConversion (PUCHAR Buffer, ULONG BufferLength, PULONG BytesRead, ULONG OldChannels, ULONG NewChannels, ULONG BitsPerSample, PUCHAR Result, ULONG ResultLength, PULONG BytesWritten)
 
BOOL SetPinFormat (IN HANDLE hPin, IN LPWAVEFORMATEX WaveFormatEx)
 
BOOL DoDataIntersection (HANDLE hFilter, DWORD PinId, DWORD SampleFrequency, LPWAVEFORMATEX WaveFormatEx, DWORD MinimumBitsPerSample, DWORD MaximumBitsPerSample, DWORD MaximumChannels, LPWAVEFORMATEX WaveFormatOut)
 
DWORD OpenPin (HANDLE hFilter, ULONG PinId, LPWAVEFORMATEX WaveFormatEx, PHANDLE hPin, BOOL bLoop)
 
DWORD OpenFilter (IN LPCWSTR lpFileName, IN PHANDLE OutHandle)
 
DWORD SyncOverlappedDeviceIoControl (IN HANDLE Handle, IN DWORD IoControlCode, IN LPVOID InBuffer, IN DWORD InBufferSize, OUT LPVOID OutBuffer, IN DWORD OutBufferSize, OUT LPDWORD BytesTransferred OPTIONAL)
 
DWORD GetFilterPinCount (IN HANDLE hFilter, OUT PULONG NumPins)
 
DWORD GetFilterNodeProperty (IN HANDLE hFilter, IN ULONG PropertyId, OUT PKSMULTIPLE_ITEM *OutMultipleItem)
 
DWORD GetFilterPinCommunication (IN HANDLE hFilter, IN ULONG PinId, OUT PKSPIN_COMMUNICATION Communication)
 
DWORD GetFilterPinDataFlow (IN HANDLE hFilter, IN ULONG PinId, OUT PKSPIN_DATAFLOW DataFlow)
 
DWORD GetFilterPinDataRanges (IN HANDLE hFilter, IN ULONG PinId, IN OUT PKSMULTIPLE_ITEM *OutMultipleItem)
 
BOOL CreateCompatiblePin (IN HANDLE hFilter, IN DWORD PinId, IN BOOL bLoop, IN LPWAVEFORMATEX WaveFormatEx, OUT LPWAVEFORMATEX WaveFormatOut, OUT PHANDLE hPin)
 

Variables

const GUID KSPROPSETID_Pin = {0x8C134960L, 0x51AD, 0x11CF, {0x87, 0x8A, 0x94, 0xF8, 0x01, 0xC1, 0x00, 0x00}}
 
const GUID KSPROPSETID_Topology = {0x720D4AC0L, 0x7533, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
 
const GUID KSPROPSETID_Audio = {0x45FFAAA0L, 0x6E1B, 0x11D0, {0xBC, 0xF2, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}
 

Function Documentation

◆ CreateCompatiblePin()

BOOL CreateCompatiblePin ( IN HANDLE  hFilter,
IN DWORD  PinId,
IN BOOL  bLoop,
IN LPWAVEFORMATEX  WaveFormatEx,
OUT LPWAVEFORMATEX  WaveFormatOut,
OUT PHANDLE  hPin 
)

Definition at line 517 of file misc.c.

524{
526 PKSDATARANGE_AUDIO AudioRange;
527 DWORD dwResult;
528 DWORD dwIndex, nChannels;
529
530 dwResult = GetFilterPinDataRanges(hFilter, PinId, &Item);
531
532 if (dwResult != ERROR_SUCCESS)
533 {
534 /* failed to get data ranges */
535 return FALSE;
536 }
537
538 CopyMemory(WaveFormatOut, WaveFormatEx, sizeof(WAVEFORMATEX));
539
540 /* iterate through all dataranges */
541 AudioRange = (PKSDATARANGE_AUDIO)(Item + 1);
542 for(dwIndex = 0; dwIndex < Item->Count; dwIndex++)
543 {
544 if (AudioRange->DataRange.FormatSize != sizeof(KSDATARANGE_AUDIO))
545 {
547 AudioRange = (PKSDATARANGE_AUDIO)((PUCHAR)AudioRange + AudioRange->DataRange.FormatSize);
548 continue;
549 }
550
551 if (WaveFormatOut->nSamplesPerSec < AudioRange->MinimumSampleFrequency)
552 WaveFormatOut->nSamplesPerSec = AudioRange->MinimumSampleFrequency;
553 else if (WaveFormatOut->nSamplesPerSec > AudioRange->MaximumSampleFrequency)
554 WaveFormatOut->nSamplesPerSec = AudioRange->MaximumSampleFrequency;
555
556 if (WaveFormatOut->wBitsPerSample < AudioRange->MinimumBitsPerSample)
557 WaveFormatOut->wBitsPerSample = AudioRange->MinimumBitsPerSample;
558 else if (WaveFormatOut->wBitsPerSample > AudioRange->MaximumBitsPerSample)
559 WaveFormatOut->wBitsPerSample = AudioRange->MaximumBitsPerSample;
560
561 DPRINT("MinimumBitsPerSample %u MaximumBitsPerSample %u MinimumSampleFrequency %u MaximumSampleFrequency %u\n",
562 AudioRange->MinimumBitsPerSample, AudioRange->MaximumBitsPerSample, AudioRange->MinimumSampleFrequency, AudioRange->MaximumSampleFrequency);
563
564 for(nChannels = 1; nChannels <= AudioRange->MaximumChannels; nChannels++)
565 {
566 WaveFormatOut->nChannels = nChannels;
567
568 dwResult = OpenPin(hFilter, PinId, WaveFormatOut, hPin, TRUE);
569 if (dwResult == ERROR_SUCCESS)
570 {
571 DPRINT("InFormat nChannels %u wBitsPerSample %u nSamplesPerSec %u\nOutFormat nChannels %u nBitsPerSample %u nSamplesPerSec %u\n",
572 WaveFormatEx->nChannels, WaveFormatEx->wBitsPerSample, WaveFormatEx->nSamplesPerSec,
573 WaveFormatOut->nChannels, WaveFormatOut->wBitsPerSample, WaveFormatOut->nSamplesPerSec);
574
575
576 /* free buffer */
578 return TRUE;
579 }
580 }
581 AudioRange = (PKSDATARANGE_AUDIO)((PUCHAR)AudioRange + AudioRange->DataRange.FormatSize);
582 }
583
584 /* free buffer */
586 return FALSE;
587}
#define UNIMPLEMENTED
Definition: debug.h:115
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD GetFilterPinDataRanges(IN HANDLE hFilter, IN ULONG PinId, IN OUT PKSMULTIPLE_ITEM *OutMultipleItem)
Definition: misc.c:461
DWORD OpenPin(HANDLE hFilter, ULONG PinId, LPWAVEFORMATEX WaveFormatEx, PHANDLE hPin, BOOL bLoop)
Definition: misc.c:212
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned long DWORD
Definition: ntddk_ex.h:95
struct KSDATARANGE_AUDIO * PKSDATARANGE_AUDIO
int nChannels
Definition: pcmconverter.c:95
#define DPRINT
Definition: sndvol32.h:71
ULONG MaximumChannels
Definition: ksmedia.h:680
ULONG MinimumBitsPerSample
Definition: ksmedia.h:681
ULONG MaximumBitsPerSample
Definition: ksmedia.h:682
ULONG MaximumSampleFrequency
Definition: ksmedia.h:684
KSDATARANGE DataRange
Definition: ksmedia.h:679
ULONG MinimumSampleFrequency
Definition: ksmedia.h:683
unsigned char * PUCHAR
Definition: typedefs.h:53
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
#define CopyMemory
Definition: winbase.h:1710

Referenced by NewDirectSoundCaptureBuffer().

◆ DoDataIntersection()

BOOL DoDataIntersection ( HANDLE  hFilter,
DWORD  PinId,
DWORD  SampleFrequency,
LPWAVEFORMATEX  WaveFormatEx,
DWORD  MinimumBitsPerSample,
DWORD  MaximumBitsPerSample,
DWORD  MaximumChannels,
LPWAVEFORMATEX  WaveFormatOut 
)

Definition at line 116 of file misc.c.

125{
126 DWORD nChannels, nBitsPerSample;
127 KSDATAFORMAT_WAVEFORMATEX WaveFormat;
131 DWORD dwResult;
132
133 /* allocate request */
135 if (!Pin)
136 {
137 /* no memory */
138 return FALSE;
139 }
140
141 Item = (PKSMULTIPLE_ITEM)(Pin + 1);
143
144 /* setup request */
145 Pin->PinId = PinId;
146 Pin->Property.Flags = KSPROPERTY_TYPE_GET;
147 Pin->Property.Set = KSPROPSETID_Pin;
149 Item->Count = 1;
150 Item->Size = sizeof(KSDATAFORMAT_WAVEFORMATEX);
151
152
153 DataFormat->WaveFormatEx.wFormatTag = WaveFormatEx->wFormatTag;
154 DataFormat->WaveFormatEx.nSamplesPerSec = SampleFrequency;
155 DataFormat->WaveFormatEx.nBlockAlign = WaveFormatEx->nBlockAlign;
156 DataFormat->WaveFormatEx.cbSize = 0;
157 DataFormat->DataFormat.FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX);
158 DataFormat->DataFormat.Flags = 0;
159 DataFormat->DataFormat.Reserved = 0;
160 DataFormat->DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO;
161 DataFormat->DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
162 DataFormat->DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX;
163 DataFormat->DataFormat.SampleSize = 4;
164
165 for(nChannels = 1; nChannels <= 2; nChannels++)
166 {
167 for(nBitsPerSample = MinimumBitsPerSample; nBitsPerSample <= MaximumBitsPerSample; nBitsPerSample += 8)
168 {
169 DataFormat->WaveFormatEx.nChannels = nChannels;
170 DataFormat->WaveFormatEx.nAvgBytesPerSec = (nBitsPerSample / 8) * nChannels * SampleFrequency;
171 DataFormat->WaveFormatEx.wBitsPerSample = nBitsPerSample;
172
173 DPRINT("CurrentFormat: InFormat nChannels %u wBitsPerSample %u nSamplesPerSec %u\n",
174 nChannels, nBitsPerSample, SampleFrequency);
175
177 (LPVOID)&WaveFormat, sizeof(KSDATAFORMAT_WAVEFORMATEX), NULL);
178
179 DPRINT("dwResult %x\n", dwResult);
180
181
182 if (dwResult == ERROR_SUCCESS)
183 {
184 /* found a compatible audio range */
185 WaveFormatOut->cbSize = 0;
186 WaveFormatOut->nBlockAlign = WaveFormatEx->nBlockAlign;
187 WaveFormatOut->wFormatTag = WaveFormatEx->wFormatTag;
188 WaveFormatOut->nAvgBytesPerSec = (nBitsPerSample / 8) * nChannels * SampleFrequency;
189 WaveFormatOut->wBitsPerSample = nBitsPerSample;
190 WaveFormatOut->nSamplesPerSec = SampleFrequency;
191 WaveFormatOut->nChannels = nChannels;
192
193 /* free buffer */
195
196 DPRINT("InFormat nChannels %u wBitsPerSample %u nSamplesPerSec %u\nOutFormat nChannels %u nBitsPerSample %u nSamplesPerSec %u\n",
197 WaveFormatEx->nChannels, WaveFormatEx->wBitsPerSample, WaveFormatEx->nSamplesPerSec,
198 WaveFormatOut->nChannels, WaveFormatOut->wBitsPerSample, WaveFormatOut->nSamplesPerSec);
199
200 return TRUE;
201 }
202 }
203 }
204
205 /* free buffer */
207 ASSERT(0);
208 return FALSE;
209}
const GUID KSPROPSETID_Pin
Definition: misc.c:12
DWORD SyncOverlappedDeviceIoControl(IN HANDLE Handle, IN DWORD IoControlCode, IN LPVOID InBuffer, IN DWORD InBufferSize, OUT LPVOID OutBuffer, IN DWORD OutBufferSize, OUT LPDWORD BytesTransferred OPTIONAL)
Definition: misc.c:298
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:427
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
@ KSPROPERTY_PIN_DATAINTERSECTION
Definition: ks.h:629
struct KSMULTIPLE_ITEM * PKSMULTIPLE_ITEM
struct KSDATAFORMAT_WAVEFORMATEX * PKSDATAFORMAT_WAVEFORMATEX
#define KSDATAFORMAT_SUBTYPE_PCM
Definition: ksmedia.h:1021
#define KSDATAFORMAT_TYPE_AUDIO
Definition: ksmedia.h:983
#define KSDATAFORMAT_SPECIFIER_WAVEFORMATEX
Definition: ksmedia.h:1031
#define ASSERT(a)
Definition: mode.c:44
Definition: ks.h:642
ULONG Flags
Definition: ntfs.h:536
WORD nBlockAlign
Definition: mmreg.h:82
WORD cbSize
Definition: mmreg.h:84
DWORD nAvgBytesPerSec
Definition: mmreg.h:81
DWORD nSamplesPerSec
Definition: mmreg.h:80
WORD nChannels
Definition: mmreg.h:79
WORD wFormatTag
Definition: mmreg.h:78
WORD wBitsPerSample
Definition: mmreg.h:83

◆ GetFilterNodeProperty()

DWORD GetFilterNodeProperty ( IN HANDLE  hFilter,
IN ULONG  PropertyId,
OUT PKSMULTIPLE_ITEM OutMultipleItem 
)

Definition at line 375 of file misc.c.

379{
381 PKSMULTIPLE_ITEM MultipleItem;
383
384 /* setup query request */
385 Property.Id = PropertyId;
388
389 /* query the size */
391
392 if (Status != ERROR_MORE_DATA)
393 {
394 /* failed */
395 DPRINT("Failed to query PropertyId %lu ErrorCode %lx\n", PropertyId, Status);
396 return Status;
397 }
398
399 MultipleItem = HeapAlloc(GetProcessHeap(), 0, BytesReturned);
400 if (!MultipleItem)
401 {
402 /* not enough memory */
403 DPRINT("Failed to allocate %u Bytes\n", BytesReturned);
404 return ERROR_OUTOFMEMORY;
405 }
406
407 /* retrieve data ranges */
409
410
411 if (Status != ERROR_SUCCESS)
412 {
413 /* failed to get data ranges */
414 DPRINT("SyncOverlappedDeviceIoControl failed with %lx\n", Status);
415
416 HeapFree(GetProcessHeap(), 0, MultipleItem);
417 return Status;
418 }
419
420 /* save result */
421 *OutMultipleItem = MultipleItem;
422 return Status;
423
424}
_In_ PSTORAGE_PROPERTY_ID PropertyId
Definition: cdrom.h:932
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
const GUID KSPROPSETID_Topology
Definition: misc.c:13
Status
Definition: gdiplustypes.h:25
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesReturned
Definition: wdfiotarget.h:1052

◆ GetFilterPinCommunication()

DWORD GetFilterPinCommunication ( IN HANDLE  hFilter,
IN ULONG  PinId,
OUT PKSPIN_COMMUNICATION  Communication 
)

Definition at line 427 of file misc.c.

431{
433
437 Property.PinId = PinId;
438 Property.Reserved = 0;
439
440 return SyncOverlappedDeviceIoControl(hFilter, IOCTL_KS_PROPERTY, (LPVOID)&Property, sizeof(KSP_PIN), (LPVOID)Communication, sizeof(KSPIN_COMMUNICATION), NULL);
441}
@ KSPROPERTY_PIN_COMMUNICATION
Definition: ks.h:632
KSPIN_COMMUNICATION
Definition: ks.h:1253
Property(long _type, long _tag, INREAL _value)
Definition: reader.h:125

Referenced by FindAudioFilterPins().

◆ GetFilterPinCount()

DWORD GetFilterPinCount ( IN HANDLE  hFilter,
OUT PULONG  NumPins 
)

Definition at line 357 of file misc.c.

360{
362
363 *NumPins = 0;
364
365 /* setup the pin request */
367 Pin.Set = KSPROPSETID_Pin;
369
370 /* query the device */
371 return SyncOverlappedDeviceIoControl(hFilter, IOCTL_KS_PROPERTY, (LPVOID)&Pin, sizeof(KSPROPERTY), (PVOID)NumPins, sizeof(ULONG), NULL);
372}
@ KSPROPERTY_PIN_CTYPES
Definition: ks.h:626
uint32_t ULONG
Definition: typedefs.h:59

Referenced by EnumerateAudioFilter().

◆ GetFilterPinDataFlow()

DWORD GetFilterPinDataFlow ( IN HANDLE  hFilter,
IN ULONG  PinId,
OUT PKSPIN_DATAFLOW  DataFlow 
)

Definition at line 444 of file misc.c.

448{
450
454 Property.PinId = PinId;
455 Property.Reserved = 0;
456
458}
DataFlow
@ KSPROPERTY_PIN_DATAFLOW
Definition: ks.h:627
KSPIN_DATAFLOW
Definition: ks.h:1248

Referenced by FindAudioFilterPins().

◆ GetFilterPinDataRanges()

DWORD GetFilterPinDataRanges ( IN HANDLE  hFilter,
IN ULONG  PinId,
IN OUT PKSMULTIPLE_ITEM OutMultipleItem 
)

Definition at line 461 of file misc.c.

465{
469 PKSMULTIPLE_ITEM MultipleItem;
470
471 /* prepare request */
472 Property.Reserved = 0;
473 Property.PinId = PinId;
477
478 /* retrieve size of data ranges buffer */
480
481#if 0
482 if (Status != ERROR_MORE_DATA)
483 {
484 DPRINT("SyncOverlappedDeviceIoControl failed with %lx\n", Status);
485 return Status;
486 }
487#endif
488
490 MultipleItem = HeapAlloc(GetProcessHeap(), 0, BytesReturned);
491 if (!MultipleItem)
492 {
493 /* not enough memory */
494 DPRINT("Failed to allocate %u Bytes\n", BytesReturned);
495 return ERROR_OUTOFMEMORY;
496 }
497
498 /* retrieve data ranges */
500
501
502 if (Status != ERROR_SUCCESS)
503 {
504 /* failed to get data ranges */
505 DPRINT("SyncOverlappedDeviceIoControl failed with %lx\n", Status);
506
507 HeapFree(GetProcessHeap(), 0, MultipleItem);
508 return Status;
509 }
510
511 /* save result */
512 *OutMultipleItem = MultipleItem;
513 return Status;
514}
@ KSPROPERTY_PIN_DATARANGES
Definition: ks.h:628

Referenced by CreateCompatiblePin().

◆ OpenFilter()

DWORD OpenFilter ( IN LPCWSTR  lpFileName,
IN PHANDLE  OutHandle 
)

Definition at line 277 of file misc.c.

280{
282
283 /* open the filter */
285
286 /* check for success */
288 {
289 DPRINT("Failed to open Filter %ws\n", lpFileName);
290 return GetLastError();
291 }
292
293 *OutHandle = Handle;
294 return ERROR_SUCCESS;
295}
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
ULONG Handle
Definition: gdb_input.c:15
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define GENERIC_WRITE
Definition: nt_native.h:90
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LPCSTR lpFileName
Definition: winbase.h:3071

Referenced by EnumerateAudioFilter().

◆ OpenPin()

DWORD OpenPin ( HANDLE  hFilter,
ULONG  PinId,
LPWAVEFORMATEX  WaveFormatEx,
PHANDLE  hPin,
BOOL  bLoop 
)

Definition at line 212 of file misc.c.

218{
220 PKSPIN_CONNECT PinConnect;
222
223 /* calculate request size */
224 Size = sizeof(KSPIN_CONNECT) + sizeof(KSDATAFORMAT_WAVEFORMATEX);
225
227 if (!PinConnect)
228 {
229 /* not enough memory */
230 return DSERR_OUTOFMEMORY;
231 }
232 /* build pin request */
234
235 if (bLoop)
237 else
239
240 PinConnect->Interface.Flags = 0;
241 PinConnect->Medium.Set = KSMEDIUMSETID_Standard;
242 PinConnect->Medium.Id = KSMEDIUM_TYPE_ANYINSTANCE;
243 PinConnect->Medium.Flags = 0;
244 PinConnect->PinToHandle = NULL;
245 PinConnect->PinId = PinId;
247 PinConnect->Priority.PrioritySubClass = 1;
248
249 DataFormat = (PKSDATAFORMAT_WAVEFORMATEX) (PinConnect + 1);
250
251 /* initialize data format */
252 DataFormat->WaveFormatEx.wFormatTag = WaveFormatEx->wFormatTag;
253 DataFormat->WaveFormatEx.nChannels = WaveFormatEx->nChannels;
254 DataFormat->WaveFormatEx.nSamplesPerSec = WaveFormatEx->nSamplesPerSec;
255 DataFormat->WaveFormatEx.nBlockAlign = WaveFormatEx->nBlockAlign;
256 DataFormat->WaveFormatEx.nAvgBytesPerSec = WaveFormatEx->nAvgBytesPerSec;
257 DataFormat->WaveFormatEx.wBitsPerSample = WaveFormatEx->wBitsPerSample;
258 DataFormat->WaveFormatEx.cbSize = 0;
259 DataFormat->DataFormat.FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX);
260 DataFormat->DataFormat.Flags = 0;
261 DataFormat->DataFormat.Reserved = 0;
262 DataFormat->DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO;
263
264 DataFormat->DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
265 DataFormat->DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX;
266 DataFormat->DataFormat.SampleSize = 4;
267
268 Result = KsCreatePin(hFilter, PinConnect, GENERIC_READ | GENERIC_WRITE, hPin);
269
270 HeapFree(GetProcessHeap(), 0, PinConnect);
271
272 return Result;
273}
#define DSERR_OUTOFMEMORY
Definition: dsound.h:125
#define KSPRIORITY_NORMAL
Definition: ks.h:1386
#define KSMEDIUM_TYPE_ANYINSTANCE
Definition: ks.h:301
#define KSMEDIUMSETID_Standard
Definition: ks.h:306
@ KSINTERFACE_STANDARD_STREAMING
Definition: ks.h:283
@ KSINTERFACE_STANDARD_LOOPED_STREAMING
Definition: ks.h:284
#define KSINTERFACESETID_Standard
Definition: ks.h:280
KSDDKAPI DWORD NTAPI KsCreatePin(HANDLE FilterHandle, PKSPIN_CONNECT Connect, ACCESS_MASK DesiredAccess, PHANDLE ConnectionHandle)
Definition: ksuser.c:192
ULONG Id
Definition: dmksctrl.h:77
ULONG Flags
Definition: dmksctrl.h:78
GUID Set
Definition: dmksctrl.h:76
ULONG PinId
Definition: ks.h:2603
KSPIN_MEDIUM Medium
Definition: ks.h:2602
KSPRIORITY Priority
Definition: ks.h:2605
KSPIN_INTERFACE Interface
Definition: ks.h:2601
HANDLE PinToHandle
Definition: ks.h:2604
ULONG PriorityClass
Definition: ks.h:1391
ULONG PrioritySubClass
Definition: ks.h:1392
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_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:409

Referenced by CreateCompatiblePin(), NewDirectSoundCaptureBuffer(), and PrimaryDirectSoundBuffer_SetFormat().

◆ PerformChannelConversion()

VOID PerformChannelConversion ( PUCHAR  Buffer,
ULONG  BufferLength,
PULONG  BytesRead,
ULONG  OldChannels,
ULONG  NewChannels,
ULONG  BitsPerSample,
PUCHAR  Result,
ULONG  ResultLength,
PULONG  BytesWritten 
)

Definition at line 18 of file misc.c.

28{
29 DWORD NewIndex, OldIndex;
30 DWORD NewLength, Skip;
31
32 if (NewChannels > OldChannels)
33 {
35 ASSERT(0);
36 }
37
38 /* setup index */
39 NewIndex = 0;
40 OldIndex = 0;
41
42 /* calculate offsets */
43 NewLength = NewChannels * (BitsPerSample/8);
44 Skip = OldChannels * (BitsPerSample/8);
45
46 do
47 {
48 if (NewIndex + NewLength>= ResultLength)
49 {
50 NewIndex = ResultLength;
51 break;
52 }
53
54 if (OldIndex + Skip >= BufferLength)
55 {
56 OldIndex = BufferLength;
57 break;
58 }
59
60 /* copy first channel */
61 RtlMoveMemory(&Result[NewIndex], &Buffer[OldIndex], NewLength);
62
63 /* skip other channels */
64 OldIndex += Skip;
65
66 /* increment offset */
67 NewIndex += NewLength;
68
69 }while(TRUE);
70
71 *BytesRead = OldIndex;
72 *BytesWritten = NewIndex;
73}
static USHORT USHORT * NewLength
Definition: bufpool.h:45
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870

Referenced by MixerThreadRoutine().

◆ SetPinFormat()

BOOL SetPinFormat ( IN HANDLE  hPin,
IN LPWAVEFORMATEX  WaveFormatEx 
)

Definition at line 77 of file misc.c.

80{
81 DWORD dwResult;
84
85 /* setup connection request */
89
90 /* setup data format */
91 DataFormat.WaveFormatEx.wFormatTag = WaveFormatEx->wFormatTag;
92 DataFormat.WaveFormatEx.nSamplesPerSec = WaveFormatEx->nSamplesPerSec;
93 DataFormat.WaveFormatEx.nBlockAlign = WaveFormatEx->nBlockAlign;
94 DataFormat.WaveFormatEx.cbSize = 0;
95 DataFormat.DataFormat.FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX);
96 DataFormat.DataFormat.Flags = 0;
97 DataFormat.DataFormat.Reserved = 0;
98 DataFormat.DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO;
99 DataFormat.DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
100 DataFormat.DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX;
101 DataFormat.DataFormat.SampleSize = 4;
102 DataFormat.WaveFormatEx.nChannels = WaveFormatEx->nChannels;
103 DataFormat.WaveFormatEx.nAvgBytesPerSec = WaveFormatEx->nAvgBytesPerSec;
104 DataFormat.WaveFormatEx.wBitsPerSample = WaveFormatEx->wBitsPerSample;
105
107
108 if (dwResult == ERROR_SUCCESS)
109 return TRUE;
110 else
111 return FALSE;
112}
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
@ KSPROPERTY_CONNECTION_DATAFORMAT
Definition: ks.h:351
#define KSPROPSETID_Connection
Definition: ks.h:346

Referenced by PrimaryDirectSoundBuffer_SetFormat().

◆ SyncOverlappedDeviceIoControl()

DWORD SyncOverlappedDeviceIoControl ( IN HANDLE  Handle,
IN DWORD  IoControlCode,
IN LPVOID  InBuffer,
IN DWORD  InBufferSize,
OUT LPVOID  OutBuffer,
IN DWORD  OutBufferSize,
OUT LPDWORD BytesTransferred  OPTIONAL 
)

Definition at line 298 of file misc.c.

306{
307 OVERLAPPED Overlapped;
308 BOOLEAN IoResult;
309 DWORD Transferred = 0;
310
311 /* Overlapped I/O is done here - this is used for waiting for completion */
312 ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
313 Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
314
315 if (!Overlapped.hEvent)
316 return GetLastError();
317
318 /* Talk to the device */
319 IoResult = DeviceIoControl(Handle,
321 InBuffer,
323 OutBuffer,
326 &Overlapped);
327
328 /* If failure occurs, make sure it's not just due to the overlapped I/O */
329 if (!IoResult)
330 {
332 {
333 CloseHandle(Overlapped.hEvent);
334 return GetLastError();
335 }
336 }
337
338 /* Wait for the I/O to complete */
339 IoResult = GetOverlappedResult(Handle,
340 &Overlapped,
341 &Transferred,
342 TRUE);
343
344 /* Don't need this any more */
345 CloseHandle(Overlapped.hEvent);
346
347 if (!IoResult)
348 return GetLastError();
349
350 if ( BytesTransferred )
351 *BytesTransferred = Transferred;
352
353 return ERROR_SUCCESS;
354}
unsigned char BOOLEAN
#define ERROR_IO_PENDING
Definition: dderror.h:15
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:221
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
HANDLE hEvent
Definition: winbase.h:820
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ PWDF_MEMORY_DESCRIPTOR _Out_opt_ PULONG BytesTransferred
Definition: wdfusb.h:1342
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
_In_ ULONG InBufferSize
Definition: wdfwmi.h:106
#define ZeroMemory
Definition: winbase.h:1712
#define CreateEvent
Definition: winbase.h:3748

Referenced by DoDataIntersection(), GetFilterNodeProperty(), GetFilterPinCommunication(), GetFilterPinCount(), GetFilterPinDataFlow(), GetFilterPinDataRanges(), GetNt4SoundDeviceCapabilities(), IDirectSoundCaptureBufferImpl_GetCurrentPosition(), IDirectSoundCaptureBufferImpl_Start(), IDirectSoundCaptureBufferImpl_Stop(), IDirectSoundNotify_fnSetNotificationPositions(), MixerEventThreadRoutine(), MixerThreadRoutine(), PrimaryDirectSoundBuffer_GetPosition(), PrimaryDirectSoundBuffer_SetState(), QueryNt4WaveDeviceFormatSupport(), SetNt4WaveDeviceFormat(), SetPinFormat(), WdmAudCloseSoundDeviceByLegacy(), WdmAudGetCapabilitiesByLegacy(), WdmAudGetDeviceInterfaceStringByLegacy(), WdmAudGetNumWdmDevsByLegacy(), WdmAudGetWavePositionByLegacy(), WdmAudQueryMixerInfoByLegacy(), WdmAudResetStreamByLegacy(), WdmAudSetMixerDeviceFormatByLegacy(), WdmAudSetWaveDeviceFormatByLegacy(), and WdmAudSetWaveStateByLegacy().

Variable Documentation

◆ KSPROPSETID_Audio

const GUID KSPROPSETID_Audio = {0x45FFAAA0L, 0x6E1B, 0x11D0, {0xBC, 0xF2, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}

Definition at line 14 of file misc.c.

◆ KSPROPSETID_Pin

const GUID KSPROPSETID_Pin = {0x8C134960L, 0x51AD, 0x11CF, {0x87, 0x8A, 0x94, 0xF8, 0x01, 0xC1, 0x00, 0x00}}

◆ KSPROPSETID_Topology

const GUID KSPROPSETID_Topology = {0x720D4AC0L, 0x7533, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}

Definition at line 13 of file misc.c.

Referenced by GetFilterNodeProperty().