[MMIXER]
[reactos.git] / reactos / lib / drivers / sound / mmixer / controls.c
index 5252a7b..09477ed 100644 (file)
@@ -207,7 +207,8 @@ MMixerAddMixerControl(
 
         /* get node name */
         Status = MixerContext->Control(hDevice, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), (LPVOID)Name, BytesReturned, &BytesReturned);
-        if (Status != MM_STATUS_SUCCESS)
+
+        if (Status == MM_STATUS_SUCCESS)
         {
             MixerContext->Copy(MixerControl->szShortName, Name, (min(MIXER_SHORT_NAME_CHARS, wcslen(Name)+1)) * sizeof(WCHAR));
             MixerControl->szShortName[MIXER_SHORT_NAME_CHARS-1] = L'\0';
@@ -300,7 +301,6 @@ MMixerAddMixerControl(
                 {
                     MixerContext->Free(Desc);
                     MixerContext->Free(VolumeData);
-
                     return MM_STATUS_NO_MEMORY;
                 }
 
@@ -316,7 +316,6 @@ MMixerAddMixerControl(
        MixerContext->Free(Desc);
     }
 
-
     DPRINT("Status %x Name %S\n", Status, MixerControl->szName);
     return MM_STATUS_SUCCESS;
 }
@@ -577,8 +576,12 @@ MMixerCreateDestinationLine(
 
     if (LineName)
     {
-        wcscpy(DestinationLine->Line.szShortName, LineName);
-        wcscpy(DestinationLine->Line.szName, LineName);
+        MixerContext->Copy(DestinationLine->Line.szShortName, LineName, (min(MIXER_SHORT_NAME_CHARS, wcslen(LineName)+1)) * sizeof(WCHAR));
+        DestinationLine->Line.szShortName[MIXER_SHORT_NAME_CHARS-1] = L'\0';
+
+        MixerContext->Copy(DestinationLine->Line.szName, LineName, (min(MIXER_LONG_NAME_CHARS, wcslen(LineName)+1)) * sizeof(WCHAR));
+        DestinationLine->Line.szName[MIXER_LONG_NAME_CHARS-1] = L'\0';
+
     }
     else
     {
@@ -594,6 +597,8 @@ MMixerCreateDestinationLine(
     DestinationLine->Line.Target.vDriverVersion = MixerInfo->MixCaps.vDriverVersion;
     wcscpy(DestinationLine->Line.Target.szPname, MixerInfo->MixCaps.szPname);
 
+    // initialize extra line
+    InitializeListHead(&DestinationLine->LineControlsExtraData);
 
     // insert into mixer info
     InsertHeadList(&MixerInfo->LineList, &DestinationLine->Entry);
@@ -687,6 +692,9 @@ MMixerHandlePhysicalConnection(
     MixerData = MMixerGetDataByDeviceName(MixerList, OutConnection->SymbolicLinkName);
     ASSERT(MixerData);
 
+    // store connected mixer handle
+    MixerInfo->hMixer = MixerData->hDevice;
+
     // get connected filter pin count
     PinsRefCount = MMixerGetFilterPinCount(MixerContext, MixerData->hDevice);
     ASSERT(PinsRefCount);
@@ -822,6 +830,7 @@ MMixerInitializeFilter(
     ULONG BytesReturned;
     KSP_PIN Pin;
     LPWSTR Buffer = NULL;
+    ULONG PinId;
 
     // allocate a mixer info struct
     MixerInfo = (LPMIXER_INFO) MixerContext->Alloc(sizeof(MIXER_INFO));
@@ -859,10 +868,15 @@ MMixerInitializeFilter(
     // now get the target pins of the ADC / DAC node
     Status = MMixerGetTargetPins(MixerContext, NodeTypes, NodeConnections, NodeIndex, !bInputMixer, Pins, PinCount);
 
+    // find a target pin with a name
+    PinId = PinCount +1;
     for(Index = 0; Index < PinCount; Index++)
     {
         if (Pins[Index])
         {
+            // store index of pin
+            PinId = Index;
+
             /* retrieve pin name */
             Pin.PinId = Index;
             Pin.Reserved = 0;
@@ -895,6 +909,12 @@ MMixerInitializeFilter(
         }
     }
 
+    if (PinId < PinCount)
+    {
+        // create an wave info struct
+        MMixerInitializeWaveInfo(MixerContext, MixerList, MixerData, MixerInfo->MixCaps.szPname, bInputMixer, PinId);
+    }
+
     Status = MMixerCreateDestinationLine(MixerContext, MixerInfo, bInputMixer, Buffer);
 
     if (Buffer)
@@ -988,7 +1008,7 @@ MMixerSetupFilter(
     IN LPMIXER_DATA MixerData,
     IN PULONG DeviceCount)
 {
-    PKSMULTIPLE_ITEM NodeTypes, NodeConnections;
+    PKSMULTIPLE_ITEM NodeTypes = NULL, NodeConnections = NULL;
     MIXER_STATUS Status;
     ULONG PinCount;
     ULONG NodeIndex;
@@ -1016,6 +1036,7 @@ MMixerSetupFilter(
     }
 
     // check if the filter has an wave out node
+
     NodeIndex = MMixerGetIndexOfGuid(NodeTypes, &KSNODETYPE_DAC);
     if (NodeIndex != MAXULONG)
     {