return Status;
}
+ULONG
+GetDeviceIndexFromPnpName(
+ IN PDEVICE_OBJECT DeviceObject,
+ LPWSTR Device)
+{
+ ULONG Count, Index;
+ LPWSTR DeviceName;
+ NTSTATUS Status;
+
+ /* get device count */
+ Count = GetSysAudioDeviceCount(DeviceObject);
+
+ if (!Count)
+ return MAXULONG;
+
+ for(Index = 0; Index < Count; Index++)
+ {
+ /* get device name */
+ Status = GetSysAudioDevicePnpName(DeviceObject, Index, &DeviceName);
+ if (NT_SUCCESS(Status))
+ {
+ if (!wcsicmp(Device, DeviceName))
+ {
+ /* found device index */
+ ExFreePool(DeviceName);
+ return Index;
+ }
+ ExFreePool(DeviceName);
+ }
+ }
+
+ return MAXULONG;
+}
+
+
NTSTATUS
OpenDevice(
IN LPWSTR Device,
/* first count all referenced nodes */
for(Index = 0; Index < MultipleItem->Count; Index++)
{
- //DPRINT1("FromPin %u FromNode %u ToPin %u ToNode %u\n", Connection->FromNodePin, Connection->FromNode, Connection->ToNodePin, Connection->ToNode);
+ //DbgPrint("FromPin %u FromNode %u ToPin %u ToNode %u\n", Connection->FromNodePin, Connection->FromNode, Connection->ToNodePin, Connection->ToNode);
if (bNode)
{
if (bFrom)
{
if (bFrom)
{
- if (Connection->FromNodePin == NodeIndex)
+ if (Connection->FromNodePin == NodeIndex && Connection->FromNode == KSFILTER_NODE)
{
/* node id has a connection */
Count++;
}
else
{
- if (Connection->ToNodePin == NodeIndex)
+ if (Connection->ToNodePin == NodeIndex && Connection->ToNode == KSFILTER_NODE)
{
/* node id has a connection */
Count++;
return STATUS_INSUFFICIENT_RESOURCES;
}
+ /* clear node index array */
+ RtlZeroMemory(Refs, Count * sizeof(ULONG));
+
Count = 0;
Connection = (PKSTOPOLOGY_CONNECTION)(MultipleItem + 1);
for(Index = 0; Index < MultipleItem->Count; Index++)
{
if (bFrom)
{
- if (Connection->FromNodePin == NodeIndex)
+ if (Connection->FromNodePin == NodeIndex && Connection->FromNode == KSFILTER_NODE)
{
/* node id has a connection */
Refs[Count] = Index;
}
else
{
- if (Connection->ToNodePin == NodeIndex)
+ if (Connection->ToNodePin == NodeIndex && Connection->ToNode == KSFILTER_NODE)
{
/* node id has a connection */
Refs[Count] = Index;
AddMixerSourceLine(
IN OUT LPMIXER_INFO MixerInfo,
IN PFILE_OBJECT FileObject,
+ IN ULONG DeviceIndex,
IN ULONG PinId)
{
LPMIXERLINE_EXT SrcLine, DstLine;
RtlZeroMemory(SrcLine, sizeof(MIXERLINE_EXT));
/* initialize mixer src line */
- SrcLine->FileObject = FileObject;
+ SrcLine->DeviceIndex = DeviceIndex;
SrcLine->PinId = PinId;
SrcLine->Line.cbStruct = sizeof(MIXERLINEW);
AddMixerSourceLines(
IN OUT LPMIXER_INFO MixerInfo,
IN PFILE_OBJECT FileObject,
+ IN ULONG DeviceIndex,
IN ULONG PinsCount,
IN PULONG Pins)
{
{
if (Pins[Index-1])
{
- AddMixerSourceLine(MixerInfo, FileObject, Index-1);
+ AddMixerSourceLine(MixerInfo, FileObject, DeviceIndex, Index-1);
}
}
return Status;
NTSTATUS
HandlePhysicalConnection(
IN OUT LPMIXER_INFO MixerInfo,
+ IN PDEVICE_OBJECT DeviceObject,
IN ULONG bInput,
IN PKSPIN_PHYSICALCONNECTION OutConnection)
{
PULONG PinsRef = NULL, PinConnectionIndex = NULL, PinsSrcRef;
- ULONG PinsRefCount, Index, PinConnectionIndexCount;
+ ULONG PinsRefCount, Index, PinConnectionIndexCount, DeviceIndex;
NTSTATUS Status;
HANDLE hDevice = NULL;
PFILE_OBJECT FileObject = NULL;
return Status;
}
+ /* get device index */
+ DeviceIndex = GetDeviceIndexFromPnpName(DeviceObject, OutConnection->SymbolicLinkName);
+
/* get connected filter pin count */
PinsRefCount = GetPinCount(FileObject);
ASSERT(PinsRefCount);
PinsSrcRef[OutConnection->Pin] = TRUE;
}
- Status = AddMixerSourceLines(MixerInfo, FileObject, PinsRefCount, PinsSrcRef);
+ Status = AddMixerSourceLines(MixerInfo, FileObject, DeviceIndex, PinsRefCount, PinsSrcRef);
ExFreePool(MixerControls);
ExFreePool(PinsSrcRef);
Status = GetPhysicalConnection(FileObject, Index, &OutConnection);
if (NT_SUCCESS(Status))
{
- Status = HandlePhysicalConnection(MixerInfo, bInput, OutConnection);
+ Status = HandlePhysicalConnection(MixerInfo, DeviceObject, bInput, OutConnection);
+ ExFreePool(OutConnection);
}
}
}
HANDLE hDevice;
PFILE_OBJECT FileObject;
PKSMULTIPLE_ITEM NodeTypes, NodeConnections;
- BOOL bCloseHandle;
PWDMAUD_DEVICE_EXTENSION DeviceExtension;
/* get device extension */
/* get num of pins */
PinCount = GetPinCount(FileObject);
- bCloseHandle = TRUE;
/* get the first available dac node index */
NodeIndex = GetNodeTypeIndex(NodeTypes, (LPGUID)&KSNODETYPE_DAC);
if (NodeIndex != (ULONG)-1)
{
/* increment mixer offset */
Count++;
- bCloseHandle = FALSE;
}
}
{
/* increment mixer offset */
Count++;
- bCloseHandle = FALSE;
}
}
ExFreePool(NodeTypes);
ExFreePool(NodeConnections);
- if (bCloseHandle)
- {
- /* close virtual audio device */
- ObDereferenceObject(FileObject);
- ZwClose(hDevice);
- }
+ /* close virtual audio device */
+ ObDereferenceObject(FileObject);
+ ZwClose(hDevice);
+
}
/* increment virtual audio device index */
Index++;