ReactOS  0.4.14-dev-1007-g90d795b
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 
12 NTAPI
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 
59 NTAPI
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 
74 VOID
75 NTAPI
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 */
91  ASSERT(Filter);
92 
93  /* attempt processing */
95 }
96 
98 NTAPI
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 
125 NTSTATUS
126 NTAPI
128  IN PIRP Irp,
130  IN OUT PVOID Data)
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 
177 NTSTATUS
178 NTAPI
180  IN PVOID Context,
181  IN PIRP Irp,
182  IN PKSP_PIN Pin,
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 
PKSFILTER NTAPI KsPinGetParentFilter(IN PKSPIN Pin)
Definition: pin.c:1097
NTSTATUS NTAPI PinClose(IN PKSPIN Pin, IN PIRP Irp)
Definition: pin.c:60
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define IN
Definition: typedefs.h:39
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
KSDDKAPI PKSPIN NTAPI KsFilterGetFirstChildPin(IN PKSFILTER Filter, IN ULONG PinId)
Definition: filter.c:2067
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI AudioPositionPropertyHandler(IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
Definition: pin.c:127
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
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
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
VOID NTAPI PinReset(IN PKSPIN Pin)
Definition: pin.c:76
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
Definition: ks.h:642
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
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
* PFILE_OBJECT
Definition: iotypes.h:1955
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define GUID_NULL
Definition: ks.h:106
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
KSSTATE
Definition: ks.h:1214
#define STATUS_NO_MATCH
Definition: ntstatus.h:737
_In_ FILTER_INFORMATION_CLASS _In_ ULONG _Out_ PULONG BytesReturned
Definition: fltkernel.h:1716
NTSTATUS NTAPI PinState(IN PKSPIN Pin, IN KSSTATE ToState, IN KSSTATE FromState)
Definition: pin.c:99
unsigned int * PULONG
Definition: retypes.h:1
NTSTATUS NTAPI PinCreate(IN PKSPIN Pin, IN PIRP Irp)
Definition: pin.c:13
KSDDKAPI PKSPIN NTAPI KsGetPinFromIrp(IN PIRP Irp)
Definition: pin.c:1211
#define OUT
Definition: typedefs.h:40
KSDDKAPI VOID NTAPI KsFilterAttemptProcessing(IN PKSFILTER Filter, IN BOOLEAN Asynchronous)
Definition: filter.c:1915
PFILE_OBJECT NTAPI KsPinGetConnectedPinFileObject(IN PKSPIN Pin)
Definition: pin.c:1047
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
return STATUS_SUCCESS
Definition: btrfs.c:2938
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4751
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68