Author: janderwald
Date: Thu May 28 00:33:00 2009
New Revision: 41157
URL:
http://svn.reactos.org/svn/reactos?rev=41157&view=rev
Log:
- Register shutdown notification
- Close file objects / handles on shutdown
Modified:
trunk/reactos/drivers/wdm/audio/sysaudio/deviface.c
trunk/reactos/drivers/wdm/audio/sysaudio/main.c
Modified: trunk/reactos/drivers/wdm/audio/sysaudio/deviface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/sysaudio/deviface.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/sysaudio/deviface.c [iso-8859-1] Thu May 28 00:33:00
2009
@@ -59,7 +59,7 @@
if (!DeviceEntry->Pins)
{
/* no memory */
- DPRINT1("Failed to allocate memory Block %x\n", Count *
sizeof(PIN_INFO));
+ DPRINT1("Failed to allocate memory Pins %u Block %x\n", Count, Count *
sizeof(PIN_INFO));
goto cleanup;
}
/* clear array */
Modified: trunk/reactos/drivers/wdm/audio/sysaudio/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/sysaudio/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/sysaudio/main.c [iso-8859-1] Thu May 28 00:33:00 2009
@@ -29,6 +29,40 @@
NTSTATUS
NTAPI
+SysAudio_Shutdown(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ PKSAUDIO_DEVICE_ENTRY DeviceEntry;
+ PSYSAUDIODEVEXT DeviceExtension;
+ PLIST_ENTRY Entry;
+
+ DPRINT1("SysAudio_Shutdown called\n");
+
+ DeviceExtension = (PSYSAUDIODEVEXT)DeviceObject->DeviceExtension;
+
+ while(!IsListEmpty(&DeviceExtension->KsAudioDeviceList))
+ {
+ Entry = RemoveHeadList(&DeviceExtension->KsAudioDeviceList);
+ DeviceEntry = (PKSAUDIO_DEVICE_ENTRY)CONTAINING_RECORD(Entry,
KSAUDIO_DEVICE_ENTRY, Entry);
+
+ DPRINT1("Freeing item %wZ\n", &DeviceEntry->DeviceName);
+ RtlFreeUnicodeString(&DeviceEntry->DeviceName);
+ ZwClose(DeviceEntry->Handle);
+ ObDereferenceObject(DeviceEntry->FileObject);
+ ExFreePool(DeviceEntry->Pins);
+ ExFreePool(DeviceEntry);
+ }
+
+ Irp->IoStatus.Information = 0;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+NTAPI
SysAudio_Pnp(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
@@ -153,6 +187,10 @@
/* clear initializing flag */
DeviceObject->Flags &= ~ DO_DEVICE_INITIALIZING;
+ /* register shutdown notfication */
+ IoRegisterShutdownNotification(DeviceObject);
+
+
/* Done */
return STATUS_SUCCESS;
@@ -192,6 +230,7 @@
/* Sysaudio needs to do work on pnp, so handle it */
DriverObject->MajorFunction[IRP_MJ_PNP] = SysAudio_Pnp;
+ DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = SysAudio_Shutdown;
/* Call our initialization function */
return SysAudio_InstallDevice(DriverObject);