mirror of
https://github.com/reactos/reactos.git
synced 2024-08-01 09:01:13 +00:00
- Several bugfixes for mixer source / destination line detection code
- Fix a memory leak svn path=/trunk/; revision=43242
This commit is contained in:
parent
b3e77ecf83
commit
17c528d7c3
|
@ -166,6 +166,41 @@ GetSysAudioDevicePnpName(
|
||||||
return Status;
|
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
|
NTSTATUS
|
||||||
OpenDevice(
|
OpenDevice(
|
||||||
IN LPWSTR Device,
|
IN LPWSTR Device,
|
||||||
|
@ -453,7 +488,7 @@ GetNodeIndexes(
|
||||||
/* first count all referenced nodes */
|
/* first count all referenced nodes */
|
||||||
for(Index = 0; Index < MultipleItem->Count; Index++)
|
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 (bNode)
|
||||||
{
|
{
|
||||||
if (bFrom)
|
if (bFrom)
|
||||||
|
@ -477,7 +512,7 @@ GetNodeIndexes(
|
||||||
{
|
{
|
||||||
if (bFrom)
|
if (bFrom)
|
||||||
{
|
{
|
||||||
if (Connection->FromNodePin == NodeIndex)
|
if (Connection->FromNodePin == NodeIndex && Connection->FromNode == KSFILTER_NODE)
|
||||||
{
|
{
|
||||||
/* node id has a connection */
|
/* node id has a connection */
|
||||||
Count++;
|
Count++;
|
||||||
|
@ -485,7 +520,7 @@ GetNodeIndexes(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Connection->ToNodePin == NodeIndex)
|
if (Connection->ToNodePin == NodeIndex && Connection->ToNode == KSFILTER_NODE)
|
||||||
{
|
{
|
||||||
/* node id has a connection */
|
/* node id has a connection */
|
||||||
Count++;
|
Count++;
|
||||||
|
@ -508,6 +543,9 @@ GetNodeIndexes(
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* clear node index array */
|
||||||
|
RtlZeroMemory(Refs, Count * sizeof(ULONG));
|
||||||
|
|
||||||
Count = 0;
|
Count = 0;
|
||||||
Connection = (PKSTOPOLOGY_CONNECTION)(MultipleItem + 1);
|
Connection = (PKSTOPOLOGY_CONNECTION)(MultipleItem + 1);
|
||||||
for(Index = 0; Index < MultipleItem->Count; Index++)
|
for(Index = 0; Index < MultipleItem->Count; Index++)
|
||||||
|
@ -537,7 +575,7 @@ GetNodeIndexes(
|
||||||
{
|
{
|
||||||
if (bFrom)
|
if (bFrom)
|
||||||
{
|
{
|
||||||
if (Connection->FromNodePin == NodeIndex)
|
if (Connection->FromNodePin == NodeIndex && Connection->FromNode == KSFILTER_NODE)
|
||||||
{
|
{
|
||||||
/* node id has a connection */
|
/* node id has a connection */
|
||||||
Refs[Count] = Index;
|
Refs[Count] = Index;
|
||||||
|
@ -546,7 +584,7 @@ GetNodeIndexes(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Connection->ToNodePin == NodeIndex)
|
if (Connection->ToNodePin == NodeIndex && Connection->ToNode == KSFILTER_NODE)
|
||||||
{
|
{
|
||||||
/* node id has a connection */
|
/* node id has a connection */
|
||||||
Refs[Count] = Index;
|
Refs[Count] = Index;
|
||||||
|
@ -685,6 +723,7 @@ NTSTATUS
|
||||||
AddMixerSourceLine(
|
AddMixerSourceLine(
|
||||||
IN OUT LPMIXER_INFO MixerInfo,
|
IN OUT LPMIXER_INFO MixerInfo,
|
||||||
IN PFILE_OBJECT FileObject,
|
IN PFILE_OBJECT FileObject,
|
||||||
|
IN ULONG DeviceIndex,
|
||||||
IN ULONG PinId)
|
IN ULONG PinId)
|
||||||
{
|
{
|
||||||
LPMIXERLINE_EXT SrcLine, DstLine;
|
LPMIXERLINE_EXT SrcLine, DstLine;
|
||||||
|
@ -703,7 +742,7 @@ AddMixerSourceLine(
|
||||||
RtlZeroMemory(SrcLine, sizeof(MIXERLINE_EXT));
|
RtlZeroMemory(SrcLine, sizeof(MIXERLINE_EXT));
|
||||||
|
|
||||||
/* initialize mixer src line */
|
/* initialize mixer src line */
|
||||||
SrcLine->FileObject = FileObject;
|
SrcLine->DeviceIndex = DeviceIndex;
|
||||||
SrcLine->PinId = PinId;
|
SrcLine->PinId = PinId;
|
||||||
SrcLine->Line.cbStruct = sizeof(MIXERLINEW);
|
SrcLine->Line.cbStruct = sizeof(MIXERLINEW);
|
||||||
|
|
||||||
|
@ -812,6 +851,7 @@ NTSTATUS
|
||||||
AddMixerSourceLines(
|
AddMixerSourceLines(
|
||||||
IN OUT LPMIXER_INFO MixerInfo,
|
IN OUT LPMIXER_INFO MixerInfo,
|
||||||
IN PFILE_OBJECT FileObject,
|
IN PFILE_OBJECT FileObject,
|
||||||
|
IN ULONG DeviceIndex,
|
||||||
IN ULONG PinsCount,
|
IN ULONG PinsCount,
|
||||||
IN PULONG Pins)
|
IN PULONG Pins)
|
||||||
{
|
{
|
||||||
|
@ -822,7 +862,7 @@ AddMixerSourceLines(
|
||||||
{
|
{
|
||||||
if (Pins[Index-1])
|
if (Pins[Index-1])
|
||||||
{
|
{
|
||||||
AddMixerSourceLine(MixerInfo, FileObject, Index-1);
|
AddMixerSourceLine(MixerInfo, FileObject, DeviceIndex, Index-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -833,11 +873,12 @@ AddMixerSourceLines(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
HandlePhysicalConnection(
|
HandlePhysicalConnection(
|
||||||
IN OUT LPMIXER_INFO MixerInfo,
|
IN OUT LPMIXER_INFO MixerInfo,
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN ULONG bInput,
|
IN ULONG bInput,
|
||||||
IN PKSPIN_PHYSICALCONNECTION OutConnection)
|
IN PKSPIN_PHYSICALCONNECTION OutConnection)
|
||||||
{
|
{
|
||||||
PULONG PinsRef = NULL, PinConnectionIndex = NULL, PinsSrcRef;
|
PULONG PinsRef = NULL, PinConnectionIndex = NULL, PinsSrcRef;
|
||||||
ULONG PinsRefCount, Index, PinConnectionIndexCount;
|
ULONG PinsRefCount, Index, PinConnectionIndexCount, DeviceIndex;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
HANDLE hDevice = NULL;
|
HANDLE hDevice = NULL;
|
||||||
PFILE_OBJECT FileObject = NULL;
|
PFILE_OBJECT FileObject = NULL;
|
||||||
|
@ -855,6 +896,9 @@ HandlePhysicalConnection(
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get device index */
|
||||||
|
DeviceIndex = GetDeviceIndexFromPnpName(DeviceObject, OutConnection->SymbolicLinkName);
|
||||||
|
|
||||||
/* get connected filter pin count */
|
/* get connected filter pin count */
|
||||||
PinsRefCount = GetPinCount(FileObject);
|
PinsRefCount = GetPinCount(FileObject);
|
||||||
ASSERT(PinsRefCount);
|
ASSERT(PinsRefCount);
|
||||||
|
@ -943,7 +987,7 @@ HandlePhysicalConnection(
|
||||||
PinsSrcRef[OutConnection->Pin] = TRUE;
|
PinsSrcRef[OutConnection->Pin] = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = AddMixerSourceLines(MixerInfo, FileObject, PinsRefCount, PinsSrcRef);
|
Status = AddMixerSourceLines(MixerInfo, FileObject, DeviceIndex, PinsRefCount, PinsSrcRef);
|
||||||
|
|
||||||
ExFreePool(MixerControls);
|
ExFreePool(MixerControls);
|
||||||
ExFreePool(PinsSrcRef);
|
ExFreePool(PinsSrcRef);
|
||||||
|
@ -1075,7 +1119,8 @@ InitializeMixer(
|
||||||
Status = GetPhysicalConnection(FileObject, Index, &OutConnection);
|
Status = GetPhysicalConnection(FileObject, Index, &OutConnection);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
Status = HandlePhysicalConnection(MixerInfo, bInput, OutConnection);
|
Status = HandlePhysicalConnection(MixerInfo, DeviceObject, bInput, OutConnection);
|
||||||
|
ExFreePool(OutConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1093,7 +1138,6 @@ WdmAudMixerInitialize(
|
||||||
HANDLE hDevice;
|
HANDLE hDevice;
|
||||||
PFILE_OBJECT FileObject;
|
PFILE_OBJECT FileObject;
|
||||||
PKSMULTIPLE_ITEM NodeTypes, NodeConnections;
|
PKSMULTIPLE_ITEM NodeTypes, NodeConnections;
|
||||||
BOOL bCloseHandle;
|
|
||||||
PWDMAUD_DEVICE_EXTENSION DeviceExtension;
|
PWDMAUD_DEVICE_EXTENSION DeviceExtension;
|
||||||
|
|
||||||
/* get device extension */
|
/* get device extension */
|
||||||
|
@ -1151,7 +1195,6 @@ WdmAudMixerInitialize(
|
||||||
|
|
||||||
/* get num of pins */
|
/* get num of pins */
|
||||||
PinCount = GetPinCount(FileObject);
|
PinCount = GetPinCount(FileObject);
|
||||||
bCloseHandle = TRUE;
|
|
||||||
/* get the first available dac node index */
|
/* get the first available dac node index */
|
||||||
NodeIndex = GetNodeTypeIndex(NodeTypes, (LPGUID)&KSNODETYPE_DAC);
|
NodeIndex = GetNodeTypeIndex(NodeTypes, (LPGUID)&KSNODETYPE_DAC);
|
||||||
if (NodeIndex != (ULONG)-1)
|
if (NodeIndex != (ULONG)-1)
|
||||||
|
@ -1161,7 +1204,6 @@ WdmAudMixerInitialize(
|
||||||
{
|
{
|
||||||
/* increment mixer offset */
|
/* increment mixer offset */
|
||||||
Count++;
|
Count++;
|
||||||
bCloseHandle = FALSE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1174,7 +1216,6 @@ WdmAudMixerInitialize(
|
||||||
{
|
{
|
||||||
/* increment mixer offset */
|
/* increment mixer offset */
|
||||||
Count++;
|
Count++;
|
||||||
bCloseHandle = FALSE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1182,12 +1223,10 @@ WdmAudMixerInitialize(
|
||||||
ExFreePool(NodeTypes);
|
ExFreePool(NodeTypes);
|
||||||
ExFreePool(NodeConnections);
|
ExFreePool(NodeConnections);
|
||||||
|
|
||||||
if (bCloseHandle)
|
/* close virtual audio device */
|
||||||
{
|
ObDereferenceObject(FileObject);
|
||||||
/* close virtual audio device */
|
ZwClose(hDevice);
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
ZwClose(hDevice);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* increment virtual audio device index */
|
/* increment virtual audio device index */
|
||||||
Index++;
|
Index++;
|
||||||
|
|
|
@ -37,7 +37,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
LIST_ENTRY Entry;
|
LIST_ENTRY Entry;
|
||||||
ULONG PinId;
|
ULONG PinId;
|
||||||
PFILE_OBJECT FileObject;
|
ULONG DeviceIndex;
|
||||||
MIXERLINEW Line;
|
MIXERLINEW Line;
|
||||||
LPMIXERCONTROLW LineControls;
|
LPMIXERCONTROLW LineControls;
|
||||||
}MIXERLINE_EXT, *LPMIXERLINE_EXT;
|
}MIXERLINE_EXT, *LPMIXERLINE_EXT;
|
||||||
|
|
Loading…
Reference in a new issue