Author: janderwald
Date: Fri May 29 16:40:09 2009
New Revision: 41195
URL:
http://svn.reactos.org/svn/reactos?rev=41195&view=rev
Log:
- Use a reference name when registering audio subdevices (bug 4566)
- Release subdevice interface when it is no longer needed
- Fix a memory leak
- Audio support is on hold untill bug 4566 is resolved
Modified:
trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h
trunk/reactos/drivers/wdm/audio/backpln/portcls/irp.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/propertyhandler.c
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c [iso-8859-1] Fri May 29
16:40:09 2009
@@ -54,6 +54,7 @@
DriverObject->MajorFunction[IRP_MJ_PNP] = PcDispatchIrp;
DriverObject->MajorFunction[IRP_MJ_POWER] = PcDispatchIrp;
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = PcDispatchIrp;
+ DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = PcDispatchIrp;
/* The driver-supplied AddDevice */
DriverObject->DriverExtension->AddDevice = AddDevice;
@@ -181,6 +182,10 @@
status = STATUS_UNSUCCESSFUL;
goto cleanup;
}
+
+ /* register shutdown notification */
+ IoRegisterShutdownNotification(PhysicalDeviceObject);
+
return status;
cleanup:
@@ -223,6 +228,7 @@
UNICODE_STRING SymbolicLinkName;
SUBDEVICE_DESCRIPTOR * SubDeviceDescriptor;
ULONG Index;
+ UNICODE_STRING RefName;
DPRINT1("PcRegisterSubdevice DeviceObject %p Name %S Unknown %p\n",
DeviceObject, Name, Unknown);
ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
@@ -272,18 +278,17 @@
return Status;
}
- /* increment reference count */
- SubDevice->lpVtbl->AddRef(SubDevice);
+ /* initialize reference string */
+ RtlInitUnicodeString(&RefName, Name);
for(Index = 0; Index < SubDeviceDescriptor->InterfaceCount; Index++)
{
- //FIXME
- // Use a reference string such as Wave0001 / Topology0001
- //
-
+ /* FIXME
+ * check if reference string with that name already exists
+ */
Status = IoRegisterDeviceInterface(DeviceExt->PhysicalDeviceObject,
&SubDeviceDescriptor->Interfaces[Index],
- NULL,
+ &RefName,
&SymbolicLinkName);
if (NT_SUCCESS(Status))
{
@@ -292,5 +297,8 @@
}
}
+ /* Release SubDevice reference */
+ SubDevice->lpVtbl->Release(SubDevice);
+
return STATUS_SUCCESS;
}
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c [iso-8859-1]
(original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c [iso-8859-1] Fri
May 29 16:40:09 2009
@@ -236,16 +236,20 @@
IN PIRP Irp)
{
ULONG Index;
+ PMINIPORTWAVECYCLIC Miniport;
IPortFilterWaveCyclicImpl * This = (IPortFilterWaveCyclicImpl *)iface;
for(Index = 0; Index < This->Descriptor->Factory.PinDescriptorCount;
Index++)
{
- if (This->Pins[Index])
- {
- This->Pins[Index]->lpVtbl->Close(This->Pins[Index], DeviceObject,
NULL);
- }
-
- }
+ /* all pins should have been closed by now */
+ ASSERT(This->Pins[Index] == NULL);
+ }
+
+ /* release reference to port */
+ This->Port->lpVtbl->Release(This->Port);
+
+ Miniport = GetWaveCyclicMiniport(This->Port);
+ Miniport->lpVtbl->Release(Miniport);
Irp->IoStatus.Status = STATUS_SUCCESS;
@@ -386,6 +390,29 @@
Port->lpVtbl->AddRef(Port);
return STATUS_SUCCESS;
+}
+
+
+static
+NTSTATUS
+NTAPI
+IPortFilterWaveCyclic_fnFreePin(
+ IN IPortFilterWaveCyclic* iface,
+ IN struct IPortPinWaveCyclic* Pin)
+{
+ ULONG Index;
+ IPortFilterWaveCyclicImpl * This = (IPortFilterWaveCyclicImpl*)iface;
+
+ for(Index = 0; Index < This->Descriptor->Factory.PinDescriptorCount;
Index++)
+ {
+ if (This->Pins[Index] == Pin)
+ {
+ This->Pins[Index]->lpVtbl->Release(This->Pins[Index]);
+ This->Pins[Index] = NULL;
+ return STATUS_SUCCESS;
+ }
+ }
+ return STATUS_UNSUCCESSFUL;
}
static IPortFilterWaveCyclicVtbl vt_IPortFilterWaveCyclic =
@@ -404,7 +431,8 @@
IPortFilterWaveCyclic_fnFastDeviceIoControl,
IPortFilterWaveCyclic_fnFastRead,
IPortFilterWaveCyclic_fnFastWrite,
- IPortFilterWaveCyclic_fnInit
+ IPortFilterWaveCyclic_fnInit,
+ IPortFilterWaveCyclic_fnFreePin
};
NTSTATUS
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h [iso-8859-1] Fri May 29
16:40:09 2009
@@ -532,6 +532,8 @@
#undef INTERFACE
#define INTERFACE IPortFilterWaveCyclic
+struct IPortPinWaveCyclic;
+
DECLARE_INTERFACE_(IPortFilterWaveCyclic, IIrpTarget)
{
DEFINE_ABSTRACT_UNKNOWN()
@@ -540,6 +542,9 @@
STDMETHOD_(NTSTATUS, Init)(THIS_
IN PPORTWAVECYCLIC Port)PURE;
+
+ STDMETHOD_(NTSTATUS, FreePin)(THIS_
+ IN struct IPortPinWaveCyclic* Pin)PURE;
};
typedef IPortFilterWaveCyclic *PPORTFILTERWAVECYCLIC;
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/irp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/irp.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/irp.c [iso-8859-1] Fri May 29 16:40:09
2009
@@ -151,7 +151,7 @@
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_NOT_SUPPORTED;
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
- DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS Status %x Information
%p\n", Irp->IoStatus.Status, Irp->IoStatus.Information);
+ DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS Status %x Information %p
Information2 %p\n", Irp->IoStatus.Status, Irp->IoStatus.Information,
IoStack->Parameters.FilterResourceRequirements.IoResourceRequirementList);
Status = Irp->IoStatus.Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
@@ -210,6 +210,25 @@
return STATUS_SUCCESS;
}
+NTSTATUS
+NTAPI
+PortClsShutdown(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ DPRINT("PortClsShutdown called\n");
+ //DbgBreakPoint();
+
+ /* TODO */
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ return STATUS_SUCCESS;
+}
+
+
/*
==========================================================================
@@ -252,6 +271,9 @@
case IRP_MJ_SYSTEM_CONTROL :
return PortClsSysControl(DeviceObject, Irp);
+
+ case IRP_MJ_SHUTDOWN:
+ return PortClsShutdown(DeviceObject, Irp);
default:
DPRINT1("Unhandled function %x\n", IoStack->MajorFunction);
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c [iso-8859-1]
(original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c [iso-8859-1] Fri May
29 16:40:09 2009
@@ -732,6 +732,7 @@
{
Stream = This->Stream;
This->Stream = NULL;
+ This->Filter->lpVtbl->FreePin(This->Filter,
(IPortPinWaveCyclic*)This);
DPRINT1("Closing stream at Irql %u\n", KeGetCurrentIrql());
Stream->lpVtbl->Release(Stream);
/* this line is never reached */
@@ -1064,7 +1065,7 @@
//This->Stream->lpVtbl->SetFormat(This->Stream,
(PKSDATAFORMAT)This->Format);
DPRINT1("Setting state to acquire %x\n",
This->Stream->lpVtbl->SetState(This->Stream, KSSTATE_ACQUIRE));
- DPRINT1("Setting state to run %x\n",
This->Stream->lpVtbl->SetState(This->Stream, KSSTATE_PAUSE));
+ DPRINT1("Setting state to pause %x\n",
This->Stream->lpVtbl->SetState(This->Stream, KSSTATE_PAUSE));
This->State = KSSTATE_PAUSE;
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.c [iso-8859-1]
(original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.c [iso-8859-1] Fri May
29 16:40:09 2009
@@ -242,7 +242,7 @@
IPortWaveCyclic* iface)
{
IPortWaveCyclicImpl * This = (IPortWaveCyclicImpl*)iface;
-
+ DPRINT("IPortWaveCyclic_fnAddRef %u entered\n", This->ref);
return InterlockedIncrement(&This->ref);
}
@@ -254,13 +254,10 @@
IPortWaveCyclicImpl * This = (IPortWaveCyclicImpl*)iface;
InterlockedDecrement(&This->ref);
+ DPRINT("IPortWaveCyclic_fnRelease %u entered\n", This->ref);
if (This->ref == 0)
{
- if (This->bInitialized)
- {
- This->pMiniport->lpVtbl->Release(This->pMiniport);
- }
if (This->pPinCount)
This->pPinCount->lpVtbl->Release(This->pPinCount);
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/propertyhandler.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/propertyhandler.c [iso-8859-1]
(original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/propertyhandler.c [iso-8859-1] Fri May
29 16:40:09 2009
@@ -197,6 +197,9 @@
/* Release reference */
Port->lpVtbl->Release(Port);
+
+ /* Release subdevice reference */
+ SubDevice->lpVtbl->Release(SubDevice);
return Status;
}