From 7776fec6cec0069d909775d05b231e96feb68a7e Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 24 Aug 2009 13:00:14 +0000 Subject: [PATCH] - Check that all pins have been closed when the last filter reference is gone - Fix freeing of stream data (hacked atm) - Implement retrieving of all property items for PinWaveCyclic svn path=/trunk/; revision=42913 --- .../audio/backpln/portcls/filter_wavecyclic.c | 12 ++--- .../drivers/wdm/audio/backpln/portcls/guids.c | 1 + .../wdm/audio/backpln/portcls/irpstream.c | 11 ++-- .../audio/backpln/portcls/pin_wavecyclic.c | 29 ++++++++++ .../audio/backpln/portcls/propertyhandler.c | 54 +++++++++++++++++-- 5 files changed, 92 insertions(+), 15 deletions(-) diff --git a/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c b/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c index 9cdad8ef04f..b1f051e855b 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c @@ -235,16 +235,16 @@ IPortFilterWaveCyclic_fnClose( 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) { + 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); diff --git a/reactos/drivers/wdm/audio/backpln/portcls/guids.c b/reactos/drivers/wdm/audio/backpln/portcls/guids.c index b0f2a34d041..b805c2d2320 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/guids.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/guids.c @@ -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 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}}; diff --git a/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c b/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c index 4f15fb2cdab..64047a642de 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c @@ -300,11 +300,12 @@ IIrpQueue_fnUpdateMapping( */ 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); diff --git a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c index fcb28790ea7..69b480e9636 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c @@ -464,6 +464,34 @@ IPortPinWaveCyclic_HandleKsProperty( 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) @@ -1041,6 +1069,7 @@ IPortPinWaveCyclic_fnInit( KeBugCheck(0); } + Status = This->Miniport->lpVtbl->NewStream(This->Miniport, &This->Stream, NULL, diff --git a/reactos/drivers/wdm/audio/backpln/portcls/propertyhandler.c b/reactos/drivers/wdm/audio/backpln/portcls/propertyhandler.c index 9131ade6b1b..53051965b8c 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/propertyhandler.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/propertyhandler.c @@ -15,6 +15,7 @@ FindPropertyHandler( IN PKSPROPERTY Property, IN ULONG InputBufferLength, IN ULONG OutputBufferLength, + OUT PVOID OutputBuffer, OUT PFNKSHANDLER *PropertyHandler); NTSTATUS @@ -237,7 +238,7 @@ FastPropertyHandler( } /* 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); @@ -368,9 +369,12 @@ FindPropertyHandler( IN PKSPROPERTY Property, IN ULONG InputBufferLength, IN ULONG OutputBufferLength, + OUT PVOID OutputBuffer, OUT PFNKSHANDLER *PropertyHandler) { ULONG Index, ItemIndex; + PULONG Flags; + PKSPROPERTY_DESCRIPTION Description; 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_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 */ @@ -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); } - 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);