[AUDIO-BRINGUP]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Mon, 6 Dec 2010 16:00:06 +0000 (16:00 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Mon, 6 Dec 2010 16:00:06 +0000 (16:00 +0000)
- Implement support for retrieving mux mixer controls
- Implement support for on/off controls
- Store logical pins for nodes connecting to another nodes. Currently not yet used

svn path=/branches/audio-bringup/; revision=49965

lib/drivers/sound/mmixer/controls.c
lib/drivers/sound/mmixer/priv.h
lib/drivers/sound/mmixer/topology.c

index b94c59c..dfa2b53 100644 (file)
@@ -53,19 +53,7 @@ MMixerAddMixerControl(
     MixerControl->dwControlType = MMixerGetControlTypeFromTopologyNode(NodeType);
 
     MixerControl->fdwControl = MIXERCONTROL_CONTROLF_UNIFORM; /* FIXME */
     MixerControl->dwControlType = MMixerGetControlTypeFromTopologyNode(NodeType);
 
     MixerControl->fdwControl = MIXERCONTROL_CONTROLF_UNIFORM; /* FIXME */
-    MixerControl->cMultipleItems = 0; /* FIXME */
-
-    if (MixerControl->dwControlType == MIXERCONTROL_CONTROLTYPE_MUTE)
-    {
-        MixerControl->Bounds.dwMinimum = 0;
-        MixerControl->Bounds.dwMaximum = 1;
-    }
-    else if (MixerControl->dwControlType == MIXERCONTROL_CONTROLTYPE_VOLUME)
-    {
-        MixerControl->Bounds.dwMinimum = 0;
-        MixerControl->Bounds.dwMaximum = 0xFFFF;
-        MixerControl->Metrics.cSteps = 0xC0; /* FIXME */
-    }
+    MixerControl->cMultipleItems = 0;
 
     /* setup request to retrieve name */
     Node.NodeId = NodeIndex;
 
     /* setup request to retrieve name */
     Node.NodeId = NodeIndex;
@@ -104,28 +92,46 @@ MMixerAddMixerControl(
     }
 
     MixerInfo->ControlId++;
     }
 
     MixerInfo->ControlId++;
-#if 0
+
     if (MixerControl->dwControlType == MIXERCONTROL_CONTROLTYPE_MUX)
     {
     if (MixerControl->dwControlType == MIXERCONTROL_CONTROLTYPE_MUX)
     {
-        KSNODEPROPERTY Property;
-        ULONG PinId = 2;
+        ULONG NodesCount;
+        PULONG Nodes;
 
 
-        /* setup the request */
-        RtlZeroMemory(&Property, sizeof(KSNODEPROPERTY));
+        /* allocate topology nodes array */
+        Status = MMixerAllocateTopologyNodeArray(MixerContext, Topology, &Nodes);
 
 
-        Property.NodeId = NodeIndex;
-        Property.Property.Id = KSPROPERTY_AUDIO_MUX_SOURCE;
-        Property.Property.Flags = KSPROPERTY_TYPE_SET;
-        Property.Property.Set = KSPROPSETID_Audio;
+        if (Status != MM_STATUS_SUCCESS)
+        {
+            /* out of memory */
+            return STATUS_NO_MEMORY;
+        }
 
 
-        /* get node volume level info */
-        Status = MixerContext->Control(hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSNODEPROPERTY), (PVOID)&PinId, sizeof(ULONG), &BytesReturned);
+        /* get connected node count */
+        MMixerGetNextNodesFromNodeIndex(MixerContext, Topology, NodeIndex, TRUE, &NodesCount, Nodes);
 
 
-        DPRINT1("Status %x NodeIndex %u PinId %u\n", Status, NodeIndex, PinId);
-        //DbgBreakPoint();
-    }else
-#endif
-    if (MixerControl->dwControlType == MIXERCONTROL_CONTROLTYPE_VOLUME)
+        /* TODO */
+        MixerContext->Free(Nodes);
+
+        /* setup mux bounds */
+        MixerControl->Bounds.dwMinimum = 0;
+        MixerControl->Bounds.dwMaximum = NodesCount - 1;
+        MixerControl->Metrics.dwReserved[0] = NodesCount;
+        MixerControl->cMultipleItems = NodesCount;
+        MixerControl->fdwControl |= MIXERCONTROL_CONTROLF_MULTIPLE;
+    }
+    else if (MixerControl->dwControlType == MIXERCONTROL_CONTROLTYPE_MUTE)
+    {
+        MixerControl->Bounds.dwMinimum = 0;
+        MixerControl->Bounds.dwMaximum = 1;
+    }
+    else if (MixerControl->dwControlType == MIXERCONTROL_CONTROLTYPE_ONOFF)
+    {
+        /* only needs to set bounds */
+        MixerControl->Bounds.dwMinimum = 0;
+        MixerControl->Bounds.dwMaximum = 1;
+    }
+    else if (MixerControl->dwControlType == MIXERCONTROL_CONTROLTYPE_VOLUME)
     {
         KSNODEPROPERTY_AUDIO_CHANNEL Property;
         ULONG Length;
     {
         KSNODEPROPERTY_AUDIO_CHANNEL Property;
         ULONG Length;
@@ -133,6 +139,10 @@ MMixerAddMixerControl(
         PKSPROPERTY_MEMBERSHEADER Members;
         PKSPROPERTY_STEPPING_LONG Range;
 
         PKSPROPERTY_MEMBERSHEADER Members;
         PKSPROPERTY_STEPPING_LONG Range;
 
+        MixerControl->Bounds.dwMinimum = 0;
+        MixerControl->Bounds.dwMaximum = 0xFFFF;
+        MixerControl->Metrics.cSteps = 0xC0; /* FIXME */
+
         Length = sizeof(KSPROPERTY_DESCRIPTION) + sizeof(KSPROPERTY_MEMBERSHEADER) + sizeof(KSPROPERTY_STEPPING_LONG);
         Desc = (PKSPROPERTY_DESCRIPTION)MixerContext->Alloc(Length);
         ASSERT(Desc);
         Length = sizeof(KSPROPERTY_DESCRIPTION) + sizeof(KSPROPERTY_MEMBERSHEADER) + sizeof(KSPROPERTY_STEPPING_LONG);
         Desc = (PKSPROPERTY_DESCRIPTION)MixerContext->Alloc(Length);
         ASSERT(Desc);
@@ -142,7 +152,7 @@ MMixerAddMixerControl(
 
         Property.NodeProperty.NodeId = NodeIndex;
         Property.NodeProperty.Property.Id = KSPROPERTY_AUDIO_VOLUMELEVEL;
 
         Property.NodeProperty.NodeId = NodeIndex;
         Property.NodeProperty.Property.Id = KSPROPERTY_AUDIO_VOLUMELEVEL;
-        Property.NodeProperty.Property.Flags = KSPROPERTY_TYPE_BASICSUPPORT;
+        Property.NodeProperty.Property.Flags = KSPROPERTY_TYPE_BASICSUPPORT | KSPROPERTY_TYPE_TOPOLOGY;
         Property.NodeProperty.Property.Set = KSPROPSETID_Audio;
 
         /* get node volume level info */
         Property.NodeProperty.Property.Set = KSPROPSETID_Audio;
 
         /* get node volume level info */
index 07e7fa4..583499e 100644 (file)
@@ -27,6 +27,7 @@ typedef struct __TOPOLOGY_NODE__
 
     ULONG NodeConnectedFromCount;
     struct __TOPOLOGY_NODE__ ** NodeConnectedFrom;
 
     ULONG NodeConnectedFromCount;
     struct __TOPOLOGY_NODE__ ** NodeConnectedFrom;
+    PULONG LogicalPinNodeConnectedFrom;
 
     ULONG PinConnectedFromCount;
     PULONG PinConnectedFrom;
 
     ULONG PinConnectedFromCount;
     PULONG PinConnectedFrom;
@@ -54,6 +55,7 @@ typedef struct
     ULONG PinConnectedToCount;
     PULONG PinConnectedTo;
 
     ULONG PinConnectedToCount;
     PULONG PinConnectedTo;
 
+
     ULONG Visited;
 }PIN, *PPIN;
 
     ULONG Visited;
 }PIN, *PPIN;
 
index d55cf6c..d5050e0 100644 (file)
@@ -264,7 +264,9 @@ MMixerHandleNodeToNodeConnection(
 {
     PTOPOLOGY_NODE InNode, OutNode;
     PTOPOLOGY_NODE * NewNodes;
 {
     PTOPOLOGY_NODE InNode, OutNode;
     PTOPOLOGY_NODE * NewNodes;
+    PULONG NewLogicalPinNodeConnectedFrom;
     ULONG Count;
     ULONG Count;
+    ULONG LogicalPinId;
 
     /* sanity checks */
     ASSERT(Topology->TopologyNodesCount > Connection->ToNode);
 
     /* sanity checks */
     ASSERT(Topology->TopologyNodesCount > Connection->ToNode);
@@ -274,6 +276,9 @@ MMixerHandleNodeToNodeConnection(
     InNode = &Topology->TopologyNodes[Connection->FromNode];
     OutNode = &Topology->TopologyNodes[Connection->ToNode];
 
     InNode = &Topology->TopologyNodes[Connection->FromNode];
     OutNode = &Topology->TopologyNodes[Connection->ToNode];
 
+    /* get logical pin node id */
+    LogicalPinId = Connection->ToNodePin;
+
     /* get existing count */
     Count = OutNode->NodeConnectedFromCount;
 
     /* get existing count */
     Count = OutNode->NodeConnectedFromCount;
 
@@ -286,21 +291,42 @@ MMixerHandleNodeToNodeConnection(
         return MM_STATUS_NO_MEMORY;
     }
 
         return MM_STATUS_NO_MEMORY;
     }
 
+    /* allocate logical pin nodes array */
+    NewLogicalPinNodeConnectedFrom = MixerContext->Alloc((Count + 1) * sizeof(ULONG));
+    if (!NewLogicalPinNodeConnectedFrom)
+    {
+        /* out of memory */
+        MixerContext->Free(NewNodes);
+        return MM_STATUS_NO_MEMORY;
+    }
+
     if (Count)
     {
         /* copy existing nodes */
         MixerContext->Copy(NewNodes, OutNode->NodeConnectedFrom, sizeof(PTOPOLOGY) * Count);
 
     if (Count)
     {
         /* copy existing nodes */
         MixerContext->Copy(NewNodes, OutNode->NodeConnectedFrom, sizeof(PTOPOLOGY) * Count);
 
+        /* copy existing logical pin node array */
+        MixerContext->Copy(NewLogicalPinNodeConnectedFrom, OutNode->LogicalPinNodeConnectedFrom, sizeof(ULONG) * Count);
+
         /* release old nodes array */
         MixerContext->Free(OutNode->NodeConnectedFrom);
         /* release old nodes array */
         MixerContext->Free(OutNode->NodeConnectedFrom);
+
+        /* release old logical pin node array */
+        MixerContext->Free(OutNode->LogicalPinNodeConnectedFrom);
     }
 
     /* add new topology node */
     NewNodes[OutNode->NodeConnectedFromCount] = InNode;
 
     }
 
     /* add new topology node */
     NewNodes[OutNode->NodeConnectedFromCount] = InNode;
 
+    /* add logical node id */
+    NewLogicalPinNodeConnectedFrom[OutNode->NodeConnectedFromCount] = LogicalPinId;
+
     /* replace old nodes array */
     OutNode->NodeConnectedFrom = NewNodes;
 
     /* replace old nodes array */
     OutNode->NodeConnectedFrom = NewNodes;
 
+    /* replace old logical pin node array */
+    OutNode->LogicalPinNodeConnectedFrom = NewLogicalPinNodeConnectedFrom;
+
     /* increment nodes count */
     OutNode->NodeConnectedFromCount++;
 
     /* increment nodes count */
     OutNode->NodeConnectedFromCount++;