- Add mixerline for audio filters which expose their topology on the same filter such as usb audio cards
- Retrieve pin name of the target pin in order to display the correct name for the destination audio mixer line

svn path=/trunk/; revision=44538
This commit is contained in:
Johannes Anderwald 2009-12-11 14:01:39 +00:00
parent e7d4a5ccc7
commit c9c03a799f

View file

@ -534,7 +534,8 @@ MIXER_STATUS
MMixerCreateDestinationLine( MMixerCreateDestinationLine(
IN PMIXER_CONTEXT MixerContext, IN PMIXER_CONTEXT MixerContext,
IN LPMIXER_INFO MixerInfo, IN LPMIXER_INFO MixerInfo,
IN ULONG bInputMixer) IN ULONG bInputMixer,
IN LPWSTR LineName)
{ {
LPMIXERLINE_EXT DestinationLine; LPMIXERLINE_EXT DestinationLine;
@ -554,8 +555,19 @@ MMixerCreateDestinationLine(
DestinationLine->Line.dwUser = 0; DestinationLine->Line.dwUser = 0;
DestinationLine->Line.dwComponentType = (bInputMixer == 0 ? MIXERLINE_COMPONENTTYPE_DST_SPEAKERS : MIXERLINE_COMPONENTTYPE_DST_WAVEIN); DestinationLine->Line.dwComponentType = (bInputMixer == 0 ? MIXERLINE_COMPONENTTYPE_DST_SPEAKERS : MIXERLINE_COMPONENTTYPE_DST_WAVEIN);
DestinationLine->Line.cChannels = 2; //FIXME DestinationLine->Line.cChannels = 2; //FIXME
wcscpy(DestinationLine->Line.szShortName, L"Summe"); //FIXME
wcscpy(DestinationLine->Line.szName, L"Summe"); //FIXME if (LineName)
{
wcscpy(DestinationLine->Line.szShortName, LineName);
wcscpy(DestinationLine->Line.szName, LineName);
}
else
{
/* FIXME no name was found for pin */
wcscpy(DestinationLine->Line.szShortName, L"Summe");
wcscpy(DestinationLine->Line.szName, L"Summe");
}
DestinationLine->Line.Target.dwType = (bInputMixer == 0 ? MIXERLINE_TARGETTYPE_WAVEOUT : MIXERLINE_TARGETTYPE_WAVEIN); DestinationLine->Line.Target.dwType = (bInputMixer == 0 ? MIXERLINE_TARGETTYPE_WAVEOUT : MIXERLINE_TARGETTYPE_WAVEIN);
DestinationLine->Line.Target.dwDeviceID = !bInputMixer; DestinationLine->Line.Target.dwDeviceID = !bInputMixer;
DestinationLine->Line.Target.wMid = MixerInfo->MixCaps.wMid; DestinationLine->Line.Target.wMid = MixerInfo->MixCaps.wMid;
@ -798,6 +810,9 @@ MMixerInitializeFilter(
ULONG Index; ULONG Index;
ULONG * Pins; ULONG * Pins;
ULONG bUsed; ULONG bUsed;
ULONG BytesReturned;
KSP_PIN Pin;
LPWSTR Buffer = NULL;
// allocate a mixer info struct // allocate a mixer info struct
MixerInfo = (LPMIXER_INFO) MixerContext->Alloc(sizeof(MIXER_INFO)); MixerInfo = (LPMIXER_INFO) MixerContext->Alloc(sizeof(MIXER_INFO));
@ -820,15 +835,6 @@ MMixerInitializeFilter(
/* FIXME find mixer name */ /* FIXME find mixer name */
Status = MMixerCreateDestinationLine(MixerContext, MixerInfo, bInputMixer);
if (Status != MM_STATUS_SUCCESS)
{
// failed to create destination line
MixerContext->Free(MixerInfo);
return Status;
}
// now allocate an array which will receive the indices of the pin // now allocate an array which will receive the indices of the pin
// which has a ADC / DAC nodetype in its path // which has a ADC / DAC nodetype in its path
Pins = (PULONG)MixerContext->Alloc(PinCount * sizeof(ULONG)); Pins = (PULONG)MixerContext->Alloc(PinCount * sizeof(ULONG));
@ -840,6 +846,65 @@ MMixerInitializeFilter(
return MM_STATUS_NO_MEMORY; return MM_STATUS_NO_MEMORY;
} }
// now get the target pins of the ADC / DAC node
Status = MMixerGetTargetPins(MixerContext, NodeTypes, NodeConnections, NodeIndex, !bInputMixer, Pins, PinCount);
for(Index = 0; Index < PinCount; Index++)
{
if (Pins[Index])
{
/* retrieve pin name */
Pin.PinId = Index;
Pin.Reserved = 0;
Pin.Property.Flags = KSPROPERTY_TYPE_GET;
Pin.Property.Set = KSPROPSETID_Pin;
Pin.Property.Id = KSPROPERTY_PIN_NAME;
/* try get pin name size */
Status = MixerContext->Control(hMixer, IOCTL_KS_PROPERTY, (PVOID)&Pin, sizeof(KSP_PIN), NULL, 0, &BytesReturned);
if (Status == MM_STATUS_MORE_ENTRIES)
{
Buffer = (LPWSTR)MixerContext->Alloc(BytesReturned);
if (Buffer)
{
/* try get pin name */
Status = MixerContext->Control(hMixer, IOCTL_KS_PROPERTY, (PVOID)&Pin, sizeof(KSP_PIN), (PVOID)Buffer, BytesReturned, &BytesReturned);
if (Status != MM_STATUS_SUCCESS)
{
MixerContext->Free((PVOID)Buffer);
Buffer = NULL;
}
else
{
// found name, done
break;
}
}
}
}
}
Status = MMixerCreateDestinationLine(MixerContext, MixerInfo, bInputMixer, Buffer);
if (Buffer)
{
// free name
MixerContext->Free(Buffer);
}
if (Status != MM_STATUS_SUCCESS)
{
// failed to create destination line
MixerContext->Free(MixerInfo);
MixerContext->Free(Pins);
return Status;
}
RtlZeroMemory(Pins, sizeof(ULONG) * PinCount);
// now get the target pins of the ADC / DAC node // now get the target pins of the ADC / DAC node
Status = MMixerGetTargetPins(MixerContext, NodeTypes, NodeConnections, NodeIndex, bInputMixer, Pins, PinCount); Status = MMixerGetTargetPins(MixerContext, NodeTypes, NodeConnections, NodeIndex, bInputMixer, Pins, PinCount);
@ -872,6 +937,12 @@ MMixerInitializeFilter(
MixerContext->Free(OutConnection); MixerContext->Free(OutConnection);
bUsed = TRUE; bUsed = TRUE;
} }
else
{
// filter exposes the topology on the same filter
MMixerAddMixerSourceLine(MixerContext, MixerInfo, hMixer, NodeConnections, NodeTypes, Index, FALSE, FALSE);
bUsed = TRUE;
}
} }
} }
MixerContext->Free(Pins); MixerContext->Free(Pins);
@ -879,14 +950,22 @@ MMixerInitializeFilter(
if (bUsed) if (bUsed)
{ {
// store mixer info in list // store mixer info in list
if (!bInputMixer && MixerList->MixerListCount == 1)
{
//FIXME preferred device should be inserted at front
//windows always inserts output mixer in front
InsertHeadList(&MixerList->MixerList, &MixerInfo->Entry);
}
else
{
InsertTailList(&MixerList->MixerList, &MixerInfo->Entry); InsertTailList(&MixerList->MixerList, &MixerInfo->Entry);
}
MixerList->MixerListCount++; MixerList->MixerListCount++;
DPRINT("New MixerCount %lu\n", MixerList->MixerListCount); DPRINT("New MixerCount %lu\n", MixerList->MixerListCount);
} }
else else
{ {
// TODO: // failed to create a mixer topology
// filter exposes its topology on the same filter
MMixerFreeMixerInfo(MixerContext, MixerInfo); MMixerFreeMixerInfo(MixerContext, MixerInfo);
} }
@ -934,7 +1013,6 @@ MMixerSetupFilter(
if (NodeIndex != MAXULONG) if (NodeIndex != MAXULONG)
{ {
// it has // it has
Status = MMixerInitializeFilter(MixerContext, MixerList, hMixer, DeviceName, NodeTypes, NodeConnections, PinCount, NodeIndex, FALSE); Status = MMixerInitializeFilter(MixerContext, MixerList, hMixer, DeviceName, NodeTypes, NodeConnections, PinCount, NodeIndex, FALSE);
DPRINT("MMixerInitializeFilter Status %u\n", Status); DPRINT("MMixerInitializeFilter Status %u\n", Status);
// check for success // check for success