Author: janderwald Date: Fri Oct 21 21:26:12 2016 New Revision: 73017
URL: http://svn.reactos.org/svn/reactos?rev=73017&view=rev Log: - implement MMixerGetDeviceNameWithComponentId, which retrieves the device name via component id - start implement MMixerHandleTopologyFilter, does not yet fully work
Modified: trunk/reactos/sdk/lib/drivers/sound/mmixer/controls.c trunk/reactos/sdk/lib/drivers/sound/mmixer/precomp.h trunk/reactos/sdk/lib/drivers/sound/mmixer/sup.c
Modified: trunk/reactos/sdk/lib/drivers/sound/mmixer/controls.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/drivers/sound/mmixe... ============================================================================== --- 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] Fri Oct 21 21:26:12 2016 @@ -1269,6 +1269,110 @@ }
MIXER_STATUS +MMixerHandleTopologyFilter( + IN PMIXER_CONTEXT MixerContext, + IN PMIXER_LIST MixerList, + IN LPMIXER_DATA MixerData, + IN OUT LPMIXER_INFO MixerInfo, + IN ULONG bInput, + IN ULONG Pin) +{ + MIXER_STATUS Status; + ULONG PinsCount, LineTerminator, DestinationLineID; + PULONG Pins; + PTOPOLOGY Topology; + + /* re-use existing topology */ + Topology = MixerData->Topology; + + if (!bInput) + { + /* allocate pin index array which will hold all referenced pins */ + Status = MMixerAllocateTopologyPinArray(MixerContext, Topology, &Pins); + if (Status != MM_STATUS_SUCCESS) + { + /* failed to create topology */ + return Status; + } + + /* the mixer is an output mixer + * find end pin of the node path + */ + PinsCount = 0; + Status = MMixerGetAllUpOrDownstreamPinsFromPinIndex(MixerContext, Topology, Pin, FALSE, &PinsCount, Pins); + + /* check for success */ + if (Status != MM_STATUS_SUCCESS) + { + /* failed to get end pin */ + MixerContext->Free(Pins); + //MMixerFreeTopology(Topology); + + /* return error code */ + return Status; + } + /* HACK: + * some topologies do not have strict boundaries + * WorkArround: remove all pin ids which have a physical connection + * because bridge pins may belong to different render paths + */ + MMixerApplyOutputFilterHack(MixerContext, MixerData, MixerData->hDevice, &PinsCount, Pins); + + /* sanity checks */ + ASSERT(PinsCount != 0); + if (PinsCount != 1) + { + DPRINT1("MMixerHandlePhysicalConnection Expected 1 pin but got %lu\n", PinsCount); + } + + /* create destination line */ + Status = MMixerBuildMixerDestinationLine(MixerContext, MixerInfo, MixerData->hDevice, Pins[0], bInput); + + /* calculate destination line id */ + DestinationLineID = (DESTINATION_LINE + MixerInfo->MixCaps.cDestinations - 1); + + if (Status != MM_STATUS_SUCCESS) + { + /* failed to build destination line */ + MixerContext->Free(Pins); + + /* return error code */ + return Status; + } + + /* add mixer controls to destination line */ + Status = MMixerAddMixerControlsToDestinationLine(MixerContext, MixerInfo, MixerData->hDevice, Topology, Pins[0], bInput, DestinationLineID, &LineTerminator); + + if (Status == MM_STATUS_SUCCESS) + { + /* now add the rest of the source lines */ + Status = MMixerAddMixerSourceLines(MixerContext, MixerInfo, MixerData->hDevice, Topology, DestinationLineID, LineTerminator); + } + + /* mark pin as consumed */ + MMixerSetTopologyPinReserved(Topology, Pins[0]); + + /* free topology pin array */ + MixerContext->Free(Pins); + } + else + { + /* calculate destination line id */ + DestinationLineID = (DESTINATION_LINE + MixerInfo->MixCaps.cDestinations - 1); + + /* add mixer controls */ + Status = MMixerAddMixerControlsToDestinationLine(MixerContext, MixerInfo, MixerData->hDevice, Topology, Pin, bInput, DestinationLineID, &LineTerminator); + + if (Status == MM_STATUS_SUCCESS) + { + /* now add the rest of the source lines */ + Status = MMixerAddMixerSourceLines(MixerContext, MixerInfo, MixerData->hDevice, Topology, DestinationLineID, LineTerminator); + } + } + return Status; +} + +MIXER_STATUS MMixerHandlePhysicalConnection( IN PMIXER_CONTEXT MixerContext, IN PMIXER_LIST MixerList, @@ -1450,7 +1554,12 @@ MixerInfo->MixCaps.cDestinations = 0;
/* get mixer name */ - MMixerGetDeviceName(MixerContext, MixerInfo->MixCaps.szPname, MixerData->hDeviceInterfaceKey); + Status = MMixerGetDeviceName(MixerContext, MixerInfo->MixCaps.szPname, MixerData->hDeviceInterfaceKey); + if (Status != MM_STATUS_SUCCESS) + { + /* try get name with component id */ + Status = MMixerGetDeviceNameWithComponentId(MixerContext, MixerData->hDevice, MixerInfo->MixCaps.szPname); + }
/* initialize line list */ InitializeListHead(&MixerInfo->LineList); @@ -1546,10 +1655,8 @@ } else { - /* FIXME - * handle drivers which expose their topology on the same filter - */ - ASSERT(0); + /* topology is on the same filter */ + Status = MMixerHandleTopologyFilter(MixerContext, MixerList, MixerData, MixerInfo, bInputMixer, Pins[0]); }
/* free pins */
Modified: trunk/reactos/sdk/lib/drivers/sound/mmixer/precomp.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/drivers/sound/mmixe... ============================================================================== --- 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] Fri Oct 21 21:26:12 2016 @@ -359,6 +359,12 @@ OUT LPWSTR DeviceName, IN HANDLE hKey);
+MIXER_STATUS +MMixerGetDeviceNameWithComponentId( + IN PMIXER_CONTEXT MixerContext, + IN HANDLE hMixer, + OUT LPWSTR DeviceName); + VOID MMixerInitializePinConnect( IN OUT PKSPIN_CONNECT PinConnect,
Modified: trunk/reactos/sdk/lib/drivers/sound/mmixer/sup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/drivers/sound/mmixe... ============================================================================== --- trunk/reactos/sdk/lib/drivers/sound/mmixer/sup.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/drivers/sound/mmixer/sup.c [iso-8859-1] Fri Oct 21 21:26:12 2016 @@ -802,6 +802,53 @@ }
MIXER_STATUS +MMixerGetDeviceNameWithComponentId( + IN PMIXER_CONTEXT MixerContext, + IN HANDLE hMixer, + OUT LPWSTR OutDeviceName) +{ + MIXER_STATUS Status; + KSPROPERTY Property; + KSCOMPONENTID ComponentId; + ULONG Length; + UNICODE_STRING GuidString; + ULONG ResultLength, KeyType; + HANDLE hMediaKey, hGuidKey; + LPWSTR DeviceName; + + /* prepare property */ + Property.Flags = KSPROPERTY_TYPE_GET; + Property.Set = KSPROPSETID_General; + Property.Id = KSPROPERTY_GENERAL_COMPONENTID; + + /* try get component id */ + Status = MixerContext->Control(hMixer, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), &ComponentId, sizeof(KSCOMPONENTID), &Length); + + if (Status == MM_STATUS_SUCCESS) + { + Status = MixerContext->OpenKey(NULL, L"\Registry\Machine\SYSTEM\CurrentControlSet\Control\MediaCategories", KEY_READ, &hMediaKey); + if (Status == MM_STATUS_SUCCESS) + { + RtlStringFromGUID(&ComponentId.Name, &GuidString); + Status = MixerContext->OpenKey(hMediaKey, GuidString.Buffer, KEY_READ, &hGuidKey); + RtlFreeUnicodeString(&GuidString); + if (Status == MM_STATUS_SUCCESS) + { + Status = MixerContext->QueryKeyValue(hGuidKey, L"Name", (PVOID*)&DeviceName, &ResultLength, &KeyType); + if (Status == MM_STATUS_SUCCESS) + { + MixerContext->Copy(OutDeviceName, DeviceName, min(ResultLength, (MAXPNAMELEN-1)*2)); + } + + MixerContext->CloseKey(hGuidKey); + } + MixerContext->CloseKey(hMediaKey); + } + } + return Status; +} + +MIXER_STATUS MMixerGetDeviceName( IN PMIXER_CONTEXT MixerContext, OUT LPWSTR DeviceName,