- implement MMixerGetDeviceNameWithComponentId, which retrieves the device name via component id

- start implement MMixerHandleTopologyFilter, does not yet fully work

svn path=/trunk/; revision=73017
This commit is contained in:
Johannes Anderwald 2016-10-21 21:26:12 +00:00
parent a9a9930090
commit 3e7f31ebe1
3 changed files with 165 additions and 5 deletions

View file

@ -1268,6 +1268,110 @@ MMixerApplyOutputFilterHack(
*PinsCount = Count;
}
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,
@ -1450,7 +1554,12 @@ MMixerInitializeFilter(
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 @@ MMixerInitializeFilter(
}
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 */

View file

@ -359,6 +359,12 @@ MMixerGetDeviceName(
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,

View file

@ -801,6 +801,53 @@ MMixerCreateMixerData(
return MM_STATUS_SUCCESS;
}
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,