12#define PACKET_COUNT 10
27 while (CommonDescriptor)
41 if ((
ULONG_PTR)CommonDescriptor + CommonDescriptor->
bLength >= ((
ULONG_PTR)ConfigurationDescriptor + ConfigurationDescriptor->wTotalLength))
105 if (!SampleRateBuffer)
140 PinContext =
Pin->Context;
173 IN ULONG FormatDescriptorIndex)
204 if (StreamingInterfaceDescriptor !=
NULL)
210 if (FormatDescriptorIndex ==
Index)
225 DPRINT1(
"No Interface found\n");
248 if (DeviceExtension->InterfaceInfo)
256 if (DeviceExtension->InterfaceInfo ==
NULL)
287 PinContext =
Pin->Context;
298 KsGateTurnInputOn(Gate);
329 Irp->IoStatus.Information = 0;
344 PacketCount = TransferBufferSize /
PacketSize;
372 Irp->Tail.Overlay.DriverContext[0] = Urb;
391 PinContext =
Pin->Context;
394 Urb =
Irp->Tail.Overlay.DriverContext[0];
401 Irp->IoStatus.Information = 0;
404 Irp->Tail.Overlay.DriverContext[0] = Urb;
405 Irp->Tail.Overlay.DriverContext[1] =
NULL;
451 PinContext =
Pin->Context;
496 ULONG MaximumPacketSize;
514 PinContext =
Pin->Context;
577 Irp->IoStatus.Information = 0;
602 DPRINT1(
"InitCapturePin Irp %p Urb %p\n",
Irp, Urb);
611 Irp->Tail.Overlay.DriverContext[0] = Urb;
624 KsGateTurnInputOff(Gate);
642 PinContext =
Pin->Context;
675 Irp->IoStatus.Information = 0;
711 DPRINT1(
"GetDataRangeIndexForFormat expected KSDATARANGE_AUDIO\n");
721 CurrentDataRange = DataRanges[
Index];
800 Pin->Context = PinContext;
823 DPRINT1(
"USBAudioSelectAudioStreamingInterface failed with %x\n",
Status);
861 PKSSTREAM_POINTER StreamPointerClone;
867 PinContext =
Pin->Context;
873 StreamPointerClone =
Irp->Tail.Overlay.DriverContext[1];
876 Urb =
Irp->Tail.Overlay.DriverContext[0];
897 if (StreamPointerClone)
921 PinContext =
Pin->Context;
924 Urb =
Irp->Tail.Overlay.DriverContext[0];
966 PinContext =
Pin->Context;
990 PKSSTREAM_POINTER LeadingStreamPointer;
991 PKSSTREAM_POINTER CloneStreamPointer;
1002 if (LeadingStreamPointer ==
NULL)
1007 if (
NULL == LeadingStreamPointer->StreamHeader->Data)
1010 DPRINT1(
"Advancing Streampointer\n");
1015 PinContext =
Pin->Context;
1044 TransferBuffer = CloneStreamPointer->StreamHeader->Data;
1087 PacketCount = (CloneStreamPointer->OffsetIn.Remaining -
Offset) / TotalPacketSize;
1093 Irp->Tail.Overlay.DriverContext[1] = CloneStreamPointer;
1095 if ((PacketCount * TotalPacketSize) + Offset < CloneStreamPointer->OffsetIn.Remaining)
1098 PinContext->
BufferLength = CloneStreamPointer->OffsetIn.Remaining - ((PacketCount * TotalPacketSize) +
Offset);
1124 PKSSTREAM_POINTER LeadingStreamPointer;
1137 if (LeadingStreamPointer ==
NULL)
1143 KsGateTurnInputOff(Gate);
1149 PinContext =
Pin->Context;
1166 Urb = (
PURB)
Irp->Tail.Overlay.DriverContext[0];
1187 LeadingStreamPointer->StreamHeader->DataUsed +=
Length;
1189 if (
Length == LeadingStreamPointer->OffsetOut.Remaining)
1206 if (LeadingStreamPointer ==
NULL)
1255 if (LeadingStreamPointer !=
NULL)
1262 KsGateTurnInputOff(Gate);
1303 _In_opt_ const KSATTRIBUTE_LIST* AttributeRange)
1305 if (OldFormat ==
NULL)
1325 PinContext =
Pin->Context;
1344 DPRINT(
"StartCaptureIsocTransfer Irp %p\n",
Irp);
1366 if (FromState != ToState)
1427 PKSPIN_DESCRIPTOR_EX PinDescriptor;
1440 PinDescriptor = (PKSPIN_DESCRIPTOR_EX)&
Filter->Descriptor->PinDescriptors[
Pin->PinId];
1443 if (DataBufferSize == 0)
1450 ASSERT(PinDescriptor->PinDescriptor.DataRangesCount >= 0);
NTSTATUS NTAPI KsAddItemToObjectBag(IN KSOBJECT_BAG ObjectBag, IN PVOID Item, IN PFNKSFREE Free OPTIONAL)
KSDDKAPI NTSTATUS NTAPI _KsEdit(IN KSOBJECT_BAG ObjectBag, IN OUT PVOID *PointerToPointerToItem, IN ULONG NewSize, IN ULONG OldSize, IN ULONG Tag)
#define NT_SUCCESS(StatCode)
KSDDKAPI PKSFILTER NTAPI KsGetFilterFromIrp(IN PIRP Irp)
PKSFILTER NTAPI KsPinGetParentFilter(IN PKSPIN Pin)
KSDDKAPI VOID NTAPI KsStreamPointerAdvanceOffsetsAndUnlock(IN PKSSTREAM_POINTER StreamPointer, IN ULONG InUsed, IN ULONG OutUsed, IN BOOLEAN Eject)
KSDDKAPI NTSTATUS NTAPI KsStreamPointerAdvance(IN PKSSTREAM_POINTER StreamPointer)
KSDDKAPI PKSSTREAM_POINTER NTAPI KsPinGetLeadingEdgeStreamPointer(IN PKSPIN Pin, IN KSSTREAM_POINTER_STATE State)
KSDDKAPI NTSTATUS NTAPI KsStreamPointerClone(IN PKSSTREAM_POINTER StreamPointer, IN PFNKSSTREAMPOINTER CancelCallback OPTIONAL, IN ULONG ContextSize, OUT PKSSTREAM_POINTER *CloneStreamPointer)
VOID NTAPI KsPinAttemptProcessing(IN PKSPIN Pin, IN BOOLEAN Asynchronous)
KSDDKAPI NTSTATUS NTAPI KsStreamPointerSetStatusCode(IN PKSSTREAM_POINTER StreamPointer, IN NTSTATUS Status)
PKSGATE NTAPI KsPinGetAndGate(IN PKSPIN Pin)
VOID NTAPI KsPinReleaseProcessingMutex(IN PKSPIN Pin)
KSDDKAPI VOID NTAPI KsStreamPointerUnlock(IN PKSSTREAM_POINTER StreamPointer, IN BOOLEAN Eject)
VOID NTAPI KsPinAcquireProcessingMutex(IN PKSPIN Pin)
KSDDKAPI NTSTATUS NTAPI KsStreamPointerAdvanceOffsets(IN PKSSTREAM_POINTER StreamPointer, IN ULONG InUsed, IN ULONG OutUsed, IN BOOLEAN Eject)
KSDDKAPI VOID NTAPI KsStreamPointerDelete(IN PKSSTREAM_POINTER StreamPointer)
PUSB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR UsbAudioGetStreamingTerminalDescriptorByIndex(IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, IN ULONG Index)
NTSTATUS NTAPI USBAudioPinCreate(_In_ PKSPIN Pin, _In_ PIRP Irp)
VOID NTAPI CaptureGateOnWorkItem(_In_ PVOID Context)
NTSTATUS RenderInitializeUrbAndIrp(IN PKSPIN Pin, IN PPIN_CONTEXT PinContext, IN OUT PIRP Irp, IN PVOID TransferBuffer, IN ULONG TransferBufferSize, IN ULONG PacketSize)
VOID NTAPI USBAudioPinReset(_In_ PKSPIN Pin)
NTSTATUS CapturePinStateChange(_In_ PKSPIN Pin, _In_ KSSTATE ToState, _In_ KSSTATE FromState)
NTSTATUS InitCapturePin(IN PKSPIN Pin)
NTSTATUS StartCaptureIsocTransfer(IN PKSPIN Pin)
NTSTATUS UsbAudioAllocCaptureUrbIso(IN USBD_PIPE_HANDLE PipeHandle, IN ULONG MaxPacketSize, IN PVOID Buffer, IN ULONG BufferLength, OUT PURB *OutUrb)
NTSTATUS NTAPI USBAudioPinProcess(_In_ PKSPIN Pin)
NTSTATUS NTAPI UsbAudioCaptureComplete(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
NTSTATUS InitStreamPin(IN PKSPIN Pin)
VOID CaptureInitializeUrbAndIrp(IN PKSPIN Pin, IN PIRP Irp)
ULONG GetDataRangeIndexForFormat(IN PKSDATARANGE ConnectionFormat, IN const PKSDATARANGE *DataRanges, IN ULONG DataRangesCount)
NTSTATUS GetMaxPacketSizeForInterface(IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, IN PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor, KSPIN_DATAFLOW DataFlow)
VOID NTAPI CaptureAvoidPipeStarvationWorker(_In_ PVOID Context)
NTSTATUS NTAPI USBAudioPinClose(_In_ PKSPIN Pin, _In_ PIRP Irp)
PIRP PinGetIrpFromReadyList(IN PKSPIN Pin)
NTSTATUS NTAPI UsbAudioPinDataIntersect(_In_ PVOID Context, _In_ PIRP Irp, _In_ PKSP_PIN Pin, _In_ PKSDATARANGE DataRange, _In_ PKSDATARANGE MatchingDataRange, _In_ ULONG DataBufferSize, _Out_ PVOID Data, _Out_ PULONG DataSize)
NTSTATUS UsbAudioSetFormat(IN PKSPIN Pin)
NTSTATUS NTAPI USBAudioPinSetDeviceState(_In_ PKSPIN Pin, _In_ KSSTATE ToState, _In_ KSSTATE FromState)
NTSTATUS NTAPI UsbAudioRenderComplete(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
NTSTATUS PinRenderProcess(IN PKSPIN Pin)
NTSTATUS NTAPI USBAudioPinSetDataFormat(_In_ PKSPIN Pin, _In_opt_ PKSDATAFORMAT OldFormat, _In_opt_ PKSMULTIPLE_ITEM OldAttributeList, _In_ const KSDATARANGE *DataRange, _In_opt_ const KSATTRIBUTE_LIST *AttributeRange)
NTSTATUS PinCaptureProcess(IN PKSPIN Pin)
NTSTATUS USBAudioSelectAudioStreamingInterface(IN PKSPIN Pin, IN PPIN_CONTEXT PinContext, IN PDEVICE_EXTENSION DeviceExtension, IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, IN ULONG FormatDescriptorIndex)
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
#define IsListEmpty(ListHead)
#define KeReleaseSpinLock(sl, irql)
#define KeAcquireSpinLock(sl, irql)
#define RemoveHeadList(ListHead)
#define InitializeListHead(ListHead)
#define KeInitializeSpinLock(sl)
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING _In_opt_ PSTRING _In_ ULONG _In_ ULONG _In_opt_ PVOID _In_opt_ PVOID FilterContext
PVOID NTAPI AllocFunction(IN ULONG ItemSize)
VOID NTAPI FreeFunction(IN PVOID Item)
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
@ KSSTREAM_POINTER_STATE_LOCKED
struct KSALLOCATOR_FRAMING_EX * PKSALLOCATOR_FRAMING_EX
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
_In_ ULONG _In_ ULONG Offset
_In_ ULONG _In_ ULONG _In_ ULONG Length
VOID NTAPI IoInitializeIrp(IN PIRP Irp, IN USHORT PacketSize, IN CCHAR StackSize)
#define STATUS_NOT_SUPPORTED
#define STATUS_NOT_IMPLEMENTED
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
#define STATUS_MORE_PROCESSING_REQUIRED
#define STATUS_BUFFER_OVERFLOW
KS_FRAMING_ITEM FramingItem[1]
ULONG MaximumBitsPerSample
ULONG MaximumSampleFrequency
ULONG MinimumSampleFrequency
KS_FRAMING_RANGE PhysicalRange
KS_FRAMING_RANGE_WEIGHTED FramingRange
WORK_QUEUE_ITEM StarvationWorkItem
WORK_QUEUE_ITEM CaptureWorkItem
PKSWORKER StarvationWorker
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
PDEVICE_EXTENSION DeviceExtension
PDEVICE_OBJECT LowerDevice
LIST_ENTRY DoneIrpListHead
PDEVICE_OBJECT DeviceObject
struct _IO_STACK_LOCATION::@1575::@1576 DeviceIoControl
union _IO_STACK_LOCATION::@1575 Parameters
struct _IO_STACK_LOCATION::@3974::@4013 Others
struct _URB_ISOCH_TRANSFER UrbIsochronousTransfer
struct _URB_SELECT_INTERFACE UrbSelectInterface
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define RtlMoveMemory(Destination, Source, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_INVALID_PARAMETER
#define STATUS_DEVICE_DATA_ERROR
#define STATUS_INSUFFICIENT_RESOURCES
#define USB_ENDPOINT_DESCRIPTOR_TYPE
struct _USB_COMMON_DESCRIPTOR * PUSB_COMMON_DESCRIPTOR
struct _USB_ENDPOINT_DESCRIPTOR * PUSB_ENDPOINT_DESCRIPTOR
#define USB_INTERFACE_DESCRIPTOR_TYPE
#define USB_DEVICE_CLASS_AUDIO
#define USBD_TRANSFER_DIRECTION_IN
#define USBD_TRANSFER_DIRECTION_OUT
#define USBD_START_ISO_TRANSFER_ASAP
#define URB_FUNCTION_CLASS_ENDPOINT
#define URB_FUNCTION_ISOCH_TRANSFER
NTSTATUS SubmitUrbSync(IN PDEVICE_OBJECT DeviceObject, IN PURB Urb)
#define USB_AUDIO_CONTROL_TERMINAL_DESCRIPTOR_TYPE
struct USB_AUDIO_STREAMING_INTERFACE_DESCRIPTOR * PUSB_AUDIO_STREAMING_INTERFACE_DESCRIPTOR
PUSB_COMMON_DESCRIPTOR NTAPI USBD_ParseDescriptors(PVOID DescriptorBuffer, ULONG TotalLength, PVOID StartPosition, LONG DescriptorType)
PUSB_INTERFACE_DESCRIPTOR NTAPI USBD_ParseConfigurationDescriptorEx(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, PVOID StartPosition, LONG InterfaceNumber, LONG AlternateSetting, LONG InterfaceClass, LONG InterfaceSubClass, LONG InterfaceProtocol)
#define UsbBuildVendorRequest(urb, cmd, length, transferFlags, reservedbits, request, value, index, transferBuffer, transferBufferMDL, transferBufferLength, link)
#define UsbBuildSelectInterfaceRequest(urb, length, configurationHandle, interfaceNumber, alternateSetting)
#define GET_SELECT_INTERFACE_REQUEST_SIZE(totalPipes)
#define GET_ISO_URB_SIZE(n)
#define IOCTL_INTERNAL_USB_SUBMIT_URB
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
_In_ WDFUSBINTERFACE _In_ UCHAR _Out_ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
#define IsEqualGUIDAligned(guid1, guid2)
KSDDKAPI ULONG NTAPI KsDecrementCountedWorker(IN PKSWORKER Worker)
KSDDKAPI VOID NTAPI KsUnregisterWorker(IN PKSWORKER Worker)
KSDDKAPI ULONG NTAPI KsIncrementCountedWorker(IN PKSWORKER Worker)
KSDDKAPI NTSTATUS NTAPI KsRegisterCountedWorker(IN WORK_QUEUE_TYPE WorkQueueType, IN PWORK_QUEUE_ITEM CountedWorkItem, OUT PKSWORKER *Worker)
#define ExInitializeWorkItem(Item, Routine, Context)
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
#define IoSizeOfIrp(_StackSize)
#define IRP_MJ_INTERNAL_DEVICE_CONTROL