Author: janderwald
Date: Tue Oct 27 00:10:05 2009
New Revision: 43788

URL: http://svn.reactos.org/svn/reactos?rev=43788&view=rev
Log:
[WDMAUD.DRV][WDMAUD_KERNEL][MMEBUDDY]
- Implement support for DRV_QUERYDEVICEINTERFACESIZE, DRV_QUERYDEVICEINTERFACE
- Required for DSound support

Modified:
    trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c
    trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
    trunk/reactos/drivers/wdm/audio/legacy/wdmaud/interface.h
    trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c
    trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h
    trunk/reactos/include/reactos/libs/sound/mmebuddy.h
    trunk/reactos/lib/drivers/sound/mmebuddy/mmewrap.c
    trunk/reactos/lib/drivers/sound/mmebuddy/wave/wodMessage.c

Modified: trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c?rev=43788&r1=43787&r2=43788&view=diff
==============================================================================
--- trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c [iso-8859-1] Tue Oct 27 
00:10:05 2009
@@ -555,6 +555,64 @@
 }
 
 MMRESULT
+GetDeviceInterfaceString(
+    IN  MMDEVICE_TYPE DeviceType,
+    IN  DWORD DeviceId,
+    IN  LPWSTR Interface,
+    IN  DWORD  InterfaceLength,
+    OUT  DWORD * InterfaceSize)
+{
+    WDMAUD_DEVICE_INFO DeviceInfo;
+    MMRESULT Result;
+
+    ZeroMemory(&DeviceInfo, sizeof(WDMAUD_DEVICE_INFO));
+    DeviceInfo.DeviceType = DeviceType;
+    DeviceInfo.DeviceIndex = DeviceId;
+
+
+    Result = SyncOverlappedDeviceIoControl(KernelHandle,
+                                           IOCTL_QUERYDEVICEINTERFACESTRING,
+                                           (LPVOID) &DeviceInfo,
+                                           sizeof(WDMAUD_DEVICE_INFO),
+                                           (LPVOID) &DeviceInfo,
+                                           sizeof(WDMAUD_DEVICE_INFO),
+                                           NULL);
+
+
+    if ( ! MMSUCCESS(Result) )
+    {
+        return TranslateInternalMmResult(Result);
+    }
+
+
+    if (!Interface)
+    {
+        SND_ASSERT(InterfaceSize);
+
+        *InterfaceSize = DeviceInfo.u.Interface.DeviceInterfaceStringSize;
+        return MMSYSERR_NOERROR;
+    }
+
+    if (InterfaceLength < DeviceInfo.u.Interface.DeviceInterfaceStringSize)
+    {
+        /* buffer is too small */
+        return MMSYSERR_MOREDATA;
+    }
+
+    DeviceInfo.u.Interface.DeviceInterfaceStringSize = InterfaceLength;
+    DeviceInfo.u.Interface.DeviceInterfaceString = Interface;
+
+    Result = SyncOverlappedDeviceIoControl(KernelHandle,
+                                           IOCTL_QUERYDEVICEINTERFACESTRING,
+                                           (LPVOID) &DeviceInfo,
+                                           sizeof(WDMAUD_DEVICE_INFO),
+                                           (LPVOID) &DeviceInfo,
+                                           sizeof(WDMAUD_DEVICE_INFO),
+                                           NULL);
+    return Result;
+}
+
+MMRESULT
 GetWdmPosition(
     IN  struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
     IN  MMTIME* Time)
@@ -734,6 +792,7 @@
 
         FuncTable.Open = OpenWdmSoundDevice;
         FuncTable.Close = CloseWdmSoundDevice;
+        FuncTable.GetDeviceInterfaceString = GetDeviceInterfaceString;
 #ifndef USERMODE_MIXER
         FuncTable.CommitWaveBuffer = WriteFileEx_Committer2;
 #else

Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c?rev=43788&r1=43787&r2=43788&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] 
(original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] Tue 
Oct 27 00:10:05 2009
@@ -203,6 +203,110 @@
 
 }
 
+NTSTATUS
+NTAPI
+WdmAudGetDeviceInterface(
+    IN  PDEVICE_OBJECT DeviceObject,
+    IN  PIRP Irp,
+    IN  PWDMAUD_DEVICE_INFO DeviceInfo)
+{
+    PWDMAUD_DEVICE_EXTENSION DeviceExtension;
+    NTSTATUS Status;
+    LPWSTR Device;
+    LPWAVE_INFO WaveInfo;
+    ULONG Size, Length;
+
+    /* get device extension */
+    DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+    /* 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 = GetWaveInfoByIndexAndType(DeviceObject, 
DeviceInfo->DeviceIndex, DeviceInfo->DeviceType, &WaveInfo);
+
+        /* check for success */
+        if (!NT_SUCCESS(Status))
+        {
+            /* invalid device id */
+            return SetIrpIoStatus(Irp, Status, sizeof(WDMAUD_DEVICE_INFO));
+        }
+
+        Status = GetSysAudioDevicePnpName(DeviceObject, WaveInfo->FilterId, 
&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);
+        }
+
+        ExFreePool(Device);
+        return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO));
+    }
+    else if (DeviceInfo->DeviceType == MIXER_DEVICE_TYPE)
+    {
+        if (DeviceInfo->DeviceIndex >= DeviceExtension->MixerInfoCount)
+        {
+            /* invalid device id */
+            return SetIrpIoStatus(Irp, STATUS_INVALID_PARAMETER, 
sizeof(WDMAUD_DEVICE_INFO));
+        }
+
+        Status = GetSysAudioDevicePnpName(DeviceObject, 
DeviceExtension->MixerInfo[DeviceInfo->DeviceIndex].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);
+        }
+
+        ExFreePool(Device);
+        return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO));
+    }
+
+    return SetIrpIoStatus(Irp, STATUS_INVALID_DEVICE_REQUEST, 
sizeof(WDMAUD_DEVICE_INFO));
+}
 
 NTSTATUS
 NTAPI
@@ -266,6 +370,8 @@
             return WdmAudSetControlDetails(DeviceObject, Irp, DeviceInfo, 
ClientInfo);
         case IOCTL_GETCONTROLDETAILS:
             return WdmAudGetControlDetails(DeviceObject, Irp, DeviceInfo, 
ClientInfo);
+        case IOCTL_QUERYDEVICEINTERFACESTRING:
+            return WdmAudGetDeviceInterface(DeviceObject, Irp, DeviceInfo);
         case IOCTL_GETPOS:
         case IOCTL_GETDEVID:
         case IOCTL_GETVOLUME:

Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/interface.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/wdmaud/interface.h?rev=43788&r1=43787&r2=43788&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/interface.h [iso-8859-1] 
(original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/interface.h [iso-8859-1] Tue 
Oct 27 00:10:05 2009
@@ -44,6 +44,11 @@
         AUXCAPSW     AuxCaps;
         WAVEINCAPSW  WaveInCaps;
         ULONGLONG    Position;
+        struct
+        {
+            LPWSTR DeviceInterfaceString;
+            ULONG DeviceInterfaceStringSize;
+        }Interface;
         KSSTATE State;
         ULONG Volume;
         ULONG FrameSize;
@@ -313,4 +318,22 @@
              METHOD_BUFFERED, \
              FILE_CREATE_TREE_CONNECTION | FILE_ANY_ACCESS)
 
+
+/// IOCTL_QUERYDEVICEINTERFACESTRING
+///
+/// Description: This IOCTL queries the mixer / playback / recording device 
for its device interface string
+///
+/// Arguments:  InputBuffer is a pointer to a WDMAUD_DEVICE_INFO structure,
+///             InputBufferSize is size of WDMAUD_DEVICE_INFO structure
+/// Note:       The DeviceType, DeviceIndex must be set
+/// Result:     The size is returned in Interface.DeviceInterfaceStringSize 
and if a buffer is supplied in Interface.DeviceInterfaceString
+///             the device interface string is stored
+/// ReturnCode:  STATUS_SUCCESS indicates success
+
+#define IOCTL_QUERYDEVICEINTERFACESTRING \
+    CTL_CODE(FILE_DEVICE_SOUND, \
+             15, \
+             METHOD_BUFFERED, \
+             FILE_CREATE_TREE_CONNECTION | FILE_ANY_ACCESS)
+
 #endif

Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c?rev=43788&r1=43787&r2=43788&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c [iso-8859-1] 
(original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c [iso-8859-1] Tue Oct 
27 00:10:05 2009
@@ -1536,6 +1536,7 @@
     MixerInfo->MixCaps.vDriverVersion = 1; //FIXME
     MixerInfo->MixCaps.fdwSupport = 0;
     MixerInfo->MixCaps.cDestinations = 1;
+    MixerInfo->DeviceIndex = DeviceIndex;
 
     /* get target pnp name */
     Status = GetSysAudioDevicePnpName(DeviceObject, DeviceIndex, &Device);

Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h?rev=43788&r1=43787&r2=43788&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h [iso-8859-1] 
(original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h [iso-8859-1] Tue Oct 
27 00:10:05 2009
@@ -67,7 +67,7 @@
 typedef struct
 {
     MIXERCAPSW    MixCaps;
-
+    ULONG DeviceIndex;
     LIST_ENTRY    LineList;
     ULONG ControlId;
 }MIXER_INFO, *LPMIXER_INFO;
@@ -277,4 +277,17 @@
     IN  ULONG FreeIndex);
 
 
+NTSTATUS
+GetWaveInfoByIndexAndType(
+    IN  PDEVICE_OBJECT DeviceObject,
+    IN  ULONG DeviceIndex,
+    IN  SOUND_DEVICE_TYPE DeviceType,
+    OUT LPWAVE_INFO *OutWaveInfo);
+
+NTSTATUS
+GetSysAudioDevicePnpName(
+    IN  PDEVICE_OBJECT DeviceObject,
+    IN  ULONG DeviceIndex,
+    OUT LPWSTR * Device);
+
 #endif

Modified: trunk/reactos/include/reactos/libs/sound/mmebuddy.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/sound/mmebuddy.h?rev=43788&r1=43787&r2=43788&view=diff
==============================================================================
--- trunk/reactos/include/reactos/libs/sound/mmebuddy.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/libs/sound/mmebuddy.h [iso-8859-1] Tue Oct 27 
00:10:05 2009
@@ -242,6 +242,14 @@
     IN  BOOL bStart);
 
 
+typedef MMRESULT(*MMQUERYDEVICEINTERFACESTRING_FUNC)(
+    IN  MMDEVICE_TYPE DeviceType,
+    IN  DWORD DeviceId,
+    IN  LPWSTR Interface,
+    IN  DWORD  InterfaceLength,
+    OUT  DWORD * InterfaceSize);
+
+
 typedef struct _MMFUNCTION_TABLE
 {
     union
@@ -265,6 +273,7 @@
 
     MMGETPOS_FUNC                   GetPos;
     MMSETSTATE_FUNC                 SetState;
+    MMQUERYDEVICEINTERFACESTRING_FUNC     GetDeviceInterfaceString;
 
     // Redundant
     //MMWAVEHEADER_FUNC               PrepareWaveHeader;
@@ -415,6 +424,15 @@
     IN  DWORD Size);
 
 MMRESULT
+MmeGetDeviceInterfaceString(
+    IN  MMDEVICE_TYPE DeviceType,
+    IN  DWORD DeviceId,
+    IN  LPWSTR Interface,
+    IN  DWORD  InterfaceLength,
+    OUT  DWORD * InterfaceSize);
+
+
+MMRESULT
 MmeSetState(
     IN  DWORD PrivateHandle,
     IN  BOOL bStart);

Modified: trunk/reactos/lib/drivers/sound/mmebuddy/mmewrap.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmebuddy/mmewrap.c?rev=43788&r1=43787&r2=43788&view=diff
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmebuddy/mmewrap.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmebuddy/mmewrap.c [iso-8859-1] Tue Oct 27 
00:10:05 2009
@@ -248,6 +248,39 @@
 }
 
 MMRESULT
+MmeGetDeviceInterfaceString(
+    IN  MMDEVICE_TYPE DeviceType,
+    IN  DWORD DeviceId,
+    IN  LPWSTR Interface,
+    IN  DWORD  InterfaceLength,
+    OUT  DWORD * InterfaceSize)
+{
+    MMRESULT Result;
+    PSOUND_DEVICE SoundDevice;
+    PMMFUNCTION_TABLE FunctionTable;
+
+    Result = GetSoundDevice(DeviceType, DeviceId, &SoundDevice);
+    if ( ! MMSUCCESS(Result) )
+        return TranslateInternalMmResult(Result);
+
+    Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
+    if ( ! MMSUCCESS(Result) )
+        return TranslateInternalMmResult(Result);
+
+    if ( FunctionTable->GetDeviceInterfaceString == NULL )
+    {
+        /* querying device interface string / size not supported */
+        return MMSYSERR_NOTSUPPORTED;
+    }
+
+    /* Call the driver */
+    Result = FunctionTable->GetDeviceInterfaceString(DeviceType, DeviceId, 
Interface, InterfaceLength, InterfaceSize);
+
+    return Result;
+}
+
+
+MMRESULT
 MmeGetPosition(
     IN  MMDEVICE_TYPE DeviceType,
     IN  DWORD DeviceId,

Modified: trunk/reactos/lib/drivers/sound/mmebuddy/wave/wodMessage.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmebuddy/wave/wodMessage.c?rev=43788&r1=43787&r2=43788&view=diff
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmebuddy/wave/wodMessage.c [iso-8859-1] 
(original)
+++ trunk/reactos/lib/drivers/sound/mmebuddy/wave/wodMessage.c [iso-8859-1] Tue 
Oct 27 00:10:05 2009
@@ -117,6 +117,18 @@
             Result = MmeGetPosition(WAVE_OUT_DEVICE_TYPE, DeviceId, 
PrivateHandle, (MMTIME*)Parameter1, Parameter2);
             break;
         }
+
+        case DRV_QUERYDEVICEINTERFACESIZE :
+        {
+            Result = MmeGetDeviceInterfaceString(WAVE_OUT_DEVICE_TYPE, 
DeviceId, NULL, 0, (DWORD*)Parameter1); //FIXME DWORD_PTR
+            break;
+        }
+
+        case DRV_QUERYDEVICEINTERFACE :
+        {
+            Result = MmeGetDeviceInterfaceString(WAVE_OUT_DEVICE_TYPE, 
DeviceId, (LPWSTR)Parameter1, Parameter2, NULL); //FIXME DWORD_PTR
+            break;
+        }
     }
 
     SND_TRACE(L"wodMessage returning MMRESULT %d\n", Result);


Reply via email to