From 052e7f510657cc182465aeb7cab3c2c70ca61a22 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Fri, 13 Nov 2009 14:13:22 +0000 Subject: [PATCH] [KS] - Silent debug traces on request of Christoph [CMIDRIVER] - Remove link hacks [WDMAUD_KERNEL] - Silent debug traces on request of Christoph - Reference notification event when the mixer is openend - Fix a bug in the notification handler (double free due entry not removed from list) svn path=/trunk/; revision=44132 --- reactos/drivers/ksfilter/ks/irp.c | 3 +- .../wdm/audio/drivers/CMIDriver/mintopo.cpp | 2 + .../audio/drivers/CMIDriver/mintopotables.hpp | 4 +- .../wdm/audio/drivers/CMIDriver/minwave.cpp | 5 +- .../audio/drivers/CMIDriver/minwavetables.hpp | 2 +- .../wdm/audio/drivers/directory.rbuild | 4 + .../drivers/wdm/audio/legacy/wdmaud/control.c | 12 ++- .../drivers/wdm/audio/legacy/wdmaud/entry.c | 6 +- .../drivers/wdm/audio/legacy/wdmaud/mixer.c | 86 +++++++++++-------- .../drivers/wdm/audio/legacy/wdmaud/wdmaud.h | 2 +- 10 files changed, 80 insertions(+), 46 deletions(-) diff --git a/reactos/drivers/ksfilter/ks/irp.c b/reactos/drivers/ksfilter/ks/irp.c index 4fdebe90302..e50490aad58 100644 --- a/reactos/drivers/ksfilter/ks/irp.c +++ b/reactos/drivers/ksfilter/ks/irp.c @@ -1790,7 +1790,8 @@ KspCreate( PKSIOBJECT_HEADER ObjectHeader; NTSTATUS Status; - DPRINT1("KS / CREATE\n"); + DPRINT("KS / CREATE\n"); + /* get current stack location */ IoStack = IoGetCurrentIrpStackLocation(Irp); /* get device extension */ diff --git a/reactos/drivers/wdm/audio/drivers/CMIDriver/mintopo.cpp b/reactos/drivers/wdm/audio/drivers/CMIDriver/mintopo.cpp index 7ced5096ce1..48af5f33e41 100644 --- a/reactos/drivers/wdm/audio/drivers/CMIDriver/mintopo.cpp +++ b/reactos/drivers/wdm/audio/drivers/CMIDriver/mintopo.cpp @@ -33,6 +33,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma code_seg("PAGE") +const GUID KSPROPSETID_CMI = {0x2B81CDBB, 0xEE6C, 0x4ECC, {0x8A, 0xA5, 0x9A, 0x18, 0x8B, 0x02, 0x3D, 0xFF}}; + HRESULT NTAPI CreateMiniportTopologyCMI(PUNKNOWN* Unknown, REFCLSID, PUNKNOWN UnknownOuter, POOL_TYPE PoolType) { //PAGED_CODE(); diff --git a/reactos/drivers/wdm/audio/drivers/CMIDriver/mintopotables.hpp b/reactos/drivers/wdm/audio/drivers/CMIDriver/mintopotables.hpp index 96656d682f4..dce93b1cf44 100644 --- a/reactos/drivers/wdm/audio/drivers/CMIDriver/mintopotables.hpp +++ b/reactos/drivers/wdm/audio/drivers/CMIDriver/mintopotables.hpp @@ -354,13 +354,13 @@ static PCPROPERTY_ITEM PropertiesFilter[] = (PCPFNPROPERTY_HANDLER)PropertyHandler_ComponentId }, { - &GUID_NULL,//&KSPROPSETID_CMI, //HACK + &KSPROPSETID_CMI, KSPROPERTY_CMI_GET, KSPROPERTY_TYPE_GET, (PCPFNPROPERTY_HANDLER)PropertyHandler_Private }, { - &GUID_NULL,//&KSPROPSETID_CMI, //HACK + &KSPROPSETID_CMI, KSPROPERTY_CMI_SET, KSPROPERTY_TYPE_SET, (PCPFNPROPERTY_HANDLER)PropertyHandler_Private diff --git a/reactos/drivers/wdm/audio/drivers/CMIDriver/minwave.cpp b/reactos/drivers/wdm/audio/drivers/CMIDriver/minwave.cpp index ddc9b588d19..4a0477133d5 100644 --- a/reactos/drivers/wdm/audio/drivers/CMIDriver/minwave.cpp +++ b/reactos/drivers/wdm/audio/drivers/CMIDriver/minwave.cpp @@ -469,6 +469,9 @@ NTSTATUS CMiniportWaveCMI::validateFormat(PKSDATAFORMAT format, ULONG PinID, BOO STDMETHODIMP CMiniportWaveCMI::DataRangeIntersection(ULONG PinId, PKSDATARANGE ClientDataRange, PKSDATARANGE MyDataRange, ULONG OutputBufferLength, PVOID ResultantFormat, PULONG ResultantFormatLength) { //PAGED_CODE(); + static const GUID KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF = {0x00000092L, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; + + DBGPRINT(("CMiniportWaveCMI[%p]::DataRangeIntersection(%d, %p, %p, %d, %p, %p)", this, PinId, ClientDataRange, MyDataRange, OutputBufferLength, ResultantFormat, ResultantFormatLength)); if (PinId == PIN_WAVE_AC3_RENDER_SINK) { @@ -482,7 +485,7 @@ STDMETHODIMP CMiniportWaveCMI::DataRangeIntersection(ULONG PinId, PKSDATARANGE C } - if (!IsEqualGUIDAligned(ClientDataRange->SubFormat, GUID_NULL)//KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF) //HACK + if (!IsEqualGUIDAligned(ClientDataRange->SubFormat, KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF) && !IsEqualGUIDAligned(ClientDataRange->SubFormat, KSDATAFORMAT_SUBTYPE_WILDCARD)) { // check for Vista isAC3Pin = false; diff --git a/reactos/drivers/wdm/audio/drivers/CMIDriver/minwavetables.hpp b/reactos/drivers/wdm/audio/drivers/CMIDriver/minwavetables.hpp index e380a1ce2fc..0c0326ca21c 100644 --- a/reactos/drivers/wdm/audio/drivers/CMIDriver/minwavetables.hpp +++ b/reactos/drivers/wdm/audio/drivers/CMIDriver/minwavetables.hpp @@ -65,7 +65,7 @@ static KSDATARANGE_AUDIO WavePinDataRangesAC3Stream[] = 0, 0, STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO), - STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO),//STATICGUIDOF(KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF), //HACK + STATICGUIDOF(KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF), STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) }, MAX_CHANNELS_AC3, diff --git a/reactos/drivers/wdm/audio/drivers/directory.rbuild b/reactos/drivers/wdm/audio/drivers/directory.rbuild index af2a40e8340..dbabf9e8d5f 100644 --- a/reactos/drivers/wdm/audio/drivers/directory.rbuild +++ b/reactos/drivers/wdm/audio/drivers/directory.rbuild @@ -4,6 +4,10 @@ + + + + diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/control.c b/reactos/drivers/wdm/audio/legacy/wdmaud/control.c index 3d4ceb2bb7e..6dda4dee4c2 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/control.c +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/control.c @@ -86,7 +86,7 @@ WdmAudControlDeviceState( ULONG BytesReturned; PFILE_OBJECT FileObject; - //DPRINT1("WdmAudControlDeviceState\n"); + DPRINT("WdmAudControlDeviceState\n"); Status = ObReferenceObjectByHandle(DeviceInfo->hDevice, GENERIC_READ | GENERIC_WRITE, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) @@ -105,7 +105,7 @@ WdmAudControlDeviceState( ObDereferenceObject(FileObject); - //DPRINT1("WdmAudControlDeviceState Status %x\n", Status); + DPRINT("WdmAudControlDeviceState Status %x\n", Status); return SetIrpIoStatus(Irp, Status, sizeof(WDMAUD_DEVICE_INFO)); } @@ -155,6 +155,14 @@ WdmAudIoctlClose( SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO)); return STATUS_SUCCESS; } + 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; + } + } } SetIrpIoStatus(Irp, STATUS_INVALID_PARAMETER, sizeof(WDMAUD_DEVICE_INFO)); diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c b/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c index 7d774da359d..013be6aa020 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c @@ -22,7 +22,7 @@ WdmAudInstallDevice( NTSTATUS Status; PWDMAUD_DEVICE_EXTENSION DeviceExtension; - DPRINT1("WdmAudInstallDevice called\n"); + DPRINT("WdmAudInstallDevice called\n"); Status = IoCreateDevice(DriverObject, sizeof(WDMAUD_DEVICE_EXTENSION), @@ -95,7 +95,7 @@ NTAPI WdmAudUnload( IN PDRIVER_OBJECT driver) { - DPRINT1("WdmAudUnload called\n"); + DPRINT("WdmAudUnload called\n"); } NTSTATUS @@ -266,7 +266,7 @@ DriverEntry( IN PUNICODE_STRING Registry_path ) { - DPRINT1("Wdmaud.sys loaded\n"); + DPRINT("Wdmaud.sys loaded\n"); Driver->DriverUnload = WdmAudUnload; diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c b/reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c index 845263994f1..946d45bb9c8 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c @@ -1752,25 +1752,39 @@ WdmAudControlOpenMixer( ULONG Index; PWDMAUD_HANDLE Handels; PWDMAUD_DEVICE_EXTENSION DeviceExtension; + NTSTATUS Status; + PKEVENT EventObject = NULL; DPRINT("WdmAudControlOpenMixer\n"); DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - if (DeviceInfo->DeviceIndex >= DeviceExtension->MixerInfoCount) { /* mixer index doesnt exist */ return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, 0); } + if (DeviceInfo->u.hNotifyEvent) + { + Status = ObReferenceObjectByHandle(DeviceInfo->u.hNotifyEvent, EVENT_MODIFY_STATE, ExEventObjectType, UserMode, (LPVOID*)&EventObject, NULL); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("Invalid notify event passed %p from client %p\n", DeviceInfo->u.hNotifyEvent, ClientInfo); + DbgBreakPoint(); + return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, 0); + } + } + + for(Index = 0; Index < ClientInfo->NumPins; Index++) { if (ClientInfo->hPins[Index].Handle == (HANDLE)DeviceInfo->DeviceIndex && ClientInfo->hPins[Index].Type == MIXER_DEVICE_TYPE) { /* re-use pseudo handle */ DeviceInfo->hDevice = (HANDLE)DeviceInfo->DeviceIndex; - ClientInfo->hPins[Index].hNotifyEvent = DeviceInfo->u.hNotifyEvent; + ClientInfo->hPins[Index].NotifyEvent = EventObject; return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO)); } } @@ -1788,7 +1802,7 @@ WdmAudControlOpenMixer( ClientInfo->hPins = Handels; ClientInfo->hPins[ClientInfo->NumPins].Handle = (HANDLE)DeviceInfo->DeviceIndex; ClientInfo->hPins[ClientInfo->NumPins].Type = MIXER_DEVICE_TYPE; - ClientInfo->hPins[ClientInfo->NumPins].hNotifyEvent = DeviceInfo->u.hNotifyEvent; + ClientInfo->hPins[ClientInfo->NumPins].NotifyEvent = EventObject; ClientInfo->NumPins++; } else @@ -1849,7 +1863,7 @@ WdmAudGetLineInfo( if (DeviceInfo->u.MixLine.dwSource >= MixerLineSrc->Line.cConnections) { - DPRINT1("dwSource %u Destinations %u\n", DeviceInfo->u.MixLine.dwSource, MixerLineSrc->Line.cConnections); + DPRINT1("dwSource %u > Destinations %u\n", DeviceInfo->u.MixLine.dwSource, MixerLineSrc->Line.cConnections); /* invalid parameter */ return SetIrpIoStatus(Irp, STATUS_INVALID_PARAMETER, 0); } @@ -1903,7 +1917,7 @@ WdmAudGetLineInfo( return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO)); } - DPRINT1("Flags %x\n", DeviceInfo->Flags); + DPRINT("Flags %x\n", DeviceInfo->Flags); UNIMPLEMENTED; //DbgBreakPoint(); @@ -1960,14 +1974,14 @@ WdmAudGetLineControls( Index = 0; for(Index = 0; Index < MixerLineSrc->Line.cControls; Index++) { - DPRINT1("dwControlType %x\n", MixerLineSrc->LineControls[Index].dwControlType); + DPRINT("dwControlType %x\n", MixerLineSrc->LineControls[Index].dwControlType); if (DeviceInfo->u.MixControls.dwControlType == MixerLineSrc->LineControls[Index].dwControlType) { RtlMoveMemory(DeviceInfo->u.MixControls.pamxctrl, &MixerLineSrc->LineControls[Index], sizeof(MIXERCONTROLW)); return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO)); } } - DPRINT1("DeviceInfo->u.MixControls.dwControlType %x not found in Line %x cControls %u \n", DeviceInfo->u.MixControls.dwControlType, DeviceInfo->u.MixControls.dwLineID, MixerLineSrc->Line.cControls); + DPRINT("DeviceInfo->u.MixControls.dwControlType %x not found in Line %x cControls %u \n", DeviceInfo->u.MixControls.dwControlType, DeviceInfo->u.MixControls.dwLineID, MixerLineSrc->Line.cControls); return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, sizeof(WDMAUD_DEVICE_INFO)); } else if (DeviceInfo->Flags == MIXER_GETLINECONTROLSF_ONEBYID) @@ -1977,7 +1991,7 @@ WdmAudGetLineControls( /* invalid parameter */ return SetIrpIoStatus(Irp, STATUS_INVALID_PARAMETER, 0); } - DPRINT1("MixerId %u ControlId %u\n",(ULONG_PTR)DeviceInfo->hDevice, DeviceInfo->u.MixControls.dwControlID); + DPRINT("MixerId %u ControlId %u\n",(ULONG_PTR)DeviceInfo->hDevice, DeviceInfo->u.MixControls.dwControlID); Status = GetMixerControlById(&DeviceExtension->MixerInfo[(ULONG_PTR)DeviceInfo->hDevice], DeviceInfo->u.MixControls.dwControlID, NULL, &MixerControl, NULL); if (NT_SUCCESS(Status)) { @@ -2047,7 +2061,7 @@ SetGetControlDetails( *InputValue = Value; } - DPRINT1("Status %x bSet %u NodeId %u Value %d PropertyId %u\n", Status, bSet, NodeId, Value, PropertyId); + DPRINT("Status %x bSet %u NodeId %u Value %d PropertyId %u\n", Status, bSet, NodeId, Value, PropertyId); return Status; } @@ -2061,11 +2075,9 @@ NotifyWdmAudClients( PWDMAUD_DEVICE_EXTENSION DeviceExtension; PLIST_ENTRY Entry; PWDMAUD_CLIENT CurClient; - PKEVENT EventObject; PMIXER_EVENT Event; KIRQL OldIrql; ULONG Index; - NTSTATUS Status; /* get device extension */ DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension; @@ -2085,22 +2097,13 @@ NotifyWdmAudClients( /* now iterate through all pins and try to find an matching handle */ for(Index = 0; Index < CurClient->NumPins; Index++) { - if (CurClient->hPins[Index].Handle == hMixer && CurClient->hPins[Index].Type == MIXER_DEVICE_TYPE && CurClient->hPins[Index].hNotifyEvent) + if (CurClient->hPins[Index].Handle == hMixer && CurClient->hPins[Index].Type == MIXER_DEVICE_TYPE && CurClient->hPins[Index].NotifyEvent) { - /* found a matching mixer handle and a valid notify event */ - Status = ObReferenceObjectByHandle(CurClient->hPins[Index].hNotifyEvent, EVENT_MODIFY_STATE, ExEventObjectType, UserMode, (LPVOID*)&EventObject, NULL); - if (!NT_SUCCESS(Status)) - { - DPRINT1("Invalid notify event passed %p from client %p\n", CurClient->hPins[Index].hNotifyEvent, CurClient); - break; - } - /* allocate event entry */ Event = (PMIXER_EVENT)ExAllocatePool(NonPagedPool, sizeof(MIXER_EVENT)); if (!Event) { /* no memory */ - ObDereferenceObject(EventObject); return STATUS_INSUFFICIENT_RESOURCES; } @@ -2112,11 +2115,12 @@ NotifyWdmAudClients( /* insert event entry */ InsertTailList(&CurClient->MixerEventList, &Event->Entry); + DPRINT("Notifying %p hMixer %p Value %x NotificationType %u\n", CurClient->hPins[Index].NotifyEvent, hMixer, Value, NotificationType); + /* now signal the event */ - KeSetEvent(EventObject, 0, FALSE); + KeSetEvent(CurClient->hPins[Index].NotifyEvent, 0, FALSE); + - /* dereference event */ - ObDereferenceObject(EventObject); /* search next client */ break; @@ -2179,6 +2183,24 @@ SetGetMuteControlDetails( return Status; } +ULONG +GetVolumeControlIndex( + LPMIXERVOLUME_DATA VolumeData, + LONG Value) +{ + ULONG Index; + + for(Index = 0; Index < VolumeData->ValuesCount; Index++) + { + if (VolumeData->Values[Index] > Value) + { + return VolumeData->InputSteppingDelta * Index; + } + } + return VolumeData->InputSteppingDelta * (VolumeData->ValuesCount-1); +} + + NTSTATUS SetGetVolumeControlDetails( IN PDEVICE_OBJECT DeviceObject, @@ -2191,6 +2213,7 @@ SetGetVolumeControlDetails( { LPMIXERCONTROLDETAILS_UNSIGNED Input; LONG Value, Index, Channel = 0; + ULONG dwValue; NTSTATUS Status; LPMIXERVOLUME_DATA VolumeData; @@ -2234,16 +2257,9 @@ SetGetVolumeControlDetails( if (!bSet) { - for(Index = 0; Index < VolumeData->ValuesCount; Index++) - { - if (VolumeData->Values[Index] > Value) - { - /* FIXME SEH */ - Input->dwValue = VolumeData->InputSteppingDelta * Index; - return Status; - } - } - Input->dwValue = VolumeData->InputSteppingDelta * (VolumeData->ValuesCount-1); + dwValue = GetVolumeControlIndex(VolumeData, (LONG)Value); + /* FIXME SEH */ + Input->dwValue = dwValue; } else { @@ -2283,6 +2299,7 @@ WdmAudGetMixerEvent( if (Event->hMixer == DeviceInfo->hDevice) { /* found an event for that particular device */ + RemoveEntryList(&Event->Entry); break; } @@ -2293,7 +2310,6 @@ WdmAudGetMixerEvent( Entry = Entry->Flink; } - /* release client context lock */ KeReleaseSpinLock(&DeviceExtension->Lock, OldIrql); diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h b/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h index bc27c367f0f..c8e53320e1e 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h @@ -31,7 +31,7 @@ typedef struct SOUND_DEVICE_TYPE Type; ULONG FilterId; ULONG PinId; - HANDLE hNotifyEvent; + PRKEVENT NotifyEvent; }WDMAUD_HANDLE, *PWDMAUD_HANDLE; typedef struct -- 2.17.1