Author: janderwald
Date: Mon Aug 10 13:28:25 2009
New Revision: 42588
URL:
http://svn.reactos.org/svn/reactos?rev=42588&view=rev
Log:
- Add BDA filter context to object bag, so that it gets freed automatically later
Modified:
trunk/reactos/drivers/multimedia/bdasup/bdasup.c
Modified: trunk/reactos/drivers/multimedia/bdasup/bdasup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/multimedia/bdasup/…
==============================================================================
--- trunk/reactos/drivers/multimedia/bdasup/bdasup.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/multimedia/bdasup/bdasup.c [iso-8859-1] Mon Aug 10 13:28:25
2009
@@ -105,6 +105,43 @@
{
return BdaCreateFilterFactoryEx(pKSDevice, pFilterDescriptor, pBdaFilterTemplate,
NULL);
}
+
+VOID
+NTAPI
+FreeFilterInstance(
+ IN PVOID Context)
+{
+ PBDA_FILTER_INSTANCE_ENTRY InstanceEntry = NULL;
+ PLIST_ENTRY Entry;
+ KIRQL OldLevel;
+
+ /* acquire list lock */
+ KeAcquireSpinLock(&g_Settings.FilterFactoryInstanceListLock, &OldLevel);
+
+ /* point to first entry */
+ Entry = g_Settings.FilterFactoryInstanceList.Flink;
+
+ while(Entry != &g_Settings.FilterFactoryInstanceList)
+ {
+ /* get instance entry from list entry offset */
+ InstanceEntry = (PBDA_FILTER_INSTANCE_ENTRY)CONTAINING_RECORD(Entry,
BDA_FILTER_INSTANCE_ENTRY, Entry);
+
+ /* is the instance entry the requested one */
+ if (InstanceEntry == (PBDA_FILTER_INSTANCE_ENTRY)Context)
+ {
+ RemoveEntryList(&InstanceEntry->Entry);
+ FreeItem(InstanceEntry);
+ break;
+ }
+
+ /* move to next entry */
+ Entry = Entry->Flink;
+ }
+
+ /* release spin lock */
+ KeReleaseSpinLock(&g_Settings.FilterFactoryInstanceListLock, OldLevel);
+}
+
/*
@implemented
@@ -141,6 +178,16 @@
if (NT_SUCCESS(Status))
{
+ /* add the item to filter object bag */
+ Status = KsAddItemToObjectBag(FilterFactory->Bag, FilterInstance,
FreeFilterInstance);
+ if (!NT_SUCCESS(Status))
+ {
+ /* destroy filter instance */
+ FreeItem(FilterInstance);
+ KsDeleteFilterFactory(FilterFactory);
+ return Status;
+ }
+
/* initialize filter instance entry */
FilterInstance->FilterFactoryInstance = FilterFactory;
FilterInstance->FilterTemplate = (BDA_FILTER_TEMPLATE *)BdaFilterTemplate;
@@ -153,6 +200,7 @@
/* release spin lock */
KeReleaseSpinLock(&g_Settings.FilterFactoryInstanceListLock, OldLevel);
+
if (ppKSFilterFactory)
{