mirror of
https://github.com/reactos/reactos.git
synced 2024-08-05 11:00:55 +00:00
- Fix leaking of work item for each detected audio device
svn path=/trunk/; revision=40373
This commit is contained in:
parent
b9a7dffffa
commit
d8ae8a179f
|
@ -17,7 +17,7 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
FilterPinWorkerRoutine(
|
FilterPinWorkerRoutine(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PVOID Context)
|
IN PVOID Context)
|
||||||
{
|
{
|
||||||
KSPROPERTY PropertyRequest;
|
KSPROPERTY PropertyRequest;
|
||||||
KSP_PIN PinRequest;
|
KSP_PIN PinRequest;
|
||||||
|
@ -27,6 +27,7 @@ FilterPinWorkerRoutine(
|
||||||
ULONG Count, Index;
|
ULONG Count, Index;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG BytesReturned;
|
ULONG BytesReturned;
|
||||||
|
PSYSAUDIODEVEXT DeviceExtension;
|
||||||
PKSAUDIO_DEVICE_ENTRY DeviceEntry = (PKSAUDIO_DEVICE_ENTRY)Context;
|
PKSAUDIO_DEVICE_ENTRY DeviceEntry = (PKSAUDIO_DEVICE_ENTRY)Context;
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,17 +41,22 @@ FilterPinWorkerRoutine(
|
||||||
Status = KsSynchronousIoControlDevice(DeviceEntry->FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&PropertyRequest, sizeof(KSPROPERTY), (PVOID)&Count, sizeof(ULONG), &BytesReturned);
|
Status = KsSynchronousIoControlDevice(DeviceEntry->FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&PropertyRequest, sizeof(KSPROPERTY), (PVOID)&Count, sizeof(ULONG), &BytesReturned);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
ExFreePool(DeviceEntry);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Count)
|
if (!Count)
|
||||||
|
{
|
||||||
|
ExFreePool(DeviceEntry);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* allocate pin array */
|
/* allocate pin array */
|
||||||
DeviceEntry->Pins = ExAllocatePool(NonPagedPool, Count * sizeof(PIN_INFO));
|
DeviceEntry->Pins = ExAllocatePool(NonPagedPool, Count * sizeof(PIN_INFO));
|
||||||
if (!DeviceEntry->Pins)
|
if (!DeviceEntry->Pins)
|
||||||
{
|
{
|
||||||
/* no memory */
|
/* no memory */
|
||||||
|
ExFreePool(DeviceEntry);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* clear array */
|
/* clear array */
|
||||||
|
@ -96,6 +102,12 @@ FilterPinWorkerRoutine(
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT1("Num Pins %u Num WaveIn Pins %u Name WaveOut Pins %u\n", DeviceEntry->NumberOfPins, DeviceEntry->NumWaveInPin, DeviceEntry->NumWaveOutPin);
|
DPRINT1("Num Pins %u Num WaveIn Pins %u Name WaveOut Pins %u\n", DeviceEntry->NumberOfPins, DeviceEntry->NumWaveInPin, DeviceEntry->NumWaveOutPin);
|
||||||
|
|
||||||
|
DeviceExtension = (PSYSAUDIODEVEXT)DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
|
InsertTailList(&DeviceExtension->KsAudioDeviceList, &DeviceEntry->Entry);
|
||||||
|
DeviceExtension->NumberOfKsAudioDevices++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -153,6 +165,7 @@ DeviceInterfaceChangeCallback(
|
||||||
DEVICE_INTERFACE_CHANGE_NOTIFICATION * Event;
|
DEVICE_INTERFACE_CHANGE_NOTIFICATION * Event;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
PSYSAUDIODEVEXT DeviceExtension;
|
PSYSAUDIODEVEXT DeviceExtension;
|
||||||
|
PKSAUDIO_DEVICE_ENTRY DeviceEntry;
|
||||||
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT)Context;
|
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT)Context;
|
||||||
|
|
||||||
DeviceExtension = (PSYSAUDIODEVEXT)DeviceObject->DeviceExtension;
|
DeviceExtension = (PSYSAUDIODEVEXT)DeviceObject->DeviceExtension;
|
||||||
|
@ -163,10 +176,6 @@ DeviceInterfaceChangeCallback(
|
||||||
&GUID_DEVICE_INTERFACE_ARRIVAL))
|
&GUID_DEVICE_INTERFACE_ARRIVAL))
|
||||||
{
|
{
|
||||||
/* a new device has arrived */
|
/* a new device has arrived */
|
||||||
|
|
||||||
PKSAUDIO_DEVICE_ENTRY DeviceEntry;
|
|
||||||
PIO_WORKITEM WorkItem;
|
|
||||||
|
|
||||||
DeviceEntry = ExAllocatePool(NonPagedPool, sizeof(KSAUDIO_DEVICE_ENTRY));
|
DeviceEntry = ExAllocatePool(NonPagedPool, sizeof(KSAUDIO_DEVICE_ENTRY));
|
||||||
if (!DeviceEntry)
|
if (!DeviceEntry)
|
||||||
{
|
{
|
||||||
|
@ -206,16 +215,11 @@ DeviceInterfaceChangeCallback(
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT1("Successfully opened audio device %u handle %p file object %p device object %p\n", DeviceExtension->KsAudioDeviceList, DeviceEntry->Handle, DeviceEntry->FileObject, DeviceEntry->FileObject->DeviceObject);
|
DPRINT1("Successfully opened audio device %u handle %p file object %p device object %p\n", DeviceExtension->NumberOfKsAudioDevices, DeviceEntry->Handle, DeviceEntry->FileObject, DeviceEntry->FileObject->DeviceObject);
|
||||||
DeviceExtension->NumberOfKsAudioDevices++;
|
|
||||||
|
|
||||||
WorkItem = IoAllocateWorkItem(DeviceObject);
|
|
||||||
if (WorkItem)
|
|
||||||
{
|
|
||||||
IoQueueWorkItem(WorkItem, FilterPinWorkerRoutine, DelayedWorkQueue, (PVOID)DeviceEntry);
|
|
||||||
}
|
|
||||||
InsertTailList(&DeviceExtension->KsAudioDeviceList, &DeviceEntry->Entry);
|
|
||||||
|
|
||||||
|
//FIXME
|
||||||
|
// mutal exclusion
|
||||||
|
IoQueueWorkItem(DeviceExtension->WorkItem, FilterPinWorkerRoutine, DelayedWorkQueue, (PVOID)DeviceEntry);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -131,15 +131,6 @@ SysAudio_InstallDevice(
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register device notification hooks */
|
|
||||||
Status = SysAudioRegisterNotifications(DriverObject,
|
|
||||||
DeviceObject);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("Failed to register device notifications\n");
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allocate work item */
|
/* allocate work item */
|
||||||
DeviceExtension->WorkItem = IoAllocateWorkItem(DeviceObject);
|
DeviceExtension->WorkItem = IoAllocateWorkItem(DeviceObject);
|
||||||
if (!DeviceExtension->WorkItem)
|
if (!DeviceExtension->WorkItem)
|
||||||
|
@ -156,6 +147,14 @@ SysAudio_InstallDevice(
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Register device notification hooks */
|
||||||
|
Status = SysAudioRegisterNotifications(DriverObject,
|
||||||
|
DeviceObject);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("Failed to register device notifications\n");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
/* Load kmixer */
|
/* Load kmixer */
|
||||||
Status = SysAudioOpenKMixer(DeviceExtension);
|
Status = SysAudioOpenKMixer(DeviceExtension);
|
||||||
|
|
Loading…
Reference in a new issue