Author: janderwald
Date: Tue Jul 28 21:32:22 2009
New Revision: 42279
URL:
http://svn.reactos.org/svn/reactos?rev=42279&view=rev
Log:
- Implement KsAcquireControl, KsReleaseControl
- Add create item for creation of pins and topology nodes
- Implement pin creation handler
Modified:
trunk/reactos/drivers/ksfilter/ks/api.c
trunk/reactos/drivers/ksfilter/ks/device.c
trunk/reactos/drivers/ksfilter/ks/filter.c
trunk/reactos/drivers/ksfilter/ks/filterfactory.c
trunk/reactos/drivers/ksfilter/ks/ksfunc.h
trunk/reactos/drivers/ksfilter/ks/kstypes.h
trunk/reactos/drivers/ksfilter/ks/pin.c
Modified: trunk/reactos/drivers/ksfilter/ks/api.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/api.c?…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/api.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/api.c [iso-8859-1] Tue Jul 28 21:32:22 2009
@@ -1449,7 +1449,7 @@
}
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
VOID
@@ -1457,8 +1457,32 @@
KsAcquireControl(
IN PVOID Object)
{
- UNIMPLEMENTED
-}
+ PKSBASIC_HEADER BasicHeader = (PKSBASIC_HEADER)((ULONG_PTR)Object -
sizeof(KSBASIC_HEADER));
+
+ /* sanity check */
+ ASSERT(BasicHeader->Type == KsObjectTypeFilter || BasicHeader->Type ==
KsObjectTypePin);
+
+ KeWaitForSingleObject(&BasicHeader->ControlMutex, Executive, KernelMode,
FALSE, NULL);
+
+}
+
+/*
+ @implemented
+*/
+VOID
+NTAPI
+KsReleaseControl(
+ IN PVOID Object)
+{
+ PKSBASIC_HEADER BasicHeader = (PKSBASIC_HEADER)((ULONG_PTR)Object -
sizeof(KSBASIC_HEADER));
+
+ /* sanity check */
+ ASSERT(BasicHeader->Type == KsObjectTypeFilter || BasicHeader->Type ==
KsObjectTypePin);
+
+ KeReleaseMutex(&BasicHeader->ControlMutex, FALSE);
+}
+
+
/*
@implemented
@@ -1796,17 +1820,6 @@
/*
@unimplemented
*/
-VOID
-NTAPI
-KsReleaseControl(
- IN PVOID Object)
-{
- UNIMPLEMENTED
-}
-
-/*
- @unimplemented
-*/
NTSTATUS
NTAPI
KsRegisterFilterWithNoKSPins(
Modified: trunk/reactos/drivers/ksfilter/ks/device.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/device…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/device.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/device.c [iso-8859-1] Tue Jul 28 21:32:22 2009
@@ -683,7 +683,6 @@
Header->KsDevice.Descriptor = Descriptor;
KsSetDevicePnpAndBaseObject(Header, PhysicalDeviceObject, NextDeviceObject);
-
/* FIXME Power state */
if (Descriptor)
Modified: trunk/reactos/drivers/ksfilter/ks/filter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/filter…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/filter.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/filter.c [iso-8859-1] Tue Jul 28 21:32:22 2009
@@ -899,6 +899,60 @@
return STATUS_SUCCESS;
}
+NTSTATUS
+NTAPI
+IKsFilter_DispatchCreatePin(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ IKsFilterImpl * This;
+ PKSOBJECT_CREATE_ITEM CreateItem;
+ PKSPIN_CONNECT Connect;
+ NTSTATUS Status;
+
+ /* get the create item */
+ CreateItem = KSCREATE_ITEM_IRP_STORAGE(Irp);
+
+ /* get the filter object */
+ This = (IKsFilterImpl*)CreateItem->Context;
+
+ /* acquire control mutex */
+ KeWaitForSingleObject(&This->Header.ControlMutex, Executive, KernelMode,
FALSE, NULL);
+
+ /* now validate the connect request */
+ Status = KsValidateConnectRequest(Irp, This->PinDescriptorCount,
This->PinDescriptors, &Connect);
+
+ if (NT_SUCCESS(Status))
+ {
+ /* create the pin */
+ Status = KspCreatePin(DeviceObject, Irp, This->Header.KsDevice,
This->FilterFactory, (IKsFilter*)&This->lpVtbl, Connect);
+ }
+
+ /* release control mutex */
+ KeReleaseMutex(&This->Header.ControlMutex, FALSE);
+
+ if (Status != STATUS_PENDING)
+ {
+ /* complete request */
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ }
+ /* done */
+ return Status;
+}
+
+NTSTATUS
+NTAPI
+IKsFilter_DispatchCreateNode(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ UNIMPLEMENTED
+ Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_UNSUCCESSFUL;
+}
+
NTSTATUS
NTAPI
@@ -913,6 +967,7 @@
PIO_STACK_LOCATION IoStack;
PDEVICE_EXTENSION DeviceExtension;
NTSTATUS Status;
+ PKSOBJECT_CREATE_ITEM CreateItem;
/* get device extension */
DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
@@ -943,7 +998,6 @@
/* get current irp stack */
IoStack = IoGetCurrentIrpStackLocation(Irp);
-
/* initialize object bag */
This->Filter.Bag = AllocateItem(NonPagedPool, sizeof(KSIOBJECT_BAG));
if (!This->Filter.Bag)
@@ -953,6 +1007,25 @@
return STATUS_INSUFFICIENT_RESOURCES;
}
+ /* allocate create items */
+ CreateItem = AllocateItem(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM) * 2);
+ if (!CreateItem)
+ {
+ /* no memory */
+ FreeItem(This);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* initialize pin create item */
+ CreateItem[0].Create = IKsFilter_DispatchCreatePin;
+ CreateItem[0].Context = (PVOID)This;
+ CreateItem[0].Flags = KSCREATE_ITEM_FREEONSTOP;
+ RtlInitUnicodeString(&CreateItem[0].ObjectClass, KSSTRING_Pin);
+ /* initialize node create item */
+ CreateItem[1].Create = IKsFilter_DispatchCreateNode;
+ CreateItem[1].Context = (PVOID)This;
+ CreateItem[1].Flags = KSCREATE_ITEM_FREEONSTOP;
+ RtlInitUnicodeString(&CreateItem[1].ObjectClass, KSSTRING_TopologyNode);
KsDevice = (IKsDevice*)&DeviceExtension->DeviceHeader->lpVtblIKsDevice;
@@ -970,6 +1043,7 @@
This->Header.KsDevice = &DeviceExtension->DeviceHeader->KsDevice;
This->Header.Parent.KsFilterFactory = iface->lpVtbl->GetStruct(iface);
This->Header.Type = KsObjectTypeFilter;
+ KeInitializeMutex(&This->Header.ControlMutex, 0);
KeInitializeMutex(&This->ProcessingMutex, 0);
@@ -979,6 +1053,7 @@
{
/* what can go wrong, goes wrong */
FreeItem(This);
+ FreeItem(CreateItem);
return Status;
}
@@ -989,7 +1064,7 @@
{
/* failed to add filter */
FreeItem(This);
-
+ FreeItem(CreateItem);
return Status;
}
@@ -1006,12 +1081,12 @@
/* free filter instance */
FreeItem(This);
-
+ FreeItem(CreateItem);
return Status;
}
/* now allocate the object header */
- Status = KsAllocateObjectHeader((PVOID*)&This->ObjectHeader, 0, NULL, Irp,
&DispatchTable);
+ Status = KsAllocateObjectHeader((PVOID*)&This->ObjectHeader, 2, CreateItem,
Irp, &DispatchTable);
if (!NT_SUCCESS(Status))
{
/* failed to allocate object header */
Modified: trunk/reactos/drivers/ksfilter/ks/filterfactory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/filter…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/filterfactory.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/filterfactory.c [iso-8859-1] Tue Jul 28 21:32:22
2009
@@ -192,6 +192,9 @@
InitializeListHead(&This->SymbolicLinkList);
InitializeListHead(&This->FilterInstanceList);
+ /* initialize filter factory control mutex */
+ KeInitializeMutex(&This->Header.ControlMutex, 0);
+
/* does the device use a reference string */
if (RefString || !Descriptor->ReferenceGuid)
{
Modified: trunk/reactos/drivers/ksfilter/ks/ksfunc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/ksfunc…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/ksfunc.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/ksfunc.h [iso-8859-1] Tue Jul 28 21:32:22 2009
@@ -114,4 +114,14 @@
IN OUT PULONG Size,
OUT PVOID * Result);
+NTSTATUS
+KspCreatePin(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ IN PKSDEVICE KsDevice,
+ IN IKsFilterFactory * FilterFactory,
+ IN IKsFilter* Filter,
+ IN PKSPIN_CONNECT Connect);
+
+
#endif
Modified: trunk/reactos/drivers/ksfilter/ks/kstypes.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/kstype…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/kstypes.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/kstypes.h [iso-8859-1] Tue Jul 28 21:32:22 2009
@@ -59,6 +59,7 @@
{
KSOBJECTTYPE Type;
PKSDEVICE KsDevice;
+ KMUTEX ControlMutex;
union
{
PKSDEVICE KsDevice;
Modified: trunk/reactos/drivers/ksfilter/ks/pin.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/pin.c?…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/pin.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/pin.c [iso-8859-1] Tue Jul 28 21:32:22 2009
@@ -519,3 +519,17 @@
UNIMPLEMENTED
return NULL;
}
+
+NTSTATUS
+KspCreatePin(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ IN PKSDEVICE KsDevice,
+ IN IKsFilterFactory * FilterFactory,
+ IN IKsFilter* Filter,
+ IN PKSPIN_CONNECT Connect)
+{
+
+ return STATUS_NOT_IMPLEMENTED;
+}
+