16const GUID KSPROPSETID_Connection = {0x1D58C920L, 0xAC9B, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
40 DPRINT(
"PerformSampleRateConversion OldRate %u NewRate %u BytesPerSample %u NumChannels %u Irql %u\n", OldRate, NewRate, BytesPerSample, NumChannels,
KeGetCurrentIrql());
42 ASSERT(BytesPerSample == 1 || BytesPerSample == 2 || BytesPerSample == 4);
53 NumSamples =
BufferLength / (BytesPerSample * NumChannels);
62 NewSamples = ((((
ULONG64)NumSamples * NewRate) + (OldRate / 2)) / OldRate) + 2;
93 if (BytesPerSample == 1)
98 else if (BytesPerSample == 2)
102 else if (BytesPerSample == 4)
107 Data.data_in = FloatIn;
108 Data.data_out = FloatOut;
109 Data.input_frames = NumSamples;
110 Data.output_frames = NewSamples;
111 Data.src_ratio = (
double)NewRate / (
double)OldRate;
124 if (BytesPerSample == 1)
131 else if (BytesPerSample == 2)
137 else if (BytesPerSample == 4)
165 ULONG NewIndex, OldIndex;
167 Samples =
BufferLength / (BitsPerSample / 8) / OldChannels;
169 if (NewChannels > OldChannels)
171 if (BitsPerSample == 8)
177 for(NewIndex = 0, OldIndex = 0; OldIndex < Samples * OldChannels; NewIndex += NewChannels, OldIndex += OldChannels)
186 BufferOut[NewIndex+OldChannels + SubIndex] =
Buffer[OldIndex + (SubIndex % OldChannels)];
187 }
while(SubIndex++ < NewChannels - OldChannels);
192 else if (BitsPerSample == 16)
198 for(NewIndex = 0, OldIndex = 0; OldIndex < Samples * OldChannels; NewIndex += NewChannels, OldIndex += OldChannels)
206 BufferOut[NewIndex+OldChannels + SubIndex] =
Buffer[OldIndex + (SubIndex % OldChannels)];
207 }
while(SubIndex++ < NewChannels - OldChannels);
212 else if (BitsPerSample == 24)
218 for(NewIndex = 0, OldIndex = 0; OldIndex < Samples * OldChannels; NewIndex += NewChannels, OldIndex += OldChannels)
226 RtlMoveMemory(&BufferOut[(NewIndex+OldChannels + SubIndex) * 3], &
Buffer[(OldIndex + (SubIndex % OldChannels)) * 3], 3);
227 }
while(SubIndex++ < NewChannels - OldChannels);
232 else if (BitsPerSample == 32)
238 for(NewIndex = 0, OldIndex = 0; OldIndex < Samples * OldChannels; NewIndex += NewChannels, OldIndex += OldChannels)
246 BufferOut[NewIndex+OldChannels + SubIndex] =
Buffer[OldIndex + (SubIndex % OldChannels)];
247 }
while(SubIndex++ < NewChannels - OldChannels);
260 for(NewIndex = 0, OldIndex = 0; OldIndex < Samples * OldChannels; NewIndex += NewChannels, OldIndex += OldChannels)
287 ASSERT(OldWidth != NewWidth);
292 if (OldWidth == 8 && NewWidth == 16)
306 BufferOut[
Index] = Sample;
311 else if (OldWidth == 8 && NewWidth == 32)
325 BufferOut[
Index] = Sample;
330 else if (OldWidth == 16 && NewWidth == 32)
340 Sample = BufferIn[
Index];
345 BufferOut[
Index] = Sample;
351 else if (OldWidth == 16 && NewWidth == 8)
361 Sample = BufferIn[
Index];
366 BufferOut[
Index] = (Sample & 0xFF);
371 else if (OldWidth == 32 && NewWidth == 8)
381 Sample = BufferIn[
Index];
386 BufferOut[
Index] = (Sample & 0xFF);
391 else if (OldWidth == 32 && NewWidth == 16)
401 Sample = BufferIn[
Index];
406 BufferOut[
Index] = (Sample & 0xFFFF);
413 DPRINT1(
"Not implemented conversion OldWidth %u NewWidth %u\n", OldWidth, NewWidth);
455 Irp->IoStatus.Information = 0;
463 Irp->IoStatus.Information = 0;
478 Irp->IoStatus.Information = 0;
491 Irp->IoStatus.Information = 0;
506 Irp->IoStatus.Information = 0;
520 Irp->IoStatus.Information = 0;
534 Irp->IoStatus.Information = 0;
549 Irp->IoStatus.Information = 0;
614 InputFormat = Formats;
619 DPRINT(
"Num Channels %u Old Channels %u\n SampleRate %u Old SampleRate %u\n BitsPerSample %u Old BitsPerSample %u\n",
635 StreamHeader->
Data = BufferOut;
653 StreamHeader->
Data = BufferOut;
671 StreamHeader->
Data = BufferOut;
722void *
calloc(
size_t Elements,
size_t ElementSize)
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
enum OutputFormat_ OutputFormat
_In_ PFCB _In_ LONGLONG FileOffset
#define NT_SUCCESS(StatCode)
KSDDKAPI NTSTATUS NTAPI KsAllocateObjectHeader(OUT KSOBJECT_HEADER *Header, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList OPTIONAL, IN PIRP Irp, IN KSDISPATCH_TABLE *Table)
const GUID KSPROPSETID_Connection
NTSTATUS NTAPI Pin_fnDeviceIoControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS CreatePin(IN PIRP Irp)
NTSTATUS NTAPI Pin_fnRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
BOOLEAN NTAPI Pin_fnFastWrite(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, ULONG LockKey, PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject)
static KSDISPATCH_TABLE PinTable
NTSTATUS NTAPI Pin_fnClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
BOOLEAN NTAPI Pin_fnFastRead(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, ULONG LockKey, PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject)
NTSTATUS NTAPI Pin_fnQuerySecurity(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS PerformQualityConversion(PUCHAR Buffer, ULONG BufferLength, ULONG OldWidth, ULONG NewWidth, PVOID *Result, PULONG ResultLength)
NTSTATUS PerformChannelConversion(PUCHAR Buffer, ULONG BufferLength, ULONG OldChannels, ULONG NewChannels, ULONG BitsPerSample, PVOID *Result, PULONG ResultLength)
NTSTATUS NTAPI Pin_fnWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS NTAPI Pin_fnSetSecurity(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS NTAPI Pin_fnFlush(PDEVICE_OBJECT DeviceObject, PIRP Irp)
BOOLEAN NTAPI Pin_fnFastDeviceIoControl(PFILE_OBJECT FileObject, BOOLEAN Wait, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, ULONG IoControlCode, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject)
NTSTATUS PerformSampleRateConversion(PUCHAR Buffer, ULONG BufferLength, ULONG OldRate, ULONG NewRate, ULONG BytesPerSample, ULONG NumChannels, PVOID *Result, PULONG ResultLength)
#define KSPROPERTY_TYPE_SET
#define KeGetCurrentIrql()
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
#define ExAllocatePool(type, size)
_Check_return_ __CRT_INLINE long lrintf(_In_ float x)
_Check_return_ unsigned long __cdecl _byteswap_ulong(_In_ unsigned long)
_Check_return_ unsigned short __cdecl _byteswap_ushort(_In_ unsigned short)
#define KeSaveFloatingPointState(x)
#define KeRestoreFloatingPointState(x)
@ KSPROPERTY_CONNECTION_DATAFORMAT
struct KSSTREAM_HEADER * PKSSTREAM_HEADER
struct KSP_PIN * PKSP_PIN
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define IoCompleteRequest
#define STATUS_NOT_IMPLEMENTED
void src_int_to_float_array(const int *in, float *out, int len)
void src_float_to_short_array(const float *in, short *out, int len)
void src_short_to_float_array(const short *in, float *out, int len)
void src_float_to_int_array(const float *in, int *out, int len)
int src_process(SRC_STATE *state, SRC_DATA *data)
SRC_STATE * src_delete(SRC_STATE *state)
SRC_STATE * src_new(int converter_type, int channels, int *error)
struct SRC_STATE_tag SRC_STATE
Property(long _type, long _tag, INREAL _value)
struct _IO_STACK_LOCATION::@1575::@1576 DeviceIoControl
union _IO_STACK_LOCATION::@1575 Parameters
#define RtlZeroMemory(Destination, Length)
#define RtlMoveMemory(Destination, Source, Length)
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
_In_ WDFDPC _In_ BOOLEAN Wait
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
_In_ WDFREQUEST _In_ size_t OutputBufferLength
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
#define IsEqualGUIDAligned(guid1, guid2)
_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