[MMIXER]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Sun, 31 Oct 2010 14:34:41 +0000 (14:34 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Sun, 31 Oct 2010 14:34:41 +0000 (14:34 +0000)
- Enumerate MIDI devices and provide all necessary functions to deal with them
[WDMAUD_KERNEL]
- Implement support functions which call the provided functions of mmixer library
- Fix a bug in device interface request ioctl handler
- Midi devices should now be visible, capabilities be retrieved and opened / close
- Writing data is not yet supported

svn path=/trunk/; revision=49376

16 files changed:
reactos/dll/win32/wdmaud.drv/legacy.c
reactos/dll/win32/wdmaud.drv/mmixer.c
reactos/dll/win32/wdmaud.drv/wdmaud.c
reactos/drivers/wdm/audio/legacy/wdmaud/control.c
reactos/drivers/wdm/audio/legacy/wdmaud/interface.h
reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c
reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h
reactos/lib/drivers/sound/mmixer/controls.c
reactos/lib/drivers/sound/mmixer/midi.c [new file with mode: 0644]
reactos/lib/drivers/sound/mmixer/mixer.c
reactos/lib/drivers/sound/mmixer/mmixer.h
reactos/lib/drivers/sound/mmixer/mmixer.rbuild
reactos/lib/drivers/sound/mmixer/priv.h
reactos/lib/drivers/sound/mmixer/sup.c
reactos/lib/drivers/sound/mmixer/topology.c
reactos/lib/drivers/sound/mmixer/wave.c

index cce93e8..88df5b2 100644 (file)
@@ -171,7 +171,7 @@ WdmAudGetCapabilitiesByLegacy(
     {
         case MIXER_DEVICE_TYPE:
         {
-            LPMIXERCAPS MixerCaps = (LPMIXERCAPS) Capabilities;
+            LPMIXERCAPSW MixerCaps = (LPMIXERCAPSW) Capabilities;
 
             DeviceInfo.u.MixCaps.szPname[MAXPNAMELEN-1] = L'\0';
             CopyWideString(MixerCaps->szPname, DeviceInfo.u.MixCaps.szPname);
@@ -185,13 +185,13 @@ WdmAudGetCapabilitiesByLegacy(
         }
         case WAVE_OUT_DEVICE_TYPE :
         {
-            LPWAVEOUTCAPS WaveOutCaps = (LPWAVEOUTCAPS) Capabilities;
+            LPWAVEOUTCAPSW WaveOutCaps = (LPWAVEOUTCAPSW) Capabilities;
 
             DeviceInfo.u.WaveOutCaps.szPname[MAXPNAMELEN-1] = L'\0';
             WaveOutCaps->wMid = DeviceInfo.u.WaveOutCaps.wMid;
             WaveOutCaps->wPid = DeviceInfo.u.WaveOutCaps.wPid;
 
-            WaveOutCaps->vDriverVersion = 0x0001;
+            WaveOutCaps->vDriverVersion = DeviceInfo.u.WaveOutCaps.vDriverVersion;
             CopyWideString(WaveOutCaps->szPname, DeviceInfo.u.WaveOutCaps.szPname);
 
             WaveOutCaps->dwFormats = DeviceInfo.u.WaveOutCaps.dwFormats;
@@ -208,7 +208,7 @@ WdmAudGetCapabilitiesByLegacy(
             WaveInCaps->wMid = DeviceInfo.u.WaveInCaps.wMid;
             WaveInCaps->wPid = DeviceInfo.u.WaveInCaps.wPid;
 
-            WaveInCaps->vDriverVersion = 0x0001;
+            WaveInCaps->vDriverVersion = DeviceInfo.u.WaveInCaps.vDriverVersion;
             CopyWideString(WaveInCaps->szPname, DeviceInfo.u.WaveInCaps.szPname);
 
             WaveInCaps->dwFormats = DeviceInfo.u.WaveInCaps.dwFormats;
@@ -216,6 +216,34 @@ WdmAudGetCapabilitiesByLegacy(
             WaveInCaps->wReserved1 = 0;
             break;
         }
+        case MIDI_IN_DEVICE_TYPE :
+        {
+            LPMIDIINCAPSW MidiInCaps = (LPMIDIINCAPSW)Capabilities;
+
+            DeviceInfo.u.MidiInCaps.szPname[MAXPNAMELEN-1] = L'\0';
+
+            MidiInCaps->vDriverVersion = DeviceInfo.u.MidiInCaps.vDriverVersion;
+            MidiInCaps->wMid = DeviceInfo.u.MidiInCaps.wMid;
+            MidiInCaps->wPid = DeviceInfo.u.MidiInCaps.wPid;
+            MidiInCaps->dwSupport = DeviceInfo.u.MidiInCaps.dwSupport;
+
+            CopyWideString(MidiInCaps->szPname, DeviceInfo.u.MidiInCaps.szPname);
+            break;
+        }
+        case MIDI_OUT_DEVICE_TYPE :
+        {
+            LPMIDIOUTCAPSW MidiOutCaps = (LPMIDIOUTCAPSW)Capabilities;
+
+            DeviceInfo.u.MidiOutCaps.szPname[MAXPNAMELEN-1] = L'\0';
+
+            MidiOutCaps->vDriverVersion = DeviceInfo.u.MidiOutCaps.vDriverVersion;
+            MidiOutCaps->wMid = DeviceInfo.u.MidiOutCaps.wMid;
+            MidiOutCaps->wPid = DeviceInfo.u.MidiOutCaps.wPid;
+            MidiOutCaps->dwSupport = DeviceInfo.u.MidiOutCaps.dwSupport;
+
+            CopyWideString(MidiOutCaps->szPname, DeviceInfo.u.MidiOutCaps.szPname);
+            break;
+        }
     }
 
     return MMSYSERR_NOERROR;
index c47b651..a3a021c 100644 (file)
@@ -655,17 +655,46 @@ WdmAudSetWaveStateByMMixer(
     IN  struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
     IN BOOL bStart)
 {
-    if (bStart)
+    MMDEVICE_TYPE DeviceType;
+    PSOUND_DEVICE SoundDevice;
+    MMRESULT Result;
+
+    Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
+    SND_ASSERT( Result == MMSYSERR_NOERROR );
+
+
+    Result = GetSoundDeviceType(SoundDevice, &DeviceType);
+    SND_ASSERT( Result == MMSYSERR_NOERROR );
+
+    if (DeviceType == WAVE_IN_DEVICE_TYPE || DeviceType == WAVE_OUT_DEVICE_TYPE)
     {
-        MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
-        MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
-        MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_RUN);
+        if (bStart)
+        {
+            MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
+            MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
+            MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_RUN);
+        }
+        else
+        {
+            MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
+            MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
+            MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_STOP);
+        }
     }
-    else
+    else if (DeviceType == MIDI_IN_DEVICE_TYPE || DeviceType == MIDI_OUT_DEVICE_TYPE)
     {
-        MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
-        MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
-        MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_STOP);
+        if (bStart)
+        {
+            MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
+            MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
+            MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_RUN);
+        }
+        else
+        {
+            MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
+            MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
+            MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_STOP);
+        }
     }
 
     return MMSYSERR_NOERROR;
index 67523eb..6255dee 100644 (file)
@@ -90,6 +90,12 @@ PopulateWdmDeviceList(
             FuncTable.CommitWaveBuffer = WriteFileEx_Remixer;
 #endif
         }
+        else if (DeviceType == MIDI_IN_DEVICE_TYPE || DeviceType == MIDI_OUT_DEVICE_TYPE)
+        {
+            FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetMixerDeviceFormat);
+            FuncTable.SetState = FUNC_NAME(WdmAudSetWaveState);
+            FuncTable.GetPos = FUNC_NAME(WdmAudGetWavePosition);
+        }
 
         SetSoundDeviceFunctionTable(SoundDevice, &FuncTable);
     }
index d41b5da..cc4824e 100644 (file)
@@ -27,6 +27,12 @@ WdmAudControlOpen(
         return WdmAudControlOpenWave(DeviceObject, Irp, DeviceInfo, ClientInfo);
     }
 
+    if (DeviceInfo->DeviceType == MIDI_OUT_DEVICE_TYPE || DeviceInfo->DeviceType == MIDI_IN_DEVICE_TYPE)
+    {
+        return WdmAudControlOpenMidi(DeviceObject, Irp, DeviceInfo, ClientInfo);
+    }
+
+
     return SetIrpIoStatus(Irp, STATUS_NOT_SUPPORTED, sizeof(WDMAUD_DEVICE_INFO));
 }
 
@@ -55,6 +61,15 @@ WdmAudControlDeviceType(
     {
         Result = WdmAudGetWaveOutDeviceCount();
     }
+    else if (DeviceInfo->DeviceType == MIDI_IN_DEVICE_TYPE)
+    {
+        Result = WdmAudGetMidiInDeviceCount();
+    }
+    else if (DeviceInfo->DeviceType == MIDI_OUT_DEVICE_TYPE)
+    {
+        Result = WdmAudGetMidiOutDeviceCount();
+    }
+
 
     /* store result count */
     DeviceInfo->DeviceCount = Result;
@@ -121,6 +136,10 @@ WdmAudCapabilities(
     {
         Status = WdmAudWaveCapabilities(DeviceObject, DeviceInfo, ClientInfo, DeviceExtension);
     }
+    else if (DeviceInfo->DeviceType == MIDI_IN_DEVICE_TYPE || DeviceInfo->DeviceType == MIDI_OUT_DEVICE_TYPE)
+    {
+        Status = WdmAudMidiCapabilities(DeviceObject, DeviceInfo, ClientInfo, DeviceExtension);
+    }
 
     return SetIrpIoStatus(Irp, Status, sizeof(WDMAUD_DEVICE_INFO));
 }
@@ -219,80 +238,38 @@ WdmAudGetDeviceInterface(
     /* get device interface string input length */
     Size = DeviceInfo->u.Interface.DeviceInterfaceStringSize;
 
-    if (DeviceInfo->DeviceType == WAVE_IN_DEVICE_TYPE || DeviceInfo->DeviceType == WAVE_OUT_DEVICE_TYPE)
-    {
-        /* get wave info */
-        Status = WdmAudGetPnpNameByIndexAndType(DeviceInfo->DeviceIndex, DeviceInfo->DeviceType, &Device);
+   /* get mixer info */
+   Status = WdmAudGetPnpNameByIndexAndType(DeviceInfo->DeviceIndex, DeviceInfo->DeviceType, &Device);
 
-        /* check for success */
-        if (!NT_SUCCESS(Status))
-        {
-            /* invalid device id */
-            return SetIrpIoStatus(Irp, Status, sizeof(WDMAUD_DEVICE_INFO));
-        }
+   /* check for success */
+   if (!NT_SUCCESS(Status))
+   {
+        /* invalid device id */
+        return SetIrpIoStatus(Irp, Status, sizeof(WDMAUD_DEVICE_INFO));
+   }
 
-        /* calculate length */
-        Length = (wcslen(Device)+1) * sizeof(WCHAR);
+   /* calculate length */
+   Length = (wcslen(Device)+1) * sizeof(WCHAR);
 
-        if (!Size)
-        {
-            /* store device interface size */
-            DeviceInfo->u.Interface.DeviceInterfaceStringSize = Length;
-        }
-        else if (Size < Length)
-        {
-            /* buffer too small */
-            DeviceInfo->u.Interface.DeviceInterfaceStringSize = Length;
-            return SetIrpIoStatus(Irp, STATUS_BUFFER_OVERFLOW, sizeof(WDMAUD_DEVICE_INFO));
-        }
-        else
-        {
-            //FIXME SEH
-            RtlMoveMemory(DeviceInfo->u.Interface.DeviceInterfaceString, Device, Length);
-        }
-
-        FreeItem(Device);
-        return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO));
+    if (!Size)
+    {
+        /* store device interface size */
+        DeviceInfo->u.Interface.DeviceInterfaceStringSize = Length;
     }
-    else if (DeviceInfo->DeviceType == MIXER_DEVICE_TYPE)
+    else if (Size < Length)
     {
-        if (DeviceInfo->DeviceIndex >= WdmAudGetMixerDeviceCount())
-        {
-            /* invalid device id */
-            return SetIrpIoStatus(Irp, STATUS_INVALID_PARAMETER, sizeof(WDMAUD_DEVICE_INFO));
-        }
-
-        Status = WdmAudGetMixerPnpNameByIndex(DeviceInfo->DeviceIndex, &Device);
-        /* check for success */
-        if (!NT_SUCCESS(Status))
-        {
-            /* invalid device id */
-            return SetIrpIoStatus(Irp, Status, sizeof(WDMAUD_DEVICE_INFO));
-        }
-
-        /* calculate length */
-        Length = (wcslen(Device)+1) * sizeof(WCHAR);
-
-        if (!Size)
-        {
-            /* store device interface size */
-            DeviceInfo->u.Interface.DeviceInterfaceStringSize = Length;
-        }
-        else if (Size < Length)
-        {
-            /* buffer too small */
-            DeviceInfo->u.Interface.DeviceInterfaceStringSize = Length;
-            return SetIrpIoStatus(Irp, STATUS_BUFFER_OVERFLOW, sizeof(WDMAUD_DEVICE_INFO));
-        }
-        else
-        {
-            //FIXME SEH
-            RtlMoveMemory(DeviceInfo->u.Interface.DeviceInterfaceString, Device, Length);
-        }
-        return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO));
+        /* buffer too small */
+        DeviceInfo->u.Interface.DeviceInterfaceStringSize = Length;
+        return SetIrpIoStatus(Irp, STATUS_BUFFER_OVERFLOW, sizeof(WDMAUD_DEVICE_INFO));
+    }
+    else
+    {
+        //FIXME SEH
+        RtlMoveMemory(DeviceInfo->u.Interface.DeviceInterfaceString, Device, Length);
     }
 
-    return SetIrpIoStatus(Irp, STATUS_INVALID_DEVICE_REQUEST, sizeof(WDMAUD_DEVICE_INFO));
+    FreeItem(Device);
+    return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO));
 }
 
 NTSTATUS
index aa5e7b2..025bebb 100644 (file)
@@ -42,6 +42,8 @@ typedef struct
         WAVEOUTCAPSW WaveOutCaps;
         AUXCAPSW     AuxCaps;
         WAVEINCAPSW  WaveInCaps;
+        MIDIINCAPSW  MidiInCaps;
+        MIDIOUTCAPSW MidiOutCaps;
         ULONGLONG    Position;
         struct
         {
index 72e7776..fbc7638 100644 (file)
@@ -612,25 +612,44 @@ WdmAudGetWaveOutDeviceCount()
     return MMixerGetWaveOutCount(&MixerContext);
 }
 
-NTSTATUS
-WdmAudGetMixerPnpNameByIndex(
-    IN  ULONG DeviceIndex,
-    OUT LPWSTR * Device)
+ULONG
+WdmAudGetMidiInDeviceCount()
+{
+    return MMixerGetMidiInCount(&MixerContext);
+}
+
+ULONG
+WdmAudGetMidiOutDeviceCount()
 {
-    UNIMPLEMENTED
-    return STATUS_NOT_IMPLEMENTED;
+    return MMixerGetWaveOutCount(&MixerContext);
 }
 
 NTSTATUS
 WdmAudGetPnpNameByIndexAndType(
-    IN ULONG DeviceIndex, 
-    IN SOUND_DEVICE_TYPE DeviceType, 
+    IN ULONG DeviceIndex,
+    IN SOUND_DEVICE_TYPE DeviceType,
     OUT LPWSTR *DevicePath)
 {
-    if (MMixerGetWaveDevicePath(&MixerContext, DeviceType == WAVE_IN_DEVICE_TYPE, DeviceIndex, DevicePath) == MM_STATUS_SUCCESS)
-        return STATUS_SUCCESS;
-    else
-        return STATUS_UNSUCCESSFUL;
+    if (DeviceType == WAVE_IN_DEVICE_TYPE || DeviceType == WAVE_OUT_DEVICE_TYPE)
+    {
+        if (MMixerGetWaveDevicePath(&MixerContext, DeviceType == WAVE_IN_DEVICE_TYPE, DeviceIndex, DevicePath) == MM_STATUS_SUCCESS)
+            return STATUS_SUCCESS;
+        else
+            return STATUS_UNSUCCESSFUL;
+    }
+    else if (DeviceType == MIDI_IN_DEVICE_TYPE || DeviceType == MIDI_OUT_DEVICE_TYPE)
+    {
+        if (MMixerGetMidiDevicePath(&MixerContext, DeviceType == MIDI_IN_DEVICE_TYPE, DeviceIndex, DevicePath) == MM_STATUS_SUCCESS)
+            return STATUS_SUCCESS;
+        else
+            return STATUS_UNSUCCESSFUL;
+    }
+    else if (DeviceType == MIXER_DEVICE_TYPE)
+    {
+        UNIMPLEMENTED;
+    }
+
+    return STATUS_UNSUCCESSFUL;
 }
 
 NTSTATUS
@@ -640,7 +659,7 @@ WdmAudWaveCapabilities(
     IN PWDMAUD_CLIENT ClientInfo,
     IN PWDMAUD_DEVICE_EXTENSION DeviceExtension)
 {
-    MIXER_STATUS Status;
+    MIXER_STATUS Status = MM_STATUS_UNSUCCESSFUL;
 
     if (DeviceInfo->DeviceType == WAVE_IN_DEVICE_TYPE)
     {
@@ -652,10 +671,31 @@ WdmAudWaveCapabilities(
         /* get capabilities */
         Status = MMixerWaveOutCapabilities(&MixerContext, DeviceInfo->DeviceIndex, &DeviceInfo->u.WaveOutCaps);
     }
+
+    if (Status == MM_STATUS_SUCCESS)
+        return STATUS_SUCCESS;
     else
+        return Status;
+}
+
+NTSTATUS
+WdmAudMidiCapabilities(
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PWDMAUD_DEVICE_INFO DeviceInfo,
+    IN PWDMAUD_CLIENT ClientInfo,
+    IN PWDMAUD_DEVICE_EXTENSION DeviceExtension)
+{
+    MIXER_STATUS Status = MM_STATUS_UNSUCCESSFUL;
+
+    if (DeviceInfo->DeviceType == MIDI_IN_DEVICE_TYPE)
     {
-        ASSERT(0);
-        return STATUS_UNSUCCESSFUL;
+        /* get capabilities */
+        Status = MMixerMidiInCapabilities(&MixerContext, DeviceInfo->DeviceIndex, &DeviceInfo->u.MidiInCaps);
+    }
+    else if (DeviceInfo->DeviceType == WAVE_OUT_DEVICE_TYPE)
+    {
+        /* get capabilities */
+        Status = MMixerMidiOutCapabilities(&MixerContext, DeviceInfo->DeviceIndex, &DeviceInfo->u.MidiOutCaps);
     }
 
     if (Status == MM_STATUS_SUCCESS)
@@ -737,3 +777,26 @@ WdmAudControlOpenWave(
     else
         return SetIrpIoStatus(Irp, STATUS_NOT_SUPPORTED, sizeof(WDMAUD_DEVICE_INFO));
 }
+
+NTSTATUS
+WdmAudControlOpenMidi(
+    IN  PDEVICE_OBJECT DeviceObject,
+    IN  PIRP Irp,
+    IN  PWDMAUD_DEVICE_INFO DeviceInfo,
+    IN  PWDMAUD_CLIENT ClientInfo)
+{
+    MIXER_STATUS Status;
+    PIN_CREATE_CONTEXT Context;
+
+    Context.ClientInfo = ClientInfo;
+    Context.DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+    Context.DeviceType = DeviceInfo->DeviceType;
+
+    Status = MMixerOpenMidi(&MixerContext, DeviceInfo->DeviceIndex, DeviceInfo->DeviceType == MIDI_IN_DEVICE_TYPE, CreatePinCallback, &Context, &DeviceInfo->hDevice);
+
+    if (Status == MM_STATUS_SUCCESS)
+        return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO));
+    else
+        return SetIrpIoStatus(Irp, STATUS_NOT_SUPPORTED, sizeof(WDMAUD_DEVICE_INFO));
+}
+
index dff0d8f..e29377a 100644 (file)
@@ -130,6 +130,12 @@ WdmAudControlOpenWave(
     IN  PWDMAUD_DEVICE_INFO DeviceInfo,
     IN  PWDMAUD_CLIENT ClientInfo);
 
+NTSTATUS
+WdmAudControlOpenMidi(
+    IN  PDEVICE_OBJECT DeviceObject,
+    IN  PIRP Irp,
+    IN  PWDMAUD_DEVICE_INFO DeviceInfo,
+    IN  PWDMAUD_CLIENT ClientInfo);
 
 ULONG
 GetNumOfMixerDevices(
@@ -166,6 +172,13 @@ WdmAudWaveCapabilities(
     IN  PWDMAUD_CLIENT ClientInfo,
     IN PWDMAUD_DEVICE_EXTENSION DeviceExtension);
 
+NTSTATUS
+WdmAudMidiCapabilities(
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PWDMAUD_DEVICE_INFO DeviceInfo,
+    IN PWDMAUD_CLIENT ClientInfo,
+    IN PWDMAUD_DEVICE_EXTENSION DeviceExtension);
+
 NTSTATUS
 NTAPI
 WdmAudFrameSize(
@@ -267,10 +280,11 @@ WdmAudGetWaveInDeviceCount();
 ULONG
 WdmAudGetWaveOutDeviceCount();
 
-NTSTATUS
-WdmAudGetMixerPnpNameByIndex(
-    IN  ULONG DeviceIndex,
-    OUT LPWSTR * Device);
+ULONG
+WdmAudGetMidiInDeviceCount();
+
+ULONG
+WdmAudGetMidiOutDeviceCount();
 
 NTSTATUS
 WdmAudGetPnpNameByIndexAndType(
index 6963f49..5b5dd18 100644 (file)
@@ -955,7 +955,7 @@ MMixerInitializeFilter(
     MixerInfo->hMixer = MixerData->hDevice;
 
     /* get mixer name */
-    MMixerGetDeviceName(MixerContext, MixerInfo, MixerData->hDeviceInterfaceKey);
+    MMixerGetDeviceName(MixerContext, MixerInfo->MixCaps.szPname, MixerData->hDeviceInterfaceKey);
 
     /* initialize line list */
     InitializeListHead(&MixerInfo->LineList);
@@ -1128,6 +1128,9 @@ MMixerSetupFilter(
 
     }
 
+    /* activate midi devices */
+    MMixerInitializeMidiForFilter(MixerContext, MixerList, MixerData, Topology);
+
     /* done */
     return Status;
 }
diff --git a/reactos/lib/drivers/sound/mmixer/midi.c b/reactos/lib/drivers/sound/mmixer/midi.c
new file mode 100644 (file)
index 0000000..e60d149
--- /dev/null
@@ -0,0 +1,541 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS Kernel Streaming
+ * FILE:            lib/drivers/sound/mmixer/midi.c
+ * PURPOSE:         Midi Support Functions
+ * PROGRAMMER:      Johannes Anderwald
+ */
+
+#include "priv.h"
+
+MIXER_STATUS
+MMixerGetPinDataFlowAndCommunication(
+    IN PMIXER_CONTEXT MixerContext,
+    IN LPMIXER_DATA MixerData,
+    IN ULONG PinId,
+    OUT PKSPIN_DATAFLOW DataFlow,
+    OUT PKSPIN_COMMUNICATION Communication)
+{
+    KSP_PIN Pin;
+    ULONG BytesReturned;
+    MIXER_STATUS Status;
+
+    /* setup request */
+    Pin.PinId = PinId;
+    Pin.Reserved = 0;
+    Pin.Property.Flags = KSPROPERTY_TYPE_GET;
+    Pin.Property.Id = KSPROPERTY_PIN_DATAFLOW;
+    Pin.Property.Set = KSPROPSETID_Pin;
+
+    /* get pin dataflow */
+    Status = MixerContext->Control(MixerData->hDevice, IOCTL_KS_PROPERTY, (PVOID)&Pin, sizeof(KSP_PIN), (PVOID)DataFlow, sizeof(KSPIN_DATAFLOW), &BytesReturned);
+    if (Status != MM_STATUS_SUCCESS)
+    {
+        /* failed to retrieve dataflow */
+        return Status;
+    }
+
+    /* setup communication request */
+    Pin.Property.Id = KSPROPERTY_PIN_COMMUNICATION;
+
+    /* get pin communication */
+    Status = MixerContext->Control(MixerData->hDevice, IOCTL_KS_PROPERTY, (PVOID)&Pin, sizeof(KSP_PIN), (PVOID)Communication, sizeof(KSPIN_COMMUNICATION), &BytesReturned);
+
+    return Status;
+}
+
+MIXER_STATUS
+MMixerAddMidiPin(
+    IN PMIXER_CONTEXT MixerContext,
+    IN PMIXER_LIST MixerList,
+    IN ULONG DeviceId,
+    IN ULONG PinId,
+    IN ULONG bInput,
+    IN LPWSTR DeviceName)
+{
+    LPMIDI_INFO MidiInfo;
+
+    /* allocate midi info */
+    MidiInfo = MixerContext->Alloc(sizeof(MIDI_INFO));
+
+    if (!MidiInfo)
+    {
+        /* no memory */
+        return MM_STATUS_NO_MEMORY;
+    }
+
+    /* initialize midi info */
+    MidiInfo->DeviceId = DeviceId;
+    MidiInfo->PinId = PinId;
+
+    /* sanity check */
+    ASSERT(wcslen(DeviceName) + 1 < MAXPNAMELEN);
+
+    /* copy device name */
+    if (bInput && DeviceName)
+    {
+        wcscpy(MidiInfo->u.InCaps.szPname, DeviceName);
+    }
+    else if (!bInput && DeviceName)
+    {
+        wcscpy(MidiInfo->u.OutCaps.szPname, DeviceName);
+    }
+
+   /* FIXME determine manufacturer / product id */
+    if (bInput)
+    {
+        MidiInfo->u.InCaps.dwSupport = 0;
+        MidiInfo->u.InCaps.wMid = MM_MICROSOFT;
+        MidiInfo->u.InCaps.wPid = MM_PID_UNMAPPED;
+        MidiInfo->u.InCaps.vDriverVersion = 1;
+    }
+    else
+    {
+        MidiInfo->u.OutCaps.dwSupport = 0;
+        MidiInfo->u.OutCaps.wMid = MM_MICROSOFT;
+        MidiInfo->u.OutCaps.wPid = MM_PID_UNMAPPED;
+        MidiInfo->u.OutCaps.vDriverVersion = 1;
+    }
+
+    if (bInput)
+    {
+        /* insert into list */
+        InsertTailList(&MixerList->MidiInList, &MidiInfo->Entry);
+        MixerList->MidiInListCount++;
+    }
+    else
+    {
+        /* insert into list */
+        InsertTailList(&MixerList->MidiOutList, &MidiInfo->Entry);
+        MixerList->MidiOutListCount++;
+    }
+
+    return MM_STATUS_SUCCESS;
+}
+
+VOID
+MMixerCheckFilterPinMidiSupport(
+    IN PMIXER_CONTEXT MixerContext,
+    IN PMIXER_LIST MixerList,
+    IN LPMIXER_DATA MixerData,
+    IN ULONG PinId,
+    IN PKSMULTIPLE_ITEM MultipleItem,
+    IN LPWSTR szPname)
+{
+    ULONG Index;
+    PKSDATARANGE DataRange;
+    KSPIN_COMMUNICATION Communication;
+    KSPIN_DATAFLOW DataFlow;
+    MIXER_STATUS Status;
+
+    /* get first datarange */
+    DataRange = (PKSDATARANGE)(MultipleItem + 1);
+
+    /* alignment assert */
+    ASSERT(((ULONG_PTR)DataRange & 0x7) == 0);
+
+    /* iterate through all data ranges */
+    for(Index = 0; Index < MultipleItem->Count; Index++)
+    {
+        if (IsEqualGUIDAligned(&DataRange->MajorFormat, &KSDATAFORMAT_TYPE_MUSIC) &&
+            IsEqualGUIDAligned(&DataRange->SubFormat, &KSDATAFORMAT_SUBTYPE_MIDI) &&
+            IsEqualGUIDAligned(&DataRange->Specifier, &KSDATAFORMAT_SPECIFIER_NONE))
+        {
+            /* pin supports midi datarange */
+            if (MMixerGetPinDataFlowAndCommunication(MixerContext, MixerData, PinId, &DataFlow, &Communication) == MM_STATUS_SUCCESS)
+            {
+                if (DataFlow == KSPIN_DATAFLOW_IN && Communication == KSPIN_COMMUNICATION_SINK)
+                {
+                    Status = MMixerAddMidiPin(MixerContext, MixerList, MixerData->DeviceId, PinId, FALSE, szPname);
+                }
+                else if (DataFlow == KSPIN_DATAFLOW_OUT && Communication == KSPIN_COMMUNICATION_SOURCE)
+                {
+                    Status = MMixerAddMidiPin(MixerContext, MixerList, MixerData->DeviceId, PinId, TRUE, szPname);
+                }
+            }
+        }
+
+        /* move to next datarange */
+        DataRange = (PKSDATARANGE)((ULONG_PTR)DataRange + DataRange->FormatSize);
+
+        /* alignment assert */
+        ASSERT(((ULONG_PTR)DataRange & 0x7) == 0);
+
+        /* data ranges are 64-bit aligned */
+        DataRange = (PVOID)(((ULONG_PTR)DataRange + 0x7) & ~0x7);
+    }
+}
+
+VOID
+MMixerInitializeMidiForFilter(
+    IN PMIXER_CONTEXT MixerContext,
+    IN PMIXER_LIST MixerList,
+    IN LPMIXER_DATA MixerData,
+    IN PTOPOLOGY Topology)
+{
+    ULONG PinCount, Index;
+    MIXER_STATUS Status;
+    PKSMULTIPLE_ITEM MultipleItem;
+    WCHAR szPname[MAXPNAMELEN];
+
+    /* get filter pin count */
+    MMixerGetTopologyPinCount(Topology, &PinCount);
+
+    /* get mixer name */
+    if (MMixerGetDeviceName(MixerContext, szPname, MixerData->hDeviceInterfaceKey) != MM_STATUS_SUCCESS)
+    {
+        /* clear name */
+        szPname[0] = 0;
+    }
+
+    /* iterate all pins and check for KSDATARANGE_MUSIC support */
+    for(Index = 0; Index < PinCount; Index++)
+    {
+        /* get audio pin data ranges */
+        Status = MMixerGetAudioPinDataRanges(MixerContext, MixerData->hDevice, Index, &MultipleItem);
+
+        /* check for success */
+        if (Status == MM_STATUS_SUCCESS)
+        {
+            /* check if there is support KSDATARANGE_MUSIC */
+            MMixerCheckFilterPinMidiSupport(MixerContext, MixerList, MixerData, Index, MultipleItem, szPname);
+        }
+    }
+}
+
+MIXER_STATUS
+MMixerOpenMidiPin(
+    IN PMIXER_CONTEXT MixerContext,
+    IN PMIXER_LIST MixerList,
+    IN ULONG DeviceId,
+    IN ULONG PinId,
+    IN ACCESS_MASK DesiredAccess,
+    IN PIN_CREATE_CALLBACK CreateCallback,
+    IN PVOID Context,
+    OUT PHANDLE PinHandle)
+{
+    PKSPIN_CONNECT PinConnect;
+    PKSDATAFORMAT DataFormat;
+    LPMIXER_DATA MixerData;
+    NTSTATUS Status;
+    MIXER_STATUS MixerStatus;
+
+    MixerData = MMixerGetDataByDeviceId(MixerList, DeviceId);
+    if (!MixerData)
+        return MM_STATUS_INVALID_PARAMETER;
+
+    /* allocate pin connect */
+    PinConnect = MMixerAllocatePinConnect(MixerContext, sizeof(KSDATAFORMAT));
+    if (!PinConnect)
+    {
+        /* no memory */
+        return MM_STATUS_NO_MEMORY;
+    }
+
+    /* initialize pin connect struct */
+    MMixerInitializePinConnect(PinConnect, PinId);
+
+    /* get offset to dataformat */
+    DataFormat = (PKSDATAFORMAT) (PinConnect + 1);
+
+    /* initialize data format */
+    RtlMoveMemory(&DataFormat->MajorFormat, &KSDATAFORMAT_TYPE_MUSIC, sizeof(GUID));
+    RtlMoveMemory(&DataFormat->SubFormat, &KSDATAFORMAT_SUBTYPE_MIDI, sizeof(GUID));
+    RtlMoveMemory(&DataFormat->Specifier, &KSDATAFORMAT_SPECIFIER_NONE, sizeof(GUID));
+
+    if (CreateCallback)
+    {
+        /* let the callback handle the creation */
+        MixerStatus = CreateCallback(Context, DeviceId, PinId, MixerData->hDevice, PinConnect, DesiredAccess, PinHandle);
+    }
+    else
+    {
+        /* now create the pin */
+        Status = KsCreatePin(MixerData->hDevice, PinConnect, DesiredAccess, PinHandle);
+
+        /* normalize status */
+        if (Status == STATUS_SUCCESS)
+            MixerStatus = MM_STATUS_SUCCESS;
+        else
+            MixerStatus = MM_STATUS_UNSUCCESSFUL;
+    }
+
+    /* free create info */
+    MixerContext->Free(PinConnect);
+
+    /* done */
+    return MixerStatus;
+}
+
+MIXER_STATUS
+MMixerGetMidiInfoByIndexAndType(
+    IN  PMIXER_LIST MixerList,
+    IN  ULONG DeviceIndex,
+    IN  ULONG bMidiInputType,
+    OUT LPMIDI_INFO *OutMidiInfo)
+{
+    ULONG Index = 0;
+    PLIST_ENTRY Entry, ListHead;
+    LPMIDI_INFO MidiInfo;
+
+    if (bMidiInputType)
+        ListHead = &MixerList->MidiInList;
+    else
+        ListHead = &MixerList->MidiOutList;
+
+    /* get first entry */
+    Entry = ListHead->Flink;
+
+    while(Entry != ListHead)
+    {
+        MidiInfo = (LPMIDI_INFO)CONTAINING_RECORD(Entry, MIDI_INFO, Entry);
+
+        if (Index == DeviceIndex)
+        {
+            *OutMidiInfo = MidiInfo;
+            return MM_STATUS_SUCCESS;
+        }
+        Index++;
+        Entry = Entry->Flink;
+    }
+
+    return MM_STATUS_INVALID_PARAMETER;
+}
+
+MIXER_STATUS
+MMixerMidiOutCapabilities(
+    IN PMIXER_CONTEXT MixerContext,
+    IN ULONG DeviceIndex,
+    OUT LPMIDIOUTCAPSW Caps)
+{
+    PMIXER_LIST MixerList;
+    MIXER_STATUS Status;
+    LPMIDI_INFO MidiInfo;
+
+    /* verify mixer context */
+    Status = MMixerVerifyContext(MixerContext);
+
+    if (Status != MM_STATUS_SUCCESS)
+    {
+        /* invalid context passed */
+        return Status;
+    }
+
+    /* grab mixer list */
+    MixerList = (PMIXER_LIST)MixerContext->MixerContext;
+
+    /* find destination midi */
+    Status = MMixerGetMidiInfoByIndexAndType(MixerList, DeviceIndex, FALSE, &MidiInfo);
+    if (Status != MM_STATUS_SUCCESS)
+    {
+        /* failed to find midi info */
+        return MM_STATUS_UNSUCCESSFUL;
+    }
+
+    /* copy capabilities */
+    MixerContext->Copy(Caps, &MidiInfo->u.OutCaps, sizeof(MIDIOUTCAPSW));
+
+    return MM_STATUS_SUCCESS;
+}
+
+MIXER_STATUS
+MMixerMidiInCapabilities(
+    IN PMIXER_CONTEXT MixerContext,
+    IN ULONG DeviceIndex,
+    OUT LPMIDIINCAPSW Caps)
+{
+    PMIXER_LIST MixerList;
+    MIXER_STATUS Status;
+    LPMIDI_INFO MidiInfo;
+
+    /* verify mixer context */
+    Status = MMixerVerifyContext(MixerContext);
+
+    if (Status != MM_STATUS_SUCCESS)
+    {
+        /* invalid context passed */
+        return Status;
+    }
+
+    /* grab mixer list */
+    MixerList = (PMIXER_LIST)MixerContext->MixerContext;
+
+    /* find destination midi */
+    Status = MMixerGetMidiInfoByIndexAndType(MixerList, DeviceIndex, TRUE, &MidiInfo);
+    if (Status != MM_STATUS_SUCCESS)
+    {
+        /* failed to find midi info */
+        return MM_STATUS_UNSUCCESSFUL;
+    }
+
+    /* copy capabilities */
+    MixerContext->Copy(Caps, &MidiInfo->u.InCaps, sizeof(MIDIINCAPSW));
+
+    return MM_STATUS_SUCCESS;
+}
+
+MIXER_STATUS
+MMixerGetMidiDevicePath(
+    IN PMIXER_CONTEXT MixerContext,
+    IN ULONG bMidiIn,
+    IN ULONG DeviceId,
+    OUT LPWSTR * DevicePath)
+{
+    PMIXER_LIST MixerList;
+    LPMIXER_DATA MixerData;
+    LPMIDI_INFO MidiInfo;
+    ULONG Length;
+    MIXER_STATUS Status;
+
+    /* verify mixer context */
+    Status = MMixerVerifyContext(MixerContext);
+
+    if (Status != MM_STATUS_SUCCESS)
+    {
+        /* invalid context passed */
+        return Status;
+    }
+
+    /* grab mixer list */
+    MixerList = (PMIXER_LIST)MixerContext->MixerContext;
+
+    /* find destination midi */
+    Status = MMixerGetMidiInfoByIndexAndType(MixerList, DeviceId, bMidiIn, &MidiInfo);
+    if (Status != MM_STATUS_SUCCESS)
+    {
+        /* failed to find midi info */
+        return MM_STATUS_INVALID_PARAMETER;
+    }
+
+    /* get associated device id */
+    MixerData = MMixerGetDataByDeviceId(MixerList, MidiInfo->DeviceId);
+    if (!MixerData)
+        return MM_STATUS_INVALID_PARAMETER;
+
+    /* calculate length */
+    Length = wcslen(MixerData->DeviceName)+1;
+
+    /* allocate destination buffer */
+    *DevicePath = MixerContext->Alloc(Length * sizeof(WCHAR));
+
+    if (!*DevicePath)
+    {
+        /* no memory */
+        return MM_STATUS_NO_MEMORY;
+    }
+
+    /* copy device path */
+    MixerContext->Copy(*DevicePath, MixerData->DeviceName, Length * sizeof(WCHAR));
+
+    /* done */
+    return MM_STATUS_SUCCESS;
+}
+
+MIXER_STATUS
+MMixerSetMidiStatus(
+    IN PMIXER_CONTEXT MixerContext,
+    IN HANDLE PinHandle,
+    IN KSSTATE State)
+{
+    KSPROPERTY Property;
+    ULONG Length;
+
+    /* setup property request */
+    Property.Set = KSPROPSETID_Connection;
+    Property.Id = KSPROPERTY_CONNECTION_STATE;
+    Property.Flags = KSPROPERTY_TYPE_SET;
+
+    return MixerContext->Control(PinHandle, IOCTL_KS_PROPERTY, &Property, sizeof(KSPROPERTY), &State, sizeof(KSSTATE), &Length);
+}
+
+MIXER_STATUS
+MMixerOpenMidi(
+    IN PMIXER_CONTEXT MixerContext,
+    IN ULONG DeviceIndex,
+    IN ULONG bMidiIn,
+    IN PIN_CREATE_CALLBACK CreateCallback,
+    IN PVOID Context,
+    OUT PHANDLE PinHandle)
+{
+    PMIXER_LIST MixerList;
+    MIXER_STATUS Status;
+    LPMIDI_INFO MidiInfo;
+    ACCESS_MASK DesiredAccess = 0;
+
+    /* verify mixer context */
+    Status = MMixerVerifyContext(MixerContext);
+
+    if (Status != MM_STATUS_SUCCESS)
+    {
+        /* invalid context passed */
+        return Status;
+    }
+
+    /* grab mixer list */
+    MixerList = (PMIXER_LIST)MixerContext->MixerContext;
+
+    /* find destination midi */
+    Status = MMixerGetMidiInfoByIndexAndType(MixerList, DeviceIndex, bMidiIn, &MidiInfo);
+    if (Status != MM_STATUS_SUCCESS)
+    {
+        /* failed to find midi info */
+        return MM_STATUS_INVALID_PARAMETER;
+    }
+
+    /* get desired access */
+    if (bMidiIn)
+    {
+        DesiredAccess |= GENERIC_READ;
+    }
+     else
+    {
+        DesiredAccess |= GENERIC_WRITE;
+    }
+
+    /* now try open the pin */
+    return MMixerOpenMidiPin(MixerContext, MixerList, MidiInfo->DeviceId, MidiInfo->PinId, DesiredAccess, CreateCallback, Context, PinHandle);
+}
+
+ULONG
+MMixerGetMidiInCount(
+    IN PMIXER_CONTEXT MixerContext)
+{
+    PMIXER_LIST MixerList;
+    MIXER_STATUS Status;
+
+     /* verify mixer context */
+    Status = MMixerVerifyContext(MixerContext);
+
+    if (Status != MM_STATUS_SUCCESS)
+    {
+        /* invalid context passed */
+        return Status;
+    }
+
+    /* grab mixer list */
+    MixerList = (PMIXER_LIST)MixerContext->MixerContext;
+
+    return MixerList->MidiInListCount;
+}
+
+ULONG
+MMixerGetMidiOutCount(
+    IN PMIXER_CONTEXT MixerContext)
+{
+    PMIXER_LIST MixerList;
+    MIXER_STATUS Status;
+
+     /* verify mixer context */
+    Status = MMixerVerifyContext(MixerContext);
+
+    if (Status != MM_STATUS_SUCCESS)
+    {
+        /* invalid context passed */
+        return Status;
+    }
+
+    /* grab mixer list */
+    MixerList = (PMIXER_LIST)MixerContext->MixerContext;
+
+    return MixerList->MidiOutListCount;
+}
index cd6b0a0..b04b50c 100644 (file)
@@ -447,11 +447,14 @@ MMixerInitialize(
      MixerList->MixerDataCount = 0;
      MixerList->WaveInListCount = 0;
      MixerList->WaveOutListCount = 0;
+     MixerList->MidiInListCount = 0;
+     MixerList->MidiOutListCount = 0;
      InitializeListHead(&MixerList->MixerList);
      InitializeListHead(&MixerList->MixerData);
      InitializeListHead(&MixerList->WaveInList);
      InitializeListHead(&MixerList->WaveOutList);
-
+     InitializeListHead(&MixerList->MidiInList);
+     InitializeListHead(&MixerList->MidiOutList);
 
      /* store mixer list */
      MixerContext->MixerContext = (PVOID)MixerList;
index c7abbb6..846d4e9 100644 (file)
@@ -122,6 +122,15 @@ ULONG
 MMixerGetWaveOutCount(
     IN PMIXER_CONTEXT MixerContext);
 
+ULONG
+MMixerGetMidiInCount(
+    IN PMIXER_CONTEXT MixerContext);
+
+ULONG
+MMixerGetMidiOutCount(
+    IN PMIXER_CONTEXT MixerContext);
+
+
 
 MIXER_STATUS
 MMixerGetCapabilities(
@@ -199,3 +208,37 @@ MMixerGetWaveDevicePath(
     IN ULONG bWaveIn,
     IN ULONG DeviceId,
     OUT LPWSTR * DevicePath);
+
+MIXER_STATUS
+MMixerMidiOutCapabilities(
+    IN PMIXER_CONTEXT MixerContext,
+    IN ULONG DeviceIndex,
+    OUT LPMIDIOUTCAPSW Caps);
+
+MIXER_STATUS
+MMixerMidiInCapabilities(
+    IN PMIXER_CONTEXT MixerContext,
+    IN ULONG DeviceIndex,
+    OUT LPMIDIINCAPSW Caps);
+
+MIXER_STATUS
+MMixerGetMidiDevicePath(
+    IN PMIXER_CONTEXT MixerContext,
+    IN ULONG bMidiIn,
+    IN ULONG DeviceId,
+    OUT LPWSTR * DevicePath);
+
+MIXER_STATUS
+MMixerSetMidiStatus(
+    IN PMIXER_CONTEXT MixerContext,
+    IN HANDLE PinHandle,
+    IN KSSTATE State);
+
+MIXER_STATUS
+MMixerOpenMidi(
+    IN PMIXER_CONTEXT MixerContext,
+    IN ULONG DeviceIndex,
+    IN ULONG bMidiIn,
+    IN PIN_CREATE_CALLBACK CreateCallback,
+    IN PVOID Context,
+    OUT PHANDLE PinHandle);
index 21d6551..c2d7fda 100644 (file)
@@ -5,6 +5,7 @@
        <define name="NDEBUG">1</define>
        <file>controls.c</file>
        <file>filter.c</file>
+       <file>midi.c</file>
        <file>mixer.c</file>
        <file>sup.c</file>
        <file>wave.c</file>
index b854c2e..8a4855f 100644 (file)
@@ -128,16 +128,38 @@ typedef struct
     }u;
 }WAVE_INFO, *LPWAVE_INFO;
 
+typedef struct
+{
+    LIST_ENTRY Entry;
+    ULONG DeviceId;
+    ULONG PinId;
+    union
+    {
+        MIDIOUTCAPSW OutCaps;
+        MIDIINCAPSW InCaps;
+    }u;
+
+}MIDI_INFO, *LPMIDI_INFO;
+
 typedef struct
 {
     ULONG MixerListCount;
     LIST_ENTRY MixerList;
+
     ULONG MixerDataCount;
     LIST_ENTRY MixerData;
+
     ULONG WaveInListCount;
     LIST_ENTRY WaveInList;
+
     ULONG WaveOutListCount;
     LIST_ENTRY WaveOutList;
+
+    ULONG MidiInListCount;
+    LIST_ENTRY MidiInList;
+
+    ULONG MidiOutListCount;
+    LIST_ENTRY MidiOutList;
 }MIXER_LIST, *PMIXER_LIST;
 
 typedef struct
@@ -196,16 +218,6 @@ MMixerFreeMixerInfo(
     IN PMIXER_CONTEXT MixerContext,
     IN LPMIXER_INFO MixerInfo);
 
-MIXER_STATUS
-MMixerGetTargetPins(
-    IN PMIXER_CONTEXT MixerContext,
-    IN PKSMULTIPLE_ITEM NodeTypes,
-    IN PKSMULTIPLE_ITEM NodeConnections,
-    IN ULONG NodeIndex,
-    IN ULONG bUpDirection,
-    OUT PULONG Pins,
-    IN ULONG PinCount);
-
 MIXER_STATUS
 MMixerGetPhysicalConnection(
     IN PMIXER_CONTEXT MixerContext,
@@ -213,11 +225,6 @@ MMixerGetPhysicalConnection(
     IN ULONG PinId,
     OUT PKSPIN_PHYSICALCONNECTION *OutConnection);
 
-ULONG
-MMixerGetIndexOfGuid(
-    PKSMULTIPLE_ITEM MultipleItem,
-    LPCGUID NodeType);
-
 MIXER_STATUS
 MMixerSetupFilter(
     IN PMIXER_CONTEXT MixerContext,
@@ -225,24 +232,24 @@ MMixerSetupFilter(
     IN LPMIXER_DATA MixerData,
     IN PULONG DeviceCount);
 
-MIXER_STATUS
-MMixerGetTargetPinsByNodeConnectionIndex(
+PKSPIN_CONNECT
+MMixerAllocatePinConnect(
     IN PMIXER_CONTEXT MixerContext,
-    IN PKSMULTIPLE_ITEM NodeConnections,
-    IN PKSMULTIPLE_ITEM NodeTypes,
-    IN ULONG bUpDirection,
-    IN ULONG NodeConnectionIndex,
-    IN ULONG PinCount,
-    OUT PULONG Pins);
+    ULONG DataFormatSize);
 
 MIXER_STATUS
-MMixerGetControlsFromPin(
+MMixerGetAudioPinDataRanges(
     IN PMIXER_CONTEXT MixerContext,
-    IN PKSMULTIPLE_ITEM NodeConnections,
-    IN PKSMULTIPLE_ITEM NodeTypes,
+    IN HANDLE hDevice,
     IN ULONG PinId,
-    IN ULONG bUpDirection,
-    OUT PULONG Nodes);
+    IN OUT PKSMULTIPLE_ITEM * OutMultipleItem);
+
+VOID
+MMixerInitializeMidiForFilter(
+    IN PMIXER_CONTEXT MixerContext,
+    IN PMIXER_LIST MixerList,
+    IN LPMIXER_DATA MixerData,
+    IN PTOPOLOGY Topology);
 
 MIXER_STATUS
 MMixerVerifyContext(
@@ -314,12 +321,6 @@ MMixerCreateMixerData(
     IN HANDLE hDevice,
     IN HANDLE hKey);
 
-MIXER_STATUS
-MMixerGetDeviceName(
-    IN PMIXER_CONTEXT MixerContext,
-    IN LPMIXER_INFO MixerInfo,
-    IN HANDLE hKey);
-
 MIXER_STATUS
 MMixerInitializeWaveInfo(
     IN PMIXER_CONTEXT MixerContext,
@@ -337,6 +338,18 @@ MMixerAddEvent(
     IN PVOID MixerEvent,
     IN PMIXER_EVENT MixerEventRoutine);
 
+MIXER_STATUS
+MMixerGetDeviceName(
+    IN PMIXER_CONTEXT MixerContext,
+    OUT LPWSTR DeviceName,
+    IN HANDLE hKey);
+
+VOID
+MMixerInitializePinConnect(
+    IN OUT PKSPIN_CONNECT PinConnect,
+    IN ULONG PinId);
+
+
 /* topology.c */
 
 MIXER_STATUS
@@ -448,3 +461,9 @@ MMixerIsTopologyNodeReserved(
     IN PTOPOLOGY Topology,
     IN ULONG NodeIndex,
     OUT PULONG bReserved);
+
+VOID
+MMixerGetTopologyPinCount(
+    IN PTOPOLOGY Topology,
+    OUT PULONG PinCount);
+
index 572afbe..126bcb5 100644 (file)
@@ -31,6 +31,11 @@ const GUID KSPROPSETID_General                  = {0x1464EDA5L, 0x6A8F, 0x11D1,
 const GUID KSPROPSETID_Topology                 = {0x720D4AC0L, 0x7533, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
 const GUID KSEVENTSETID_AudioControlChange      = {0xE85E9698L, 0xFA2F, 0x11D1, {0x95, 0xBD, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3}};
 
+const GUID KSDATAFORMAT_TYPE_MUSIC = {0xE725D360L, 0x62CC, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
+const GUID KSDATAFORMAT_SUBTYPE_MIDI = {0x1D262760L, 0xE957, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
+const GUID KSDATAFORMAT_SPECIFIER_NONE = {0x0F6417D6L, 0xC318, 0x11D0, {0xA4, 0x3F, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
+
+
 MIXER_STATUS
 MMixerVerifyContext(
     IN PMIXER_CONTEXT MixerContext)
@@ -444,7 +449,7 @@ MMixerCreateMixerData(
 MIXER_STATUS
 MMixerGetDeviceName(
     IN PMIXER_CONTEXT MixerContext,
-    IN LPMIXER_INFO MixerInfo,
+    OUT LPWSTR DeviceName,
     IN HANDLE hKey)
 {
     LPWSTR Name;
@@ -457,10 +462,10 @@ MMixerGetDeviceName(
     if (Status == MM_STATUS_SUCCESS)
     {
         /* copy device name */
-        MixerContext->Copy(MixerInfo->MixCaps.szPname, Name, min(wcslen(Name), MAXPNAMELEN-1) * sizeof(WCHAR));
+        MixerContext->Copy(DeviceName, Name, min(wcslen(Name), MAXPNAMELEN-1) * sizeof(WCHAR));
 
         /* make sure its null terminated */
-        MixerInfo->MixCaps.szPname[MAXPNAMELEN-1] = L'\0';
+        DeviceName[MAXPNAMELEN-1] = L'\0';
 
         /* free device name */
         MixerContext->Free(Name);
@@ -473,14 +478,14 @@ MMixerGetDeviceName(
     if (Status != MM_STATUS_SUCCESS)
         return Status;
 
-    Status = MixerContext->QueryKeyValue(hKey, L"FriendlyName", (PVOID*)&Name, &Length, &Type);
+    Status = MixerContext->QueryKeyValue(hTemp, L"FriendlyName", (PVOID*)&Name, &Length, &Type);
     if (Status == MM_STATUS_SUCCESS)
     {
         /* copy device name */
-        MixerContext->Copy(MixerInfo->MixCaps.szPname, Name, min(wcslen(Name), MAXPNAMELEN-1) * sizeof(WCHAR));
+        MixerContext->Copy(DeviceName, Name, min(wcslen(Name), MAXPNAMELEN-1) * sizeof(WCHAR));
 
         /* make sure its null terminated */
-        MixerInfo->MixCaps.szPname[MAXPNAMELEN-1] = L'\0';
+        DeviceName[MAXPNAMELEN-1] = L'\0';
 
         /* free device name */
         MixerContext->Free(Name);
@@ -489,3 +494,21 @@ MMixerGetDeviceName(
     MixerContext->CloseKey(hTemp);
     return Status;
 }
+
+VOID
+MMixerInitializePinConnect(
+    IN OUT PKSPIN_CONNECT PinConnect,
+    IN ULONG PinId)
+{
+    PinConnect->Interface.Set = KSINTERFACESETID_Standard;
+    PinConnect->Interface.Id = KSINTERFACE_STANDARD_STREAMING;
+    PinConnect->Interface.Flags = 0;
+    PinConnect->Medium.Set = KSMEDIUMSETID_Standard;
+    PinConnect->Medium.Id = KSMEDIUM_TYPE_ANYINSTANCE;
+    PinConnect->Medium.Flags = 0;
+    PinConnect->PinToHandle = NULL;
+    PinConnect->PinId = PinId;
+    PinConnect->Priority.PriorityClass = KSPRIORITY_NORMAL;
+    PinConnect->Priority.PrioritySubClass = 1;
+}
+
index 06f569a..44e85da 100644 (file)
@@ -983,6 +983,15 @@ MMixerGetNextNodesFromNodeIndex(
     *OutNodesCount = TopologyNodesCount;
 }
 
+VOID
+MMixerGetTopologyPinCount(
+    IN PTOPOLOGY Topology,
+    OUT PULONG PinCount)
+{
+    /* store pin count */
+    *PinCount = Topology->TopologyPinsCount;
+}
+
 MIXER_STATUS
 MMixerAllocateTopologyPinArray(
     IN PMIXER_CONTEXT MixerContext,
index c0d832a..c48f03b 100644 (file)
@@ -109,22 +109,7 @@ MMixerGetWaveInfoByIndexAndType(
 }
 
 
-VOID
-MMixerInitializePinConnect(
-    IN OUT PKSPIN_CONNECT PinConnect,
-    IN ULONG PinId)
-{
-    PinConnect->Interface.Set = KSINTERFACESETID_Standard;
-    PinConnect->Interface.Id = KSINTERFACE_STANDARD_STREAMING;
-    PinConnect->Interface.Flags = 0;
-    PinConnect->Medium.Set = KSMEDIUMSETID_Standard;
-    PinConnect->Medium.Id = KSMEDIUM_TYPE_ANYINSTANCE;
-    PinConnect->Medium.Flags = 0;
-    PinConnect->PinToHandle = NULL;
-    PinConnect->PinId = PinId;
-    PinConnect->Priority.PriorityClass = KSPRIORITY_NORMAL;
-    PinConnect->Priority.PrioritySubClass = 1;
-}
+
 
 VOID
 MMixerInitializeDataFormat(
@@ -369,7 +354,7 @@ MMixerInitializeWaveInfo(
     WaveInfo->PinId = Pins[0];
 
     /* sanity check */
-    ASSERT(wcslen(DeviceName) < MAXPNAMELEN);
+    ASSERT(wcslen(DeviceName) + 1 < MAXPNAMELEN);
 
     /* copy device name */
     if (bWaveIn)