Author: janderwald
Date: Thu Apr 1 04:35:37 2010
New Revision: 46632
URL:
http://svn.reactos.org/svn/reactos?rev=46632&view=rev
Log:
[BDASUP]
- Allocate KSFILTER_DESCRIPTOR before passing to KsCreateFilterFactory
- Allocate KSPIN_DESCRIPTOR_EX before passing to KsFilterCreatePinFactory
- Use stored BDA_FILTER_TEMPLATE when caller doesnt pass any
Modified:
trunk/reactos/drivers/multimedia/bdasup/bdasup.c
trunk/reactos/drivers/multimedia/bdasup/precomp.h
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] Thu Apr 1 04:35:37
2010
@@ -261,19 +261,28 @@
PBDA_FILTER_INSTANCE_ENTRY FilterInstance;
KIRQL OldLevel;
NTSTATUS Status;
- KSFILTER_DESCRIPTOR FilterDescriptor;
+ PKSFILTER_DESCRIPTOR FilterDescriptor;
DPRINT("BdaCreateFilterFactoryEx\n");
- /* backup filter descriptor */
- RtlMoveMemory(&FilterDescriptor, pFilterDescriptor,
sizeof(KSFILTER_DESCRIPTOR));
+
+ FilterDescriptor = AllocateItem(NonPagedPool, sizeof(KSFILTER_DESCRIPTOR));
+ if (!FilterDescriptor)
+ {
+ /* no memory */
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* copy filter descriptor template */
+ RtlMoveMemory(FilterDescriptor, pFilterDescriptor, sizeof(KSFILTER_DESCRIPTOR));
/* merge the automation tables */
- Status =
KsMergeAutomationTables((PKSAUTOMATION_TABLE*)&FilterDescriptor.AutomationTable,
(PKSAUTOMATION_TABLE)pFilterDescriptor->AutomationTable, &FilterAutomationTable,
NULL);
+ Status =
KsMergeAutomationTables((PKSAUTOMATION_TABLE*)&FilterDescriptor->AutomationTable,
(PKSAUTOMATION_TABLE)pFilterDescriptor->AutomationTable, &FilterAutomationTable,
NULL);
/* check for success */
if (!NT_SUCCESS(Status))
{
DPRINT1("KsMergeAutomationTables failed with %lx\n", Status);
+ FreeItem(FilterDescriptor);
return Status;
}
@@ -282,11 +291,12 @@
if (!FilterInstance)
{
/* not enough memory */
+ FreeItem(FilterDescriptor);
return STATUS_INSUFFICIENT_RESOURCES;
}
/* create the filter factory */
- Status = KsCreateFilterFactory(pKSDevice->FunctionalDeviceObject,
&FilterDescriptor, NULL, NULL, 0, NULL, NULL, &FilterFactory);
+ Status = KsCreateFilterFactory(pKSDevice->FunctionalDeviceObject,
FilterDescriptor, NULL, NULL, 0, NULL, NULL, &FilterFactory);
/* check for success */
if (NT_SUCCESS(Status))
@@ -298,6 +308,7 @@
{
/* destroy filter instance */
DPRINT1("KsAddItemToObjectBag failed with %lx\n", Status);
+ FreeItem(FilterDescriptor);
FreeItem(FilterInstance);
KsDeleteFilterFactory(FilterFactory);
return Status;
@@ -350,7 +361,7 @@
PBDA_FILTER_INSTANCE_ENTRY InstanceEntry;
NTSTATUS Status;
ULONG PinId;
- KSPIN_DESCRIPTOR_EX NewPinDescriptor;
+ PKSPIN_DESCRIPTOR_EX NewPinDescriptor;
DPRINT("BdaCreatePin\n");
@@ -380,6 +391,7 @@
if (!InstanceEntry->FilterTemplate->pFilterDescriptor->PinDescriptorsCount)
{
/* no pins supported */
+ DPRINT("BdaCreatePin NoPins supported\n");
return STATUS_UNSUCCESSFUL;
}
@@ -387,6 +399,7 @@
if (InstanceEntry->FilterTemplate->pFilterDescriptor->PinDescriptorsCount
<= ulPinType)
{
/* pin request is out of bounds */
+ DPRINT("BdaCreatePin ulPinType %lu >= PinDescriptorCount %lu\n",
ulPinType,
InstanceEntry->FilterTemplate->pFilterDescriptor->PinDescriptorsCount);
return STATUS_INVALID_PARAMETER;
}
@@ -396,17 +409,26 @@
/* get pin descriptor */
PinDescriptor =
(PKSPIN_DESCRIPTOR_EX)&InstanceEntry->FilterTemplate->pFilterDescriptor->PinDescriptors[ulPinType];
+ /* allocate pin descriptor */
+ NewPinDescriptor = AllocateItem(NonPagedPool, sizeof(KSPIN_DESCRIPTOR_EX));
+ if (!NewPinDescriptor)
+ {
+ /* no memory */
+ DPRINT("BdaCreatePin OutOfMemory\n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
/* make a copy of the pin descriptor */
- RtlMoveMemory(&NewPinDescriptor, PinDescriptor, sizeof(KSPIN_DESCRIPTOR_EX));
+ RtlMoveMemory(NewPinDescriptor, PinDescriptor, sizeof(KSPIN_DESCRIPTOR_EX));
/* merge the automation tables */
- Status =
KsMergeAutomationTables((PKSAUTOMATION_TABLE*)&NewPinDescriptor.AutomationTable,
(PKSAUTOMATION_TABLE)PinDescriptor->AutomationTable, &PinAutomationTable,
pKSFilter->Bag);
+ Status =
KsMergeAutomationTables((PKSAUTOMATION_TABLE*)&NewPinDescriptor->AutomationTable,
(PKSAUTOMATION_TABLE)PinDescriptor->AutomationTable, &PinAutomationTable,
pKSFilter->Bag);
/* check for success */
if (NT_SUCCESS(Status))
{
/* create the pin factory */
- Status = KsFilterCreatePinFactory(pKSFilter, &NewPinDescriptor, &PinId);
+ Status = KsFilterCreatePinFactory(pKSFilter, NewPinDescriptor, &PinId);
/* check for success */
if (NT_SUCCESS(Status))
@@ -417,7 +439,7 @@
}
- DPRINT("BdaCreatePin Result %x\n", Status);
+ DPRINT("BdaCreatePin Result %x PinId %u\n", Status, PinId);
return Status;
}
@@ -470,7 +492,7 @@
ULONG Index, PinId;
NTSTATUS Status = STATUS_SUCCESS;
- DPRINT("BdaInitFilter\n");
+ DPRINT("BdaInitFilter %p\n", pBdaFilterTemplate);
/* check input parameters */
if (!pKSFilter)
@@ -487,7 +509,12 @@
/* sanity check */
ASSERT(InstanceEntry);
- ASSERT(InstanceEntry->FilterTemplate == pBdaFilterTemplate);
+
+ if (!pBdaFilterTemplate)
+ {
+ /* use template from BdaCreateFilterFactoryEx */
+ pBdaFilterTemplate = InstanceEntry->FilterTemplate;
+ }
/* now create the pins */
for(Index = 0; Index <
pBdaFilterTemplate->pFilterDescriptor->PinDescriptorsCount; Index++)
Modified: trunk/reactos/drivers/multimedia/bdasup/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/multimedia/bdasup/…
==============================================================================
--- trunk/reactos/drivers/multimedia/bdasup/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/multimedia/bdasup/precomp.h [iso-8859-1] Thu Apr 1 04:35:37
2010
@@ -7,7 +7,7 @@
#include <bdamedia.h>
#include <bdasup.h>
-#define NDEBUG
+#define YDEBUG
#include <debug.h>