From 88c42f36e699fc3d51bd0d9069524fc06a103485 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Tue, 6 Oct 2009 18:16:21 +0000 Subject: [PATCH] - Implement MIXER_GETLINEINFOF_COMPONENTTYPE for WdmAudGetLineInfo - Implement MIXER_GETLINECONTROLSF_ONEBYID for WdmAudGetLineControls - Clear MIXER_OBJECTF_HMIXER from Flags - Fix a bug SetGetVolumeControlDetails which fixes retrieving current volume level (verified by sndvol32.exe from XP / mmsys.cpl ReactOS) svn path=/trunk/; revision=43315 --- .../drivers/wdm/audio/legacy/wdmaud/mixer.c | 72 +++++++++++++++++-- 1 file changed, 68 insertions(+), 4 deletions(-) diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c b/reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c index 4fc4775dcf0..2b0ced20424 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c @@ -96,9 +96,12 @@ GetMixerControlById( { if (MixerLineSrc->LineControls[Index].dwControlID == dwControlID) { - *MixerLine = MixerLineSrc; - *MixerControl = &MixerLineSrc->LineControls[Index]; - *NodeId = MixerLineSrc->NodeIds[Index]; + if (MixerLine) + *MixerLine = MixerLineSrc; + if (MixerControl) + *MixerControl = &MixerLineSrc->LineControls[Index]; + if (NodeId) + *NodeId = MixerLineSrc->NodeIds[Index]; return STATUS_SUCCESS; } } @@ -108,7 +111,28 @@ GetMixerControlById( return STATUS_NOT_FOUND; } +LPMIXERLINE_EXT +GetSourceMixerLineByComponentType( + LPMIXER_INFO MixerInfo, + DWORD dwComponentType) +{ + PLIST_ENTRY Entry; + LPMIXERLINE_EXT MixerLineSrc; + + /* get first entry */ + Entry = MixerInfo->LineList.Flink; + + while(Entry != &MixerInfo->LineList) + { + MixerLineSrc = (LPMIXERLINE_EXT)CONTAINING_RECORD(Entry, MIXERLINE_EXT, Entry); + if (MixerLineSrc->Line.dwComponentType == dwComponentType) + return MixerLineSrc; + + Entry = Entry->Flink; + } + return NULL; +} LPMIXERLINE_EXT GetSourceMixerLineByLineId( @@ -1761,6 +1785,8 @@ WdmAudGetLineInfo( /* get device extension */ DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + DeviceInfo->Flags &= ~MIXER_OBJECTF_HMIXER; + if (DeviceInfo->Flags == MIXER_GETLINEINFOF_DESTINATION) { if ((ULONG)DeviceInfo->hDevice >= DeviceExtension->MixerInfoCount) @@ -1822,7 +1848,21 @@ WdmAudGetLineInfo( RtlCopyMemory(&DeviceInfo->u.MixLine, &MixerLineSrc->Line, sizeof(MIXERLINEW)); return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO)); } + else if (DeviceInfo->Flags == MIXER_GETLINEINFOF_COMPONENTTYPE) + { + if ((ULONG)DeviceInfo->hDevice >= DeviceExtension->MixerInfoCount) + { + /* invalid parameter */ + return SetIrpIoStatus(Irp, STATUS_INVALID_PARAMETER, 0); + } + + MixerLineSrc = GetSourceMixerLineByComponentType(&DeviceExtension->MixerInfo[(ULONG)DeviceInfo->hDevice], DeviceInfo->u.MixLine.dwComponentType); + ASSERT(MixerLineSrc); + /* copy cached data */ + RtlCopyMemory(&DeviceInfo->u.MixLine, &MixerLineSrc->Line, sizeof(MIXERLINEW)); + return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO)); + } DPRINT1("Flags %x\n", DeviceInfo->Flags); UNIMPLEMENTED; @@ -1841,12 +1881,16 @@ WdmAudGetLineControls( IN PWDMAUD_CLIENT ClientInfo) { LPMIXERLINE_EXT MixerLineSrc; + LPMIXERCONTROLW MixerControl; PWDMAUD_DEVICE_EXTENSION DeviceExtension; ULONG Index; + NTSTATUS Status; /* get device extension */ DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + DeviceInfo->Flags &= ~MIXER_OBJECTF_HMIXER; + if (DeviceInfo->Flags == MIXER_GETLINECONTROLSF_ALL) { if ((ULONG)DeviceInfo->hDevice >= DeviceExtension->MixerInfoCount) @@ -1887,6 +1931,22 @@ WdmAudGetLineControls( 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); return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, sizeof(WDMAUD_DEVICE_INFO)); } + else if (DeviceInfo->Flags == MIXER_GETLINECONTROLSF_ONEBYID) + { + if ((ULONG)DeviceInfo->hDevice >= DeviceExtension->MixerInfoCount) + { + /* invalid parameter */ + return SetIrpIoStatus(Irp, STATUS_INVALID_PARAMETER, 0); + } + + Status = GetMixerControlById(&DeviceExtension->MixerInfo[(ULONG)DeviceInfo->hDevice], DeviceInfo->u.MixControls.dwControlID, NULL, &MixerControl, NULL); + if (NT_SUCCESS(Status)) + { + RtlMoveMemory(DeviceInfo->u.MixControls.pamxctrl, MixerControl, sizeof(MIXERCONTROLW)); + } + return SetIrpIoStatus(Irp, Status, sizeof(WDMAUD_DEVICE_INFO)); + } + UNIMPLEMENTED; //DbgBreakPoint(); @@ -2042,7 +2102,7 @@ SetGetVolumeControlDetails( { for(Index = 0; Index < VolumeData->ValuesCount; Index++) { - if (VolumeData->Values[Index] < Value) + if (VolumeData->Values[Index] > Value) { /* FIXME SEH */ Input->dwValue = VolumeData->InputSteppingDelta * Index; @@ -2069,6 +2129,8 @@ WdmAudSetControlDetails( PWDMAUD_DEVICE_EXTENSION DeviceExtension; NTSTATUS Status; + DeviceInfo->Flags &= ~MIXER_OBJECTF_HMIXER; + DPRINT("cbStruct %u Expected %u dwControlID %u cChannels %u cMultipleItems %u cbDetails %u paDetails %p Flags %x\n", DeviceInfo->u.MixDetails.cbStruct, sizeof(MIXERCONTROLDETAILS), DeviceInfo->u.MixDetails.dwControlID, DeviceInfo->u.MixDetails.cChannels, DeviceInfo->u.MixDetails.cMultipleItems, DeviceInfo->u.MixDetails.cbDetails, DeviceInfo->u.MixDetails.paDetails, DeviceInfo->Flags); @@ -2119,6 +2181,8 @@ WdmAudGetControlDetails( PWDMAUD_DEVICE_EXTENSION DeviceExtension; NTSTATUS Status; + DeviceInfo->Flags &= ~MIXER_OBJECTF_HMIXER; + DPRINT("cbStruct %u Expected %u dwControlID %u cChannels %u cMultipleItems %u cbDetails %u paDetails %p Flags %x\n", DeviceInfo->u.MixDetails.cbStruct, sizeof(MIXERCONTROLDETAILS), DeviceInfo->u.MixDetails.dwControlID, DeviceInfo->u.MixDetails.cChannels, DeviceInfo->u.MixDetails.cMultipleItems, DeviceInfo->u.MixDetails.cbDetails, DeviceInfo->u.MixDetails.paDetails, DeviceInfo->Flags); -- 2.17.1