ReactOS 0.4.15-dev-8344-g0574987
pin.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel Streaming
4 * FILE: drivers/wdm/audio/filters/splitter/pin.c
5 * PURPOSE: Pin Context Handling
6 * PROGRAMMER: Johannes Anderwald
7 */
8
9#include "precomp.h"
10
14 IN PKSPIN Pin,
15 IN PIRP Irp)
16{
17 PKSFILTER Filter;
18 PKSPIN FirstPin;
19 PPIN_CONTEXT PinContext;
20
21 /* first get the parent filter */
23
24 /* now get first child pin */
25 FirstPin = KsFilterGetFirstChildPin(Filter, Pin->Id);
26
27 /* sanity check */
28 ASSERT(FirstPin);
29
30 if (FirstPin != Pin)
31 {
32 /* a previous pin already exists */
33 if (RtlCompareMemory(FirstPin->ConnectionFormat, Pin->ConnectionFormat, Pin->ConnectionFormat->FormatSize) != Pin->ConnectionFormat->FormatSize)
34 {
35 /* each instantiated pin must have the same connection format */
37 }
38 }
39
40 /* allocate pin context */
41 PinContext = ExAllocatePool(NonPagedPool, sizeof(PIN_CONTEXT));
42 if (!PinContext)
44
45 /* store pin context */
46 Pin->Context = PinContext;
47
48 /* clear pin context */
49 RtlZeroMemory(PinContext, sizeof(PIN_CONTEXT));
50
51 /* FIXME
52 * check allocator framing and apply to all pins
53 */
54
55 return STATUS_SUCCESS;
56}
57
61 IN PKSPIN Pin,
62 IN PIRP Irp)
63{
64 /* is there a context */
65 if (Pin->Context)
66 {
67 /* free pin context */
68 ExFreePool(Pin->Context);
69 }
70
71 return STATUS_SUCCESS;
72}
73
74VOID
77 IN PKSPIN Pin)
78{
79 PKSFILTER Filter;
80
81 /* sanity check */
82 ASSERT(Pin->Context);
83
84 /* clear pin context */
85 RtlZeroMemory(Pin->Context, sizeof(PIN_CONTEXT));
86
87 /* get parent filter */
89
90 /* sanity check */
92
93 /* attempt processing */
95}
96
100 IN PKSPIN Pin,
101 IN KSSTATE ToState,
102 IN KSSTATE FromState)
103{
104 PKSFILTER Filter;
105
106 /* should the pin stop */
107 if (ToState == KSSTATE_STOP)
108 {
109 /* clear pin context */
110 RtlZeroMemory(Pin->Context, sizeof(PIN_CONTEXT));
111 }
112
113 /* get parent filter */
115
116 /* sanity check */
117 ASSERT(Filter);
118
119 /* attempt processing */
121
122 return STATUS_SUCCESS;
123}
124
126NTAPI
128 IN PIRP Irp,
131{
132 PKSFILTER Filter;
133 PKSPIN Pin, FirstPin;
137
138 /* first get the pin */
140
141 /* sanity check */
142 ASSERT(Pin);
143
144 /* get parent filter */
146
147 /* acquire filter control mutex */
148 KsFilterAcquireControl(Filter);
149
150 /* get first pin */
151 FirstPin = KsFilterGetFirstChildPin(Filter, Pin->Id);
152
153 /* get connected pin of first pin */
155
156 if (!FileObject)
157 {
158 /* no pin connected */
160 }
161 else
162 {
163 /* perform request */
165
166 /* store result size */
167 Irp->IoStatus.Information = sizeof(KSAUDIO_POSITION);
168 }
169
170 /* release control */
171 KsFilterReleaseControl(Filter);
172
173 /* done */
174 return Status;
175}
176
178NTAPI
181 IN PIRP Irp,
183 IN PKSDATARANGE DataRange,
184 IN PKSDATARANGE MatchingDataRange,
185 IN ULONG DataBufferSize,
188{
189 PKSPIN FirstPin;
191
192 /* get first pin */
193 FirstPin = KsFilterGetFirstChildPin((PKSFILTER)Context, Pin->PinId);
194
195 /* sanity check */
196 ASSERT(FirstPin);
197
198 /* check for matching dataformat */
199 if (!IsEqualGUIDAligned(&FirstPin->ConnectionFormat->SubFormat, &DataRange->SubFormat) ||
200 !IsEqualGUIDAligned(&FirstPin->ConnectionFormat->Specifier, &DataRange->Specifier) ||
201 !IsEqualGUIDAligned(&GUID_NULL, &DataRange->SubFormat) ||
202 !IsEqualGUIDAligned(&GUID_NULL, &DataRange->Specifier))
203 {
204 /* no match */
205 return STATUS_NO_MATCH;
206 }
207
208
209 if (DataBufferSize)
210 {
211 /* there is output buffer */
212 if (DataBufferSize >= FirstPin->ConnectionFormat->FormatSize)
213 {
214 /* copy dataformat */
215 RtlMoveMemory(Data, FirstPin->ConnectionFormat, FirstPin->ConnectionFormat->FormatSize);
216
217 /* store output length */
218 *DataSize = FirstPin->ConnectionFormat->FormatSize;
219
221 }
222 else
223 {
224 /* buffer too small */
226 }
227 }
228 else
229 {
230 /* store output length */
231 *DataSize = FirstPin->ConnectionFormat->FormatSize;
232
234 }
235
236 /* done */
237 return Status;
238}
239
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
KSDDKAPI NTSTATUS NTAPI KsSynchronousIoControlDevice(IN PFILE_OBJECT FileObject, IN KPROCESSOR_MODE RequestorMode, IN ULONG IoControl, IN PVOID InBuffer, IN ULONG InSize, OUT PVOID OutBuffer, IN ULONG OutSize, OUT PULONG BytesReturned)
Definition: api.c:1099
KSDDKAPI VOID NTAPI KsFilterAttemptProcessing(IN PKSFILTER Filter, IN BOOLEAN Asynchronous)
Definition: filter.c:1915
KSDDKAPI PKSPIN NTAPI KsFilterGetFirstChildPin(IN PKSFILTER Filter, IN ULONG PinId)
Definition: filter.c:2067
PKSFILTER NTAPI KsPinGetParentFilter(IN PKSPIN Pin)
Definition: pin.c:1097
KSDDKAPI PKSPIN NTAPI KsGetPinFromIrp(IN PIRP Irp)
Definition: pin.c:1211
PFILE_OBJECT NTAPI KsPinGetConnectedPinFileObject(IN PKSPIN Pin)
Definition: pin.c:1047
NTSTATUS NTAPI PinIntersectHandler(IN PVOID Context, IN PIRP Irp, IN PKSP_PIN Pin, IN PKSDATARANGE DataRange, IN PKSDATARANGE MatchingDataRange, IN ULONG DataBufferSize, OUT PVOID Data OPTIONAL, OUT PULONG DataSize)
Definition: pin.c:179
NTSTATUS NTAPI AudioPositionPropertyHandler(IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
Definition: pin.c:127
NTSTATUS NTAPI PinClose(IN PKSPIN Pin, IN PIRP Irp)
Definition: pin.c:60
NTSTATUS NTAPI PinCreate(IN PKSPIN Pin, IN PIRP Irp)
Definition: pin.c:13
NTSTATUS NTAPI PinState(IN PKSPIN Pin, IN KSSTATE ToState, IN KSSTATE FromState)
Definition: pin.c:99
VOID NTAPI PinReset(IN PKSPIN Pin)
Definition: pin.c:76
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:427
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
Status
Definition: gdiplustypes.h:25
#define GUID_NULL
Definition: ks.h:106
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
KSSTATE
Definition: ks.h:1214
@ KSSTATE_STOP
Definition: ks.h:1215
#define ASSERT(a)
Definition: mode.c:44
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755
#define KernelMode
Definition: asm.h:34
#define STATUS_NO_MATCH
Definition: ntstatus.h:751
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
Definition: ks.h:642
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_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
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
* PFILE_OBJECT
Definition: iotypes.h:1998