Author: sdever
Date: Sat Jun 24 13:54:10 2017
New Revision: 75183
URL:
http://svn.reactos.org/svn/reactos?rev=75183&view=rev
Log:
[MMIXER] Cleanup mixer notifications opened by an application when it is closed.
CORE-10735 #comment Please retest.
Modified:
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h
trunk/reactos/sdk/lib/drivers/sound/mmixer/controls.c
trunk/reactos/sdk/lib/drivers/sound/mmixer/mixer.c
trunk/reactos/sdk/lib/drivers/sound/mmixer/mmixer.h
trunk/reactos/sdk/lib/drivers/sound/mmixer/precomp.h
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] Sat Jun 24
13:54:10 2017
@@ -166,11 +166,8 @@
}
else if (ClientInfo->hPins[Index].Handle == DeviceInfo->hDevice &&
ClientInfo->hPins[Index].Type == MIXER_DEVICE_TYPE)
{
- if (ClientInfo->hPins[Index].NotifyEvent)
- {
- ObDereferenceObject(ClientInfo->hPins[Index].NotifyEvent);
- ClientInfo->hPins[Index].NotifyEvent = NULL;
- }
+ DPRINT1("Closing mixer %p\n", DeviceInfo->hDevice);
+ return WdmAudControlCloseMixer(DeviceObject, Irp, DeviceInfo, ClientInfo,
Index);
}
}
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c [iso-8859-1] Sat Jun 24
13:54:10 2017
@@ -472,6 +472,32 @@
}
NTSTATUS
+WdmAudControlCloseMixer(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ IN PWDMAUD_DEVICE_INFO DeviceInfo,
+ IN PWDMAUD_CLIENT ClientInfo,
+ IN ULONG Index)
+{
+ /* Remove event associated to this client */
+ if (MMixerClose(&MixerContext, DeviceInfo->DeviceIndex, ClientInfo,
EventCallback))
+ {
+ DPRINT1("Failed to close mixer\n");
+ return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, sizeof(WDMAUD_DEVICE_INFO));
+ }
+
+ /* Dereference event */
+ if (ClientInfo->hPins[Index].NotifyEvent)
+ {
+ ObDereferenceObject(ClientInfo->hPins[Index].NotifyEvent);
+ ClientInfo->hPins[Index].NotifyEvent = NULL;
+ }
+
+ /* FIXME: do we need to free ClientInfo->hPins ? */
+ return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO));
+}
+
+NTSTATUS
NTAPI
WdmAudGetControlDetails(
IN PDEVICE_OBJECT DeviceObject,
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h [iso-8859-1] Sat Jun 24
13:54:10 2017
@@ -129,6 +129,14 @@
IN PWDMAUD_CLIENT ClientInfo);
NTSTATUS
+WdmAudControlCloseMixer(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ IN PWDMAUD_DEVICE_INFO DeviceInfo,
+ IN PWDMAUD_CLIENT ClientInfo,
+ IN ULONG Index);
+
+NTSTATUS
WdmAudControlOpenWave(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
Modified: trunk/reactos/sdk/lib/drivers/sound/mmixer/controls.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/drivers/sound/mmix…
==============================================================================
--- trunk/reactos/sdk/lib/drivers/sound/mmixer/controls.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/drivers/sound/mmixer/controls.c [iso-8859-1] Sat Jun 24 13:54:10
2017
@@ -1834,17 +1834,19 @@
IN PMIXER_EVENT MixerEventRoutine)
{
//KSE_NODE Property;
- PEVENT_NOTIFICATION_ENTRY EventData;
+ //KSEVENTDATA EventData
//ULONG BytesReturned;
//MIXER_STATUS Status;
-
- EventData =
(PEVENT_NOTIFICATION_ENTRY)MixerContext->AllocEventData(sizeof(EVENT_NOTIFICATION_ENTRY));
- if (!EventData)
+ PEVENT_NOTIFICATION_ENTRY EventNotification;
+
+ EventNotification =
(PEVENT_NOTIFICATION_ENTRY)MixerContext->Alloc(sizeof(EVENT_NOTIFICATION_ENTRY));
+ if (!EventNotification)
{
/* not enough memory */
return MM_STATUS_NO_MEMORY;
}
+ /* FIXME: what is it supposed to happen with KSEVENTDATA ? */
#if 0
/* setup request */
Property.Event.Set = KSEVENTSETID_AudioControlChange;
@@ -1864,10 +1866,39 @@
#endif
/* initialize notification entry */
- EventData->MixerEventContext = MixerEventContext;
- EventData->MixerEventRoutine = MixerEventRoutine;
+ EventNotification->MixerEventContext = MixerEventContext;
+ EventNotification->MixerEventRoutine = MixerEventRoutine;
/* store event */
- InsertTailList(&MixerInfo->EventList, &EventData->Entry);
+ InsertTailList(&MixerInfo->EventList, &EventNotification->Entry);
return MM_STATUS_SUCCESS;
}
+
+MIXER_STATUS
+MMixerRemoveEvent(
+ IN PMIXER_CONTEXT MixerContext,
+ IN OUT LPMIXER_INFO MixerInfo,
+ IN PVOID MixerEventContext,
+ IN PMIXER_EVENT MixerEventRoutine)
+{
+ PLIST_ENTRY EventList;
+ PEVENT_NOTIFICATION_ENTRY NotificationEntry;
+
+ /* Lookup through mixers */
+ EventList = MixerInfo->EventList.Flink;
+ while(EventList != &MixerInfo->EventList)
+ {
+ NotificationEntry = CONTAINING_RECORD(EventList, EVENT_NOTIFICATION_ENTRY,
Entry);
+ EventList = EventList->Flink;
+ /* TODO: find a better way to identify an event ? */
+ if(NotificationEntry->MixerEventRoutine == MixerEventRoutine &&
+ NotificationEntry->MixerEventContext == MixerEventContext)
+ {
+ DPRINT1("Freeing entry %p\n", NotificationEntry);
+ /* We found the event to remove */
+ RemoveEntryList(&NotificationEntry->Entry);
+ MixerContext->Free(NotificationEntry);
+ }
+ }
+ return MM_STATUS_SUCCESS;
+}
Modified: trunk/reactos/sdk/lib/drivers/sound/mmixer/mixer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/drivers/sound/mmix…
==============================================================================
--- trunk/reactos/sdk/lib/drivers/sound/mmixer/mixer.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/drivers/sound/mmixer/mixer.c [iso-8859-1] Sat Jun 24 13:54:10
2017
@@ -110,6 +110,39 @@
/* store result */
*MixerHandle = (HANDLE)MixerInfo;
return MM_STATUS_SUCCESS;
+}
+
+MIXER_STATUS
+MMixerClose(
+ IN PMIXER_CONTEXT MixerContext,
+ IN ULONG MixerId,
+ IN PVOID MixerEventContext,
+ IN PMIXER_EVENT MixerEventRoutine)
+{
+ MIXER_STATUS Status;
+ LPMIXER_INFO MixerInfo;
+
+ /* verify mixer context */
+ Status = MMixerVerifyContext(MixerContext);
+
+ if (Status != MM_STATUS_SUCCESS)
+ {
+ /* invalid context passed */
+ DPRINT1("invalid context\n");
+ return Status;
+ }
+
+ /* get mixer info */
+ MixerInfo = MMixerGetMixerInfoByIndex(MixerContext, MixerId);
+ if (!MixerInfo)
+ {
+ /* invalid mixer id */
+ DPRINT1("invalid mixer id %lu\n", MixerId);
+ return MM_STATUS_INVALID_PARAMETER;
+ }
+
+ /* remove event from list */
+ return MMixerRemoveEvent(MixerContext, MixerInfo, MixerEventContext,
MixerEventRoutine);
}
MIXER_STATUS
Modified: trunk/reactos/sdk/lib/drivers/sound/mmixer/mmixer.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/drivers/sound/mmix…
==============================================================================
--- trunk/reactos/sdk/lib/drivers/sound/mmixer/mmixer.h [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/drivers/sound/mmixer/mmixer.h [iso-8859-1] Sat Jun 24 13:54:10
2017
@@ -147,6 +147,13 @@
OUT PHANDLE MixerHandle);
MIXER_STATUS
+MMixerClose(
+ IN PMIXER_CONTEXT MixerContext,
+ IN ULONG MixerId,
+ IN PVOID MixerEventContext,
+ IN PMIXER_EVENT MixerEventRoutine);
+
+MIXER_STATUS
MMixerGetLineInfo(
IN PMIXER_CONTEXT MixerContext,
IN HANDLE MixerHandle,
Modified: trunk/reactos/sdk/lib/drivers/sound/mmixer/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/drivers/sound/mmix…
==============================================================================
--- trunk/reactos/sdk/lib/drivers/sound/mmixer/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/drivers/sound/mmixer/precomp.h [iso-8859-1] Sat Jun 24 13:54:10
2017
@@ -354,6 +354,13 @@
IN PMIXER_EVENT MixerEventRoutine);
MIXER_STATUS
+MMixerRemoveEvent(
+ IN PMIXER_CONTEXT MixerContext,
+ IN OUT LPMIXER_INFO MixerInfo,
+ IN PVOID MixerEventContext,
+ IN PMIXER_EVENT MixerEventRoutine);
+
+MIXER_STATUS
MMixerGetDeviceName(
IN PMIXER_CONTEXT MixerContext,
OUT LPWSTR DeviceName,