Author: janderwald
Date: Tue Jul 28 19:01:36 2009
New Revision: 42277
URL:
http://svn.reactos.org/svn/reactos?rev=42277&view=rev
Log:
- Implement KsFilterAcquireProcessingMutex, KsFilterReleaseProcessingMutex,
KsFilterGetChildPinCount, KsFilterRegisterPowerCallbacks, KsGetFilterFromIrp
Modified:
trunk/reactos/drivers/ksfilter/ks/filter.c
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 19:01:36 2009
@@ -25,7 +25,11 @@
ULONG PinDescriptorCount;
PKSFILTERFACTORY Factory;
PFILE_OBJECT FileObject;
-
+ KMUTEX ProcessingMutex;
+
+
+ PFNKSFILTERPOWER Sleep;
+ PFNKSFILTERPOWER Wake;
ULONG *PinInstanceCount;
}IKsFilterImpl;
@@ -882,6 +886,8 @@
This->Header.KsDevice = &DeviceExtension->DeviceHeader->KsDevice;
This->Header.Parent.KsFilterFactory = iface->lpVtbl->GetStruct(iface);
This->Header.Type = KsObjectTypeFilter;
+ KeInitializeMutex(&This->ProcessingMutex, 0);
+
/* allocate the stream descriptors */
Status = IKsFilter_CreateDescriptors(This,
(PKSFILTER_DESCRIPTOR)Factory->FilterDescriptor);
@@ -943,15 +949,46 @@
}
/*
+ @implemented
+*/
+KSDDKAPI
+VOID
+NTAPI
+KsFilterAcquireProcessingMutex(
+ IN PKSFILTER Filter)
+{
+ IKsFilterImpl * This = (IKsFilterImpl*)CONTAINING_RECORD(Filter, IKsFilterImpl,
Filter);
+
+ KeWaitForSingleObject(&This->ProcessingMutex, Executive, KernelMode, FALSE,
NULL);
+}
+
+/*
+ @implemented
+*/
+KSDDKAPI
+VOID
+NTAPI
+KsFilterReleaseProcessingMutex(
+ IN PKSFILTER Filter)
+{
+ IKsFilterImpl * This = (IKsFilterImpl*)CONTAINING_RECORD(Filter, IKsFilterImpl,
Filter);
+
+ KeReleaseMutex(&This->ProcessingMutex, FALSE);
+}
+
+/*
@unimplemented
*/
KSDDKAPI
-VOID
-NTAPI
-KsFilterAcquireProcessingMutex(
- IN PKSFILTER Filter)
-{
- UNIMPLEMENTED
+NTSTATUS
+NTAPI
+KsFilterAddTopologyConnections (
+ IN PKSFILTER Filter,
+ IN ULONG NewConnectionsCount,
+ IN const KSTOPOLOGY_CONNECTION *const NewTopologyConnections)
+{
+ UNIMPLEMENTED
+ return STATUS_NOT_IMPLEMENTED;
}
/*
@@ -960,33 +997,6 @@
KSDDKAPI
VOID
NTAPI
-KsFilterReleaseProcessingMutex(
- IN PKSFILTER Filter)
-{
- UNIMPLEMENTED
-}
-
-/*
- @unimplemented
-*/
-KSDDKAPI
-NTSTATUS
-NTAPI
-KsFilterAddTopologyConnections (
- IN PKSFILTER Filter,
- IN ULONG NewConnectionsCount,
- IN const KSTOPOLOGY_CONNECTION *const NewTopologyConnections)
-{
- UNIMPLEMENTED
- return STATUS_NOT_IMPLEMENTED;
-}
-
-/*
- @unimplemented
-*/
-KSDDKAPI
-VOID
-NTAPI
KsFilterAttemptProcessing(
IN PKSFILTER Filter,
IN BOOLEAN Asynchronous)
@@ -1038,7 +1048,7 @@
}
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
ULONG
@@ -1047,8 +1057,15 @@
IN PKSFILTER Filter,
IN ULONG PinId)
{
- UNIMPLEMENTED
- return 0;
+ IKsFilterImpl * This = (IKsFilterImpl*)CONTAINING_RECORD(Filter, IKsFilterImpl,
Filter);
+
+ if (PinId >= This->PinDescriptorCount)
+ {
+ /* index is out of bounds */
+ return 0;
+ }
+ /* return pin instance count */
+ return This->PinInstanceCount[PinId];
}
/*
@@ -1066,7 +1083,7 @@
}
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
VOID
@@ -1076,11 +1093,14 @@
IN PFNKSFILTERPOWER Sleep OPTIONAL,
IN PFNKSFILTERPOWER Wake OPTIONAL)
{
- UNIMPLEMENTED
+ IKsFilterImpl * This = (IKsFilterImpl*)CONTAINING_RECORD(Filter, IKsFilterImpl,
Filter);
+
+ This->Sleep = Sleep;
+ This->Wake = Wake;
}
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
PKSFILTER
@@ -1088,7 +1108,31 @@
KsGetFilterFromIrp(
IN PIRP Irp)
{
- UNIMPLEMENTED
- return NULL;
-}
-
+ PIO_STACK_LOCATION IoStack;
+ PKSIOBJECT_HEADER ObjectHeader;
+
+ /* get current irp stack location */
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ /* sanity check */
+ ASSERT(IoStack->FileObject);
+
+ /* get object header */
+ ObjectHeader = (PKSIOBJECT_HEADER)IoStack->FileObject->FsContext;
+
+ if (ObjectHeader->Type == KsObjectTypeFilter)
+ {
+ /* irp is targeted at the filter */
+ return (PKSFILTER)ObjectHeader->ObjectType;
+ }
+ else if (ObjectHeader->Type == KsObjectTypePin)
+ {
+ /* irp is for a pin */
+ return KsPinGetParentFilter((PKSPIN)ObjectHeader->ObjectType);
+ }
+ else
+ {
+ /* irp is unappropiate to retrieve a filter */
+ return NULL;
+ }
+}