mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 22:56:00 +00:00
[MMIXER]
- Store MixerList in MixerContext member - Fix a lot of bugs - MMixer is now able to enumerate mixers and their associated controls svn path=/trunk/; revision=44522
This commit is contained in:
parent
e60dc4ed94
commit
3953b7855d
4 changed files with 56 additions and 35 deletions
|
@ -413,7 +413,10 @@ MMixerAddMixerSourceLine(
|
||||||
for(Index = 0; Index < NodeTypes->Count; Index++)
|
for(Index = 0; Index < NodeTypes->Count; Index++)
|
||||||
{
|
{
|
||||||
if (Nodes[Index])
|
if (Nodes[Index])
|
||||||
|
{
|
||||||
|
// found a node
|
||||||
ControlCount++;
|
ControlCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now allocate the line controls */
|
/* now allocate the line controls */
|
||||||
|
@ -458,7 +461,7 @@ MMixerAddMixerSourceLine(
|
||||||
SrcLine->NodeIds[ControlCount] = Index;
|
SrcLine->NodeIds[ControlCount] = Index;
|
||||||
|
|
||||||
Status = MMixerAddMixerControl(MixerContext, MixerInfo, hDevice, NodeTypes, Index, SrcLine, &SrcLine->LineControls[ControlCount]);
|
Status = MMixerAddMixerControl(MixerContext, MixerInfo, hDevice, NodeTypes, Index, SrcLine, &SrcLine->LineControls[ControlCount]);
|
||||||
if (Status != MM_STATUS_SUCCESS)
|
if (Status == MM_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
/* increment control count on success */
|
/* increment control count on success */
|
||||||
ControlCount++;
|
ControlCount++;
|
||||||
|
@ -497,12 +500,7 @@ MMixerAddMixerSourceLine(
|
||||||
/* try get pin name size */
|
/* try get pin name size */
|
||||||
Status = MixerContext->Control(hDevice, IOCTL_KS_PROPERTY, (PVOID)&Pin, sizeof(KSP_PIN), NULL, 0, &BytesReturned);
|
Status = MixerContext->Control(hDevice, IOCTL_KS_PROPERTY, (PVOID)&Pin, sizeof(KSP_PIN), NULL, 0, &BytesReturned);
|
||||||
|
|
||||||
if (Status != STATUS_MORE_ENTRIES)
|
if (Status == MM_STATUS_MORE_ENTRIES)
|
||||||
{
|
|
||||||
SrcLine->Line.szShortName[0] = L'\0';
|
|
||||||
SrcLine->Line.szName[0] = L'\0';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
PinName = (LPWSTR)MixerContext->Alloc(BytesReturned);
|
PinName = (LPWSTR)MixerContext->Alloc(BytesReturned);
|
||||||
if (PinName)
|
if (PinName)
|
||||||
|
@ -510,7 +508,7 @@ MMixerAddMixerSourceLine(
|
||||||
/* try get pin name */
|
/* try get pin name */
|
||||||
Status = MixerContext->Control(hDevice, IOCTL_KS_PROPERTY, (PVOID)&Pin, sizeof(KSP_PIN), (LPVOID)PinName, BytesReturned, &BytesReturned);
|
Status = MixerContext->Control(hDevice, IOCTL_KS_PROPERTY, (PVOID)&Pin, sizeof(KSP_PIN), (LPVOID)PinName, BytesReturned, &BytesReturned);
|
||||||
|
|
||||||
if (Status != MM_STATUS_SUCCESS)
|
if (Status == MM_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
MixerContext->Copy(SrcLine->Line.szShortName, PinName, (min(MIXER_SHORT_NAME_CHARS, wcslen(PinName)+1)) * sizeof(WCHAR));
|
MixerContext->Copy(SrcLine->Line.szShortName, PinName, (min(MIXER_SHORT_NAME_CHARS, wcslen(PinName)+1)) * sizeof(WCHAR));
|
||||||
SrcLine->Line.szShortName[MIXER_SHORT_NAME_CHARS-1] = L'\0';
|
SrcLine->Line.szShortName[MIXER_SHORT_NAME_CHARS-1] = L'\0';
|
||||||
|
@ -625,6 +623,7 @@ MMixerAddMixerSourceLines(
|
||||||
|
|
||||||
for(Index = PinsCount; Index > 0; Index--)
|
for(Index = PinsCount; Index > 0; Index--)
|
||||||
{
|
{
|
||||||
|
DPRINT("MMixerAddMixerSourceLines Index %lu Pin %lu\n", Index-1, Pins[Index-1]);
|
||||||
if (Pins[Index-1])
|
if (Pins[Index-1])
|
||||||
{
|
{
|
||||||
MMixerAddMixerSourceLine(MixerContext, MixerInfo, hDevice, NodeConnections, NodeTypes, Index-1, (Index -1 == BridgePinIndex), (Index -1 == TargetPinIndex));
|
MMixerAddMixerSourceLine(MixerContext, MixerInfo, hDevice, NodeConnections, NodeTypes, Index-1, (Index -1 == BridgePinIndex), (Index -1 == TargetPinIndex));
|
||||||
|
@ -645,7 +644,6 @@ MMixerHandlePhysicalConnection(
|
||||||
ULONG PinsRefCount, Index, PinConnectionIndexCount;
|
ULONG PinsRefCount, Index, PinConnectionIndexCount;
|
||||||
MIXER_STATUS Status;
|
MIXER_STATUS Status;
|
||||||
HANDLE hDevice = NULL;
|
HANDLE hDevice = NULL;
|
||||||
PFILE_OBJECT FileObject = NULL;
|
|
||||||
PKSMULTIPLE_ITEM NodeTypes = NULL;
|
PKSMULTIPLE_ITEM NodeTypes = NULL;
|
||||||
PKSMULTIPLE_ITEM NodeConnections = NULL;
|
PKSMULTIPLE_ITEM NodeConnections = NULL;
|
||||||
PULONG MixerControls;
|
PULONG MixerControls;
|
||||||
|
@ -656,7 +654,7 @@ MMixerHandlePhysicalConnection(
|
||||||
Status = MixerContext->Open(OutConnection->SymbolicLinkName, &hDevice);
|
Status = MixerContext->Open(OutConnection->SymbolicLinkName, &hDevice);
|
||||||
if (Status != MM_STATUS_SUCCESS)
|
if (Status != MM_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
DPRINT1("OpenDevice failed with %x\n", Status);
|
DPRINT("OpenDevice failed with %x\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,7 +689,7 @@ MMixerHandlePhysicalConnection(
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
// gets connection index of the bridge pin which connects to a node
|
// gets connection index of the bridge pin which connects to a node
|
||||||
DPRINT("Pin %u\n", OutConnection->Pin);
|
DPRINT("Pin %lu\n", OutConnection->Pin);
|
||||||
|
|
||||||
Status = MMixerGetNodeIndexes(MixerContext, NodeConnections, OutConnection->Pin, FALSE, !bInput, &PinConnectionIndexCount, &PinConnectionIndex);
|
Status = MMixerGetNodeIndexes(MixerContext, NodeConnections, OutConnection->Pin, FALSE, !bInput, &PinConnectionIndexCount, &PinConnectionIndex);
|
||||||
if (Status != MM_STATUS_SUCCESS)
|
if (Status != MM_STATUS_SUCCESS)
|
||||||
|
@ -720,12 +718,16 @@ MMixerHandlePhysicalConnection(
|
||||||
|
|
||||||
for(Index = 0; Index < PinsRefCount; Index++)
|
for(Index = 0; Index < PinsRefCount; Index++)
|
||||||
{
|
{
|
||||||
|
DPRINT("PinsRefCount %lu Index %lu Value %lu\n", PinsRefCount, Index, PinsRef[Index]);
|
||||||
if (PinsRef[Index])
|
if (PinsRef[Index])
|
||||||
{
|
{
|
||||||
// found a target pin, now get all references
|
// found a target pin, now get all references
|
||||||
Status = MMixerGetNodeIndexes(MixerContext, NodeConnections, Index, FALSE, FALSE, &MixerControlsCount, &MixerControls);
|
Status = MMixerGetNodeIndexes(MixerContext, NodeConnections, Index, FALSE, FALSE, &MixerControlsCount, &MixerControls);
|
||||||
if (Status != MM_STATUS_SUCCESS)
|
if (Status != MM_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
DPRINT("MMixerGetNodeIndexes failed with %u\n", Status);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
ASSERT(MixerControlsCount == 1);
|
ASSERT(MixerControlsCount == 1);
|
||||||
|
@ -767,7 +769,7 @@ MMixerHandlePhysicalConnection(
|
||||||
}
|
}
|
||||||
PinsSrcRef[OutConnection->Pin] = TRUE;
|
PinsSrcRef[OutConnection->Pin] = TRUE;
|
||||||
|
|
||||||
Status = MMixerAddMixerSourceLines(MixerContext, MixerInfo, FileObject, NodeConnections, NodeTypes, PinsRefCount, OutConnection->Pin, Index, PinsSrcRef);
|
Status = MMixerAddMixerSourceLines(MixerContext, MixerInfo, hDevice, NodeConnections, NodeTypes, PinsRefCount, OutConnection->Pin, Index, PinsSrcRef);
|
||||||
|
|
||||||
MixerContext->Free(MixerControls);
|
MixerContext->Free(MixerControls);
|
||||||
MixerContext->Free(PinsSrcRef);
|
MixerContext->Free(PinsSrcRef);
|
||||||
|
@ -795,6 +797,7 @@ MMixerInitializeFilter(
|
||||||
PKSPIN_PHYSICALCONNECTION OutConnection;
|
PKSPIN_PHYSICALCONNECTION OutConnection;
|
||||||
ULONG Index;
|
ULONG Index;
|
||||||
ULONG * Pins;
|
ULONG * Pins;
|
||||||
|
ULONG bUsed;
|
||||||
|
|
||||||
// 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));
|
||||||
|
@ -845,31 +848,47 @@ MMixerInitializeFilter(
|
||||||
// failed to locate target pins
|
// failed to locate target pins
|
||||||
MixerContext->Free(Pins);
|
MixerContext->Free(Pins);
|
||||||
MMixerFreeMixerInfo(MixerContext, MixerInfo);
|
MMixerFreeMixerInfo(MixerContext, MixerInfo);
|
||||||
|
DPRINT("MMixerGetTargetPins failed with %u\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// filter hasnt been used
|
||||||
|
bUsed = FALSE;
|
||||||
|
|
||||||
// now check all pins and generate new lines for destination lines
|
// now check all pins and generate new lines for destination lines
|
||||||
for(Index = 0; Index < PinCount; Index++)
|
for(Index = 0; Index < PinCount; Index++)
|
||||||
{
|
{
|
||||||
|
DPRINT("Index %lu TargetPin %lu\n", Index, Pins[Index]);
|
||||||
// is the current index a target pin
|
// is the current index a target pin
|
||||||
if (Pins[Index])
|
if (Pins[Index])
|
||||||
{
|
{
|
||||||
// check if the pin has a physical connection
|
// check if the pin has a physical connection
|
||||||
Status = MMixerGetPhysicalConnection(MixerContext, hMixer, Index, &OutConnection);
|
Status = MMixerGetPhysicalConnection(MixerContext, hMixer, Index, &OutConnection);
|
||||||
if (Status != MM_STATUS_SUCCESS)
|
if (Status == MM_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
// the pin has a physical connection
|
// the pin has a physical connection
|
||||||
Status = MMixerHandlePhysicalConnection(MixerContext, MixerInfo, bInputMixer, OutConnection);
|
Status = MMixerHandlePhysicalConnection(MixerContext, MixerInfo, bInputMixer, OutConnection);
|
||||||
|
DPRINT("MMixerHandlePhysicalConnection status %u\n", Status);
|
||||||
MixerContext->Free(OutConnection);
|
MixerContext->Free(OutConnection);
|
||||||
|
bUsed = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MixerContext->Free(Pins);
|
MixerContext->Free(Pins);
|
||||||
|
|
||||||
// store mixer info in list
|
if (bUsed)
|
||||||
InsertTailList(&MixerList->MixerList, &MixerInfo->Entry);
|
{
|
||||||
MixerList->MixerListCount++;
|
// store mixer info in list
|
||||||
|
InsertTailList(&MixerList->MixerList, &MixerInfo->Entry);
|
||||||
|
MixerList->MixerListCount++;
|
||||||
|
DPRINT("New MixerCount %lu\n", MixerList->MixerListCount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
// filter exposes its topology on the same filter
|
||||||
|
MMixerFreeMixerInfo(MixerContext, MixerInfo);
|
||||||
|
}
|
||||||
|
|
||||||
// done
|
// done
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -891,7 +910,7 @@ MMixerSetupFilter(
|
||||||
// get number of pins
|
// get number of pins
|
||||||
PinCount = MMixerGetFilterPinCount(MixerContext, hMixer);
|
PinCount = MMixerGetFilterPinCount(MixerContext, hMixer);
|
||||||
ASSERT(PinCount);
|
ASSERT(PinCount);
|
||||||
|
DPRINT("NumOfPins: %lu\n", PinCount);
|
||||||
|
|
||||||
// get filter node types
|
// get filter node types
|
||||||
Status = MMixerGetFilterTopologyProperty(MixerContext, hMixer, KSPROPERTY_TOPOLOGY_NODES, &NodeTypes);
|
Status = MMixerGetFilterTopologyProperty(MixerContext, hMixer, KSPROPERTY_TOPOLOGY_NODES, &NodeTypes);
|
||||||
|
@ -915,8 +934,9 @@ 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);
|
||||||
// check for success
|
// check for success
|
||||||
if (Status == MM_STATUS_SUCCESS)
|
if (Status == MM_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -932,7 +952,7 @@ MMixerSetupFilter(
|
||||||
{
|
{
|
||||||
// it has
|
// it has
|
||||||
Status = MMixerInitializeFilter(MixerContext, MixerList, hMixer, DeviceName, NodeTypes, NodeConnections, PinCount, NodeIndex, TRUE);
|
Status = MMixerInitializeFilter(MixerContext, MixerList, hMixer, DeviceName, NodeTypes, NodeConnections, PinCount, NodeIndex, TRUE);
|
||||||
|
DPRINT("MMixerInitializeFilter Status %u\n", Status);
|
||||||
// check for success
|
// check for success
|
||||||
if (Status == MM_STATUS_SUCCESS)
|
if (Status == MM_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -109,7 +109,7 @@ MMixerGetPhysicalConnection(
|
||||||
// pin does not have a physical connection
|
// pin does not have a physical connection
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
DPRINT("Status %u BytesReturned %lu\n", Status, BytesReturned);
|
||||||
Connection = (PKSPIN_PHYSICALCONNECTION)MixerContext->Alloc(BytesReturned);
|
Connection = (PKSPIN_PHYSICALCONNECTION)MixerContext->Alloc(BytesReturned);
|
||||||
if (!Connection)
|
if (!Connection)
|
||||||
{
|
{
|
||||||
|
@ -123,6 +123,7 @@ MMixerGetPhysicalConnection(
|
||||||
{
|
{
|
||||||
// failed to query the physical connection
|
// failed to query the physical connection
|
||||||
MixerContext->Free(Connection);
|
MixerContext->Free(Connection);
|
||||||
|
DPRINT("Status %u\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -438,10 +438,15 @@ MMixerInitialize(
|
||||||
MixerList->MixerListCount = 0;
|
MixerList->MixerListCount = 0;
|
||||||
InitializeListHead(&MixerList->MixerList);
|
InitializeListHead(&MixerList->MixerList);
|
||||||
|
|
||||||
|
// store mixer list
|
||||||
|
MixerContext->MixerContext = (PVOID)MixerList;
|
||||||
|
|
||||||
// start enumerating all available devices
|
// start enumerating all available devices
|
||||||
Count = 0;
|
Count = 0;
|
||||||
DeviceIndex = 0;
|
DeviceIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// enumerate a device
|
// enumerate a device
|
||||||
|
@ -450,26 +455,21 @@ MMixerInitialize(
|
||||||
if (Status != MM_STATUS_SUCCESS)
|
if (Status != MM_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
//check error code
|
//check error code
|
||||||
if (Status != MM_STATUS_NO_MORE_DEVICES)
|
if (Status == MM_STATUS_NO_MORE_DEVICES)
|
||||||
{
|
{
|
||||||
// enumeration has failed
|
// enumeration has finished
|
||||||
return Status;
|
break;
|
||||||
}
|
}
|
||||||
// last device
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MMixerSetupFilter(MixerContext, MixerList, hMixer, &Count, DeviceName);
|
||||||
|
}
|
||||||
|
|
||||||
// increment device index
|
// increment device index
|
||||||
DeviceIndex++;
|
DeviceIndex++;
|
||||||
|
|
||||||
Status = MMixerSetupFilter(MixerContext, MixerList, hMixer, &Count, DeviceName);
|
|
||||||
|
|
||||||
if (Status != MM_STATUS_SUCCESS)
|
|
||||||
break;
|
|
||||||
|
|
||||||
}while(TRUE);
|
}while(TRUE);
|
||||||
|
|
||||||
// done
|
// done
|
||||||
return Status;
|
return MM_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ typedef MIXER_STATUS(*PMIXER_DEVICE_CONTROL)(
|
||||||
PULONG lpBytesReturned);
|
PULONG lpBytesReturned);
|
||||||
|
|
||||||
typedef MIXER_STATUS(*PMIXER_OPEN)(
|
typedef MIXER_STATUS(*PMIXER_OPEN)(
|
||||||
IN LPCWSTR DevicePath,
|
IN LPWSTR DevicePath,
|
||||||
OUT PHANDLE hDevice);
|
OUT PHANDLE hDevice);
|
||||||
|
|
||||||
typedef MIXER_STATUS(*PMIXER_CLOSE)(
|
typedef MIXER_STATUS(*PMIXER_CLOSE)(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue