ULONG PinDescriptorCount;
PKSFILTERFACTORY Factory;
PFILE_OBJECT FileObject;
+ KMUTEX ProcessingMutex;
+ PFNKSFILTERPOWER Sleep;
+ PFNKSFILTERPOWER Wake;
+
ULONG *PinInstanceCount;
}IKsFilterImpl;
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);
}
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
VOID
KsFilterAcquireProcessingMutex(
IN PKSFILTER Filter)
{
- UNIMPLEMENTED
+ IKsFilterImpl * This = (IKsFilterImpl*)CONTAINING_RECORD(Filter, IKsFilterImpl, Filter);
+
+ KeWaitForSingleObject(&This->ProcessingMutex, Executive, KernelMode, FALSE, NULL);
}
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
VOID
KsFilterReleaseProcessingMutex(
IN PKSFILTER Filter)
{
- UNIMPLEMENTED
+ IKsFilterImpl * This = (IKsFilterImpl*)CONTAINING_RECORD(Filter, IKsFilterImpl, Filter);
+
+ KeReleaseMutex(&This->ProcessingMutex, FALSE);
}
/*
}
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
ULONG
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];
}
/*
}
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
VOID
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
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;
+ }
+}