- Check that all pins have been closed when the last filter reference is gone
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Mon, 24 Aug 2009 13:00:14 +0000 (13:00 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Mon, 24 Aug 2009 13:00:14 +0000 (13:00 +0000)
- Fix freeing of stream data (hacked atm)
- Implement retrieving of all property items for PinWaveCyclic

svn path=/trunk/; revision=42913

reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c
reactos/drivers/wdm/audio/backpln/portcls/guids.c
reactos/drivers/wdm/audio/backpln/portcls/irpstream.c
reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c
reactos/drivers/wdm/audio/backpln/portcls/propertyhandler.c

index 9cdad8e..b1f051e 100644 (file)
@@ -235,16 +235,16 @@ IPortFilterWaveCyclic_fnClose(
     NTSTATUS Status = STATUS_SUCCESS;
     IPortFilterWaveCyclicImpl * This = (IPortFilterWaveCyclicImpl *)iface;
 
     NTSTATUS Status = STATUS_SUCCESS;
     IPortFilterWaveCyclicImpl * This = (IPortFilterWaveCyclicImpl *)iface;
 
-    for(Index = 0; Index < This->Descriptor->Factory.PinDescriptorCount; Index++)
-    {
-        /* all pins should have been closed by now */
-        ASSERT(This->Pins[Index] == NULL);
-    }
-
     DPRINT("IPortFilterWaveCyclic_fnClose ref %u\n", This->ref);
 
     if (This->ref == 1)
     {
     DPRINT("IPortFilterWaveCyclic_fnClose ref %u\n", This->ref);
 
     if (This->ref == 1)
     {
+        for(Index = 0; Index < This->Descriptor->Factory.PinDescriptorCount; Index++)
+        {
+            /* all pins should have been closed by now */
+            ASSERT(This->Pins[Index] == NULL);
+        }
+
         /* release reference to port */
         This->SubDevice->lpVtbl->Release(This->SubDevice);
 
         /* release reference to port */
         This->SubDevice->lpVtbl->Release(This->SubDevice);
 
index b0f2a34..b805c2d 100644 (file)
@@ -73,6 +73,7 @@ const GUID KSDATAFORMAT_SPECIFIER_WAVEFORMATEX = {0x05589f81L, 0xc356, 0x11ce, {
 const GUID KSPROPSETID_Topology                = {0x720D4AC0L, 0x7533, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
 const GUID KSPROPSETID_Pin                     = {0x8C134960L, 0x51AD, 0x11CF, {0x87, 0x8A, 0x94, 0xF8, 0x01, 0xC1, 0x00, 0x00}};
 const GUID KSPROPSETID_Connection              = {0x1D58C920L, 0xAC9B, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
 const GUID KSPROPSETID_Topology                = {0x720D4AC0L, 0x7533, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
 const GUID KSPROPSETID_Pin                     = {0x8C134960L, 0x51AD, 0x11CF, {0x87, 0x8A, 0x94, 0xF8, 0x01, 0xC1, 0x00, 0x00}};
 const GUID KSPROPSETID_Connection              = {0x1D58C920L, 0xAC9B, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
+const GUID KSPROPTYPESETID_General             = {0x97E99BA0L, 0xBDEA, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
 
 const GUID IID_IAllocatorMXF                   = {0xa5f0d62cL, 0xb30f, 0x11d2, {0xb7, 0xa3, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1}};
 
 
 const GUID IID_IAllocatorMXF                   = {0xa5f0d62cL, 0xb30f, 0x11d2, {0xb7, 0xa3, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1}};
 
index 4f15fb2..64047a6 100644 (file)
@@ -300,11 +300,12 @@ IIrpQueue_fnUpdateMapping(
          */
         This->Irp->IoStatus.Information = StreamHeader->FrameExtent;
 
          */
         This->Irp->IoStatus.Information = StreamHeader->FrameExtent;
 
-        /* free stream data, no tag as wdmaud.drv does it atm */
-        //ExFreePool(StreamHeader->Data);
-
-        /* free stream header, no tag as wdmaud.drv allocates it atm */
-        //ExFreePool(StreamHeader);
+        if (This->Irp->RequestorMode != KernelMode)
+        {
+            /* HACK - WDMAUD should pass PKSSTREAM_HEADERs */
+            ExFreePool(StreamHeader->Data);
+            ExFreePool(StreamHeader);
+        }
 
         /* complete the request */
         IoCompleteRequest(This->Irp, IO_SOUND_INCREMENT);
 
         /* complete the request */
         IoCompleteRequest(This->Irp, IO_SOUND_INCREMENT);
index fcb2879..69b480e 100644 (file)
@@ -464,6 +464,34 @@ IPortPinWaveCyclic_HandleKsProperty(
 
     Property = (PKSPROPERTY)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
 
 
     Property = (PKSPROPERTY)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
 
+    if (IsEqualGUIDAligned(&Property->Set, &GUID_NULL))
+    {
+        if (Property->Flags & KSPROPERTY_TYPE_SETSUPPORT)
+        {
+            if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(GUID))
+            {
+                /* buffer too small */
+                Irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW;
+                Irp->IoStatus.Information = sizeof(GUID);
+                IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+                return STATUS_BUFFER_OVERFLOW;
+            }
+            /* FIXME copy guids 
+             *   KSPROPSETID_Audio when available
+             *   KSPROPSETID_Sysaudio_Pin
+             */
+            RtlMoveMemory(Irp->UserBuffer, &KSPROPSETID_Connection, sizeof(GUID));
+
+            Irp->IoStatus.Status = STATUS_SUCCESS;
+            Irp->IoStatus.Information = sizeof(GUID);
+            IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+            return STATUS_SUCCESS;
+        }
+    }
+
+
     if (IsEqualGUIDAligned(&Property->Set, &KSPROPSETID_Connection))
     {
         if (Property->Id == KSPROPERTY_CONNECTION_STATE)
     if (IsEqualGUIDAligned(&Property->Set, &KSPROPSETID_Connection))
     {
         if (Property->Id == KSPROPERTY_CONNECTION_STATE)
@@ -1041,6 +1069,7 @@ IPortPinWaveCyclic_fnInit(
         KeBugCheck(0);
     }
 
         KeBugCheck(0);
     }
 
+
     Status = This->Miniport->lpVtbl->NewStream(This->Miniport,
                                                &This->Stream,
                                                NULL,
     Status = This->Miniport->lpVtbl->NewStream(This->Miniport,
                                                &This->Stream,
                                                NULL,
index 9131ade..5305196 100644 (file)
@@ -15,6 +15,7 @@ FindPropertyHandler(
     IN PKSPROPERTY Property,
     IN ULONG InputBufferLength,
     IN ULONG OutputBufferLength,
     IN PKSPROPERTY Property,
     IN ULONG InputBufferLength,
     IN ULONG OutputBufferLength,
+    OUT PVOID OutputBuffer,
     OUT PFNKSHANDLER *PropertyHandler);
 
 NTSTATUS
     OUT PFNKSHANDLER *PropertyHandler);
 
 NTSTATUS
@@ -237,7 +238,7 @@ FastPropertyHandler(
     }
 
     /* property handler is used to verify input parameters */
     }
 
     /* property handler is used to verify input parameters */
-    Status = FindPropertyHandler(IoStatus, Descriptor, Property, PropertyLength, DataLength, &PropertyHandler);
+    Status = FindPropertyHandler(IoStatus, Descriptor, Property, PropertyLength, DataLength, Data, &PropertyHandler);
     if (!NT_SUCCESS(Status))
     {
         DPRINT("FindPropertyHandler failed with %x\n", Status);
     if (!NT_SUCCESS(Status))
     {
         DPRINT("FindPropertyHandler failed with %x\n", Status);
@@ -368,9 +369,12 @@ FindPropertyHandler(
     IN PKSPROPERTY Property,
     IN ULONG InputBufferLength,
     IN ULONG OutputBufferLength,
     IN PKSPROPERTY Property,
     IN ULONG InputBufferLength,
     IN ULONG OutputBufferLength,
+    OUT PVOID OutputBuffer,
     OUT PFNKSHANDLER *PropertyHandler)
 {
     ULONG Index, ItemIndex;
     OUT PFNKSHANDLER *PropertyHandler)
 {
     ULONG Index, ItemIndex;
+    PULONG Flags;
+    PKSPROPERTY_DESCRIPTION Description;
 
     for(Index = 0; Index < Descriptor->FilterPropertySet.FreeKsPropertySetOffset; Index++)
     {
 
     for(Index = 0; Index < Descriptor->FilterPropertySet.FreeKsPropertySetOffset; Index++)
     {
@@ -386,6 +390,48 @@ FindPropertyHandler(
                     if (Property->Flags & KSPROPERTY_TYPE_GET)
                         *PropertyHandler = Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].GetPropertyHandler;
 
                     if (Property->Flags & KSPROPERTY_TYPE_GET)
                         *PropertyHandler = Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].GetPropertyHandler;
 
+                    if (Property->Flags & KSPROPERTY_TYPE_BASICSUPPORT)
+                    {
+                        if (sizeof(ULONG) > OutputBufferLength)
+                        {
+                            /* too small buffer */
+                            return STATUS_INVALID_PARAMETER;
+                        }
+
+                        /* get output buffer */
+                        Flags = (PULONG)OutputBuffer;
+
+                        /* clear flags */
+                        *Flags = KSPROPERTY_TYPE_BASICSUPPORT;
+
+                        if (Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].GetSupported)
+                            *Flags |= KSPROPERTY_TYPE_GET;
+
+                        if (Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].SetSupported)
+                            *Flags |= KSPROPERTY_TYPE_SET;
+
+                        IoStatus->Information = sizeof(ULONG);
+
+                        if (OutputBufferLength >= sizeof(KSPROPERTY_DESCRIPTION))
+                        {
+                            /* get output buffer */
+                            Description = (PKSPROPERTY_DESCRIPTION)OutputBuffer;
+
+                            /* store result */
+                            Description->DescriptionSize = sizeof(KSPROPERTY_DESCRIPTION);
+                            Description->PropTypeSet.Set = KSPROPTYPESETID_General;
+                            Description->PropTypeSet.Id = 0;
+                            Description->PropTypeSet.Flags = 0;
+                            Description->MembersListCount = 0;
+                            Description->Reserved = 0;
+
+                            IoStatus->Information = sizeof(KSPROPERTY_DESCRIPTION);
+                        }
+
+                        return STATUS_SUCCESS;
+                    }
+
+
                     if (Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].MinProperty > InputBufferLength)
                     {
                         /* too small input buffer */
                     if (Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].MinProperty > InputBufferLength)
                     {
                         /* too small input buffer */
@@ -536,14 +582,14 @@ PcPropertyHandler(
         }
     }
 
         }
     }
 
-    Status = FindPropertyHandler(&Irp->IoStatus, Descriptor, Property, IoStack->Parameters.DeviceIoControl.InputBufferLength, IoStack->Parameters.DeviceIoControl.OutputBufferLength, &PropertyHandler);
-    if (PropertyHandler)
+    Status = FindPropertyHandler(&Irp->IoStatus, Descriptor, Property, IoStack->Parameters.DeviceIoControl.InputBufferLength, IoStack->Parameters.DeviceIoControl.OutputBufferLength, Irp->UserBuffer, &PropertyHandler);
+    if (NT_SUCCESS(Status) && PropertyHandler)
     {
         KSPROPERTY_ITEM_IRP_STORAGE(Irp) = (PVOID)Descriptor;
         DPRINT("Calling property handler %p\n", PropertyHandler);
         Status = PropertyHandler(Irp, Property, Irp->UserBuffer);
     }
     {
         KSPROPERTY_ITEM_IRP_STORAGE(Irp) = (PVOID)Descriptor;
         DPRINT("Calling property handler %p\n", PropertyHandler);
         Status = PropertyHandler(Irp, Property, Irp->UserBuffer);
     }
-    else
+    else if (!NT_SUCCESS(Status))
     {
         RtlStringFromGUID(&Property->Set, &GuidString);
         DPRINT1("Unhandeled property: Set %S Id %u Flags %x InputLength %u OutputLength %u\n", GuidString.Buffer, Property->Id, Property->Flags, IoStack->Parameters.DeviceIoControl.InputBufferLength, IoStack->Parameters.DeviceIoControl.OutputBufferLength);
     {
         RtlStringFromGUID(&Property->Set, &GuidString);
         DPRINT1("Unhandeled property: Set %S Id %u Flags %x InputLength %u OutputLength %u\n", GuidString.Buffer, Property->Id, Property->Flags, IoStack->Parameters.DeviceIoControl.InputBufferLength, IoStack->Parameters.DeviceIoControl.OutputBufferLength);