[AUDIO-BRINGUP]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Tue, 7 Dec 2010 15:19:22 +0000 (15:19 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Tue, 7 Dec 2010 15:19:22 +0000 (15:19 +0000)
- Implement registering source / destination lines + controls of alternative mixers
- Implement support function for retrieving mixer by name

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

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

index 04a3f9a..15e3216 100644 (file)
@@ -249,13 +249,16 @@ MMixerCreateDestinationLine(
 
     /* initialize mixer destination line */
     DestinationLine->Line.cbStruct = sizeof(MIXERLINEW);
 
     /* initialize mixer destination line */
     DestinationLine->Line.cbStruct = sizeof(MIXERLINEW);
-    DestinationLine->Line.dwSource = MAXULONG;
+    DestinationLine->Line.cChannels = 2; /* FIXME */
+    DestinationLine->Line.cConnections = 0;
+    DestinationLine->Line.cControls = 0;
+    DestinationLine->Line.dwComponentType = (bInputMixer == 0 ? MIXERLINE_COMPONENTTYPE_DST_SPEAKERS : MIXERLINE_COMPONENTTYPE_DST_WAVEIN);
+    DestinationLine->Line.dwDestination = MixerInfo->MixCaps.cDestinations;
     DestinationLine->Line.dwLineID = MixerInfo->MixCaps.cDestinations + DESTINATION_LINE;
     DestinationLine->Line.dwLineID = MixerInfo->MixCaps.cDestinations + DESTINATION_LINE;
-    DestinationLine->Line.fdwLine = MIXERLINE_LINEF_ACTIVE;
+    DestinationLine->Line.dwSource = MAXULONG;
     DestinationLine->Line.dwUser = 0;
     DestinationLine->Line.dwUser = 0;
-    DestinationLine->Line.dwDestination = MixerInfo->MixCaps.cDestinations;
-    DestinationLine->Line.dwComponentType = (bInputMixer == 0 ? MIXERLINE_COMPONENTTYPE_DST_SPEAKERS : MIXERLINE_COMPONENTTYPE_DST_WAVEIN);
-    DestinationLine->Line.cChannels = 2; /* FIXME */
+    DestinationLine->Line.fdwLine = MIXERLINE_LINEF_ACTIVE;
+
 
     if (LineName)
     {
 
     if (LineName)
     {
@@ -1267,6 +1270,12 @@ MMixerHandlePhysicalConnection(
 
     DPRINT1("Name %S, Pin %lu bInput %lu\n", OutConnection->SymbolicLinkName, OutConnection->Pin, bInput);
 
 
     DPRINT1("Name %S, Pin %lu bInput %lu\n", OutConnection->SymbolicLinkName, OutConnection->Pin, bInput);
 
+    /* sanity check */
+    ASSERT(MixerData->MixerInfo == NULL || MixerData->MixerInfo == MixerInfo);
+
+    /* associate with mixer */
+    MixerData->MixerInfo = MixerInfo;
+
     if (MixerData->Topology == NULL)
     {
         /* construct new topology */
     if (MixerData->Topology == NULL)
     {
         /* construct new topology */
@@ -1418,6 +1427,9 @@ MMixerInitializeFilter(
         /* initialize line list */
         InitializeListHead(&MixerInfo->LineList);
         InitializeListHead(&MixerInfo->EventList);
         /* initialize line list */
         InitializeListHead(&MixerInfo->LineList);
         InitializeListHead(&MixerInfo->EventList);
+
+        /* associate with mixer data */
+        MixerData->MixerInfo = MixerInfo;
     }
 
     /* store mixer info */
     }
 
     /* store mixer info */
@@ -1535,6 +1547,9 @@ MMixerHandleAlternativeMixers(
     IN PTOPOLOGY Topology)
 {
     ULONG Index, PinCount, Reserved;
     IN PTOPOLOGY Topology)
 {
     ULONG Index, PinCount, Reserved;
+    MIXER_STATUS Status;
+    ULONG DestinationLineID, LineTerminator;
+    LPMIXERLINE_EXT DstLine;
 
     DPRINT1("DeviceName %S\n", MixerData->DeviceName);
 
 
     DPRINT1("DeviceName %S\n", MixerData->DeviceName);
 
@@ -1546,10 +1561,54 @@ MMixerHandleAlternativeMixers(
         MMixerIsTopologyPinReserved(Topology, Index, &Reserved);
 
         /* check if it has already been reserved */
         MMixerIsTopologyPinReserved(Topology, Index, &Reserved);
 
         /* check if it has already been reserved */
-        if (Reserved == FALSE)
+        if (Reserved == TRUE)
+        {
+            /* pin has already been reserved */
+            continue;
+        }
+
+        DPRINT("MixerName %S Available PinID %lu\n", MixerData->DeviceName, Index);
+
+        /* sanity check */
+        ASSERT(MixerData->MixerInfo);
+
+        if (!MixerData->MixerInfo)
         {
         {
-            DPRINT1("MixerName %S Available PinID %lu\n", MixerData->DeviceName, Index);
+            DPRINT1("Expected mixer info\n");
+            continue;
         }
         }
+
+        /* build the destination line */
+        Status = MMixerBuildMixerDestinationLine(MixerContext, MixerData->MixerInfo, MixerData->hDevice, Index, TRUE);
+        if (Status != MM_STATUS_SUCCESS)
+        {
+            /* failed to build destination line */
+            continue;
+        }
+
+        /* calculate destination line id */
+        DestinationLineID = (DESTINATION_LINE + MixerData->MixerInfo->MixCaps.cDestinations-1);
+
+        /* add mixer controls to destination line */
+        Status = MMixerAddMixerControlsToDestinationLine(MixerContext, MixerData->MixerInfo, MixerData->hDevice, MixerData->Topology, Index, TRUE, DestinationLineID,  &LineTerminator);
+        if (Status == MM_STATUS_SUCCESS)
+        {
+            /* now add the rest of the source lines */
+            Status = MMixerAddMixerSourceLines(MixerContext, MixerData->MixerInfo, MixerData->hDevice, MixerData->Topology, DestinationLineID, LineTerminator);
+        }
+
+        /* mark pin as consumed */
+        MMixerSetTopologyPinReserved(Topology, Index);
+
+        /* now grab destination line */
+        DstLine = MMixerGetSourceMixerLineByLineId(MixerData->MixerInfo, DestinationLineID);
+
+        /* set type and target as undefined */
+        DstLine->Line.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_UNDEFINED;
+        DstLine->Line.Target.dwType = MIXERLINE_TARGETTYPE_UNDEFINED;
+        DstLine->Line.Target.vDriverVersion = 0;
+        DstLine->Line.Target.wMid = 0;
+        DstLine->Line.Target.wPid = 0;
     }
 }
 
     }
 }
 
@@ -1625,7 +1684,7 @@ MMixerSetupFilter(
     /* TODO: apply hacks for Wave source line */
 
     /* activate midi devices */
     /* TODO: apply hacks for Wave source line */
 
     /* activate midi devices */
-    MMixerInitializeMidiForFilter(MixerContext, MixerList, MixerData, Topology);
+    //MMixerInitializeMidiForFilter(MixerContext, MixerList, MixerData, Topology);
 
     /* done */
     return Status;
 
     /* done */
     return Status;
index 815e651..f794d71 100644 (file)
@@ -122,6 +122,7 @@ typedef struct
     HANDLE hDeviceInterfaceKey;
     LPWSTR DeviceName;
     PTOPOLOGY Topology;
     HANDLE hDeviceInterfaceKey;
     LPWSTR DeviceName;
     PTOPOLOGY Topology;
+    LPMIXER_INFO MixerInfo;
 }MIXER_DATA, *LPMIXER_DATA;
 
 typedef struct
 }MIXER_DATA, *LPMIXER_DATA;
 
 typedef struct
@@ -372,6 +373,11 @@ MMixerHandleAlternativeMixers(
     IN LPMIXER_DATA MixerData,
     IN PTOPOLOGY Topology);
 
     IN LPMIXER_DATA MixerData,
     IN PTOPOLOGY Topology);
 
+MIXER_STATUS
+MMixerGetMixerByName(
+    IN PMIXER_LIST MixerList,
+    IN LPWSTR MixerName,
+    OUT LPMIXER_INFO *MixerInfo);
 
 /* topology.c */
 
 
 /* topology.c */
 
index 4d32abb..005f3da 100644 (file)
@@ -100,6 +100,33 @@ MMixerGetMixerInfoByIndex(
     return NULL;
 }
 
     return NULL;
 }
 
+MIXER_STATUS
+MMixerGetMixerByName(
+    IN PMIXER_LIST MixerList,
+    IN LPWSTR MixerName,
+    OUT LPMIXER_INFO *OutMixerInfo)
+{
+    LPMIXER_INFO MixerInfo;
+    PLIST_ENTRY Entry;
+
+    Entry = MixerList->MixerList.Flink;
+    while(Entry != &MixerList->MixerList)
+    {
+        MixerInfo = (LPMIXER_INFO)CONTAINING_RECORD(Entry, MIXER_INFO, Entry);
+
+        DPRINT1("MixerName %S MixerName %S\n", MixerInfo->MixCaps.szPname, MixerName);
+        if (wcsicmp(MixerInfo->MixCaps.szPname, MixerName) == 0)
+        {
+            *OutMixerInfo = MixerInfo;
+            return MM_STATUS_SUCCESS;
+        }
+        /* move to next mixer entry */
+        Entry = Entry->Flink;
+    }
+
+    return MM_STATUS_UNSUCCESSFUL;
+}
+
 LPMIXERLINE_EXT
 MMixerGetSourceMixerLineByLineId(
     LPMIXER_INFO MixerInfo,
 LPMIXERLINE_EXT
 MMixerGetSourceMixerLineByLineId(
     LPMIXER_INFO MixerInfo,