Author: janderwald
Date: Thu Sep 24 21:24:22 2009
New Revision: 43138
URL:
http://svn.reactos.org/svn/reactos?rev=43138&view=rev
Log:
[WDMAUD.DRV]
- Implement copying mixer capabilities
[WDMAUD_KERNEL]
- Partly implement retrieving mixer capabilties
- Implement retrieving mixer name
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
Modified: trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wdmaud.drv/wdmau…
==============================================================================
--- trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c [iso-8859-1] Thu Sep 24 21:24:22 2009
@@ -125,6 +125,19 @@
/* This is pretty much a big hack right now */
switch ( DeviceType )
{
+ case MIXER_DEVICE_TYPE:
+ {
+ LPMIXERCAPS MixerCaps = (LPMIXERCAPS) Capabilities;
+
+ CopyWideString(MixerCaps->szPname, DeviceInfo.u.WaveOutCaps.szPname);
+
+ MixerCaps->cDestinations = DeviceInfo.u.MixCaps.cDestinations;
+ MixerCaps->fdwSupport = DeviceInfo.u.MixCaps.fdwSupport;
+ MixerCaps->vDriverVersion = DeviceInfo.u.MixCaps.vDriverVersion;
+ MixerCaps->wMid = DeviceInfo.u.MixCaps.wMid;
+ MixerCaps->wPid = DeviceInfo.u.MixCaps.wPid;
+ break;
+ }
case WAVE_OUT_DEVICE_TYPE :
{
LPWAVEOUTCAPS WaveOutCaps = (LPWAVEOUTCAPS) Capabilities;
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- 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] Thu Sep 24
21:24:22 2009
@@ -706,6 +706,13 @@
DPRINT("WdmAudCapabilities entered\n");
+ if (DeviceInfo->DeviceType == MIXER_DEVICE_TYPE)
+ {
+ Status = WdmAudMixerCapabilities(DeviceObject, DeviceInfo, ClientInfo);
+ return SetIrpIoStatus(Irp, Status, sizeof(WDMAUD_DEVICE_INFO));
+ }
+
+
Status = GetFilterIdAndPinId(DeviceObject, DeviceInfo, ClientInfo, &FilterId,
&PinId);
if (!NT_SUCCESS(Status))
{
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/interface.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- 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] Thu Sep 24
21:24:22 2009
@@ -34,6 +34,7 @@
union
{
+ MIXERCAPSW MixCaps;
MIXERCONTROLDETAILS MixDetails;
MIXERLINECONTROLSW MixControls;
MIXERLINEW MixLine;
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- 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] Thu Sep 24 21:24:22
2009
@@ -36,53 +36,67 @@
}
NTSTATUS
+GetSysAudioDevicePnpName(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN ULONG DeviceIndex,
+ OUT LPWSTR * Device)
+{
+ ULONG BytesReturned;
+ KSP_PIN Pin;
+ NTSTATUS Status;
+ PWDMAUD_DEVICE_EXTENSION DeviceExtension;
+
+ /* first check if the device index is within bounds */
+ if (DeviceIndex >= GetSysAudioDeviceCount(DeviceObject))
+ return STATUS_INVALID_PARAMETER;
+
+ /* setup the query request */
+ Pin.Property.Set = KSPROPSETID_Sysaudio;
+ Pin.Property.Id = KSPROPERTY_SYSAUDIO_DEVICE_INTERFACE_NAME;
+ Pin.Property.Flags = KSPROPERTY_TYPE_GET;
+ Pin.PinId = DeviceIndex;
+
+ DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+ /* query sysaudio for the device path */
+ Status = KsSynchronousIoControlDevice(DeviceExtension->FileObject, KernelMode,
IOCTL_KS_PROPERTY, (PVOID)&Pin, sizeof(KSPROPERTY) + sizeof(ULONG), NULL, 0,
&BytesReturned);
+
+ /* check if the request failed */
+ if (Status != STATUS_BUFFER_TOO_SMALL || BytesReturned == 0)
+ return STATUS_UNSUCCESSFUL;
+
+ /* allocate buffer for the device */
+ *Device = ExAllocatePool(NonPagedPool, BytesReturned);
+ if (!Device)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ /* query sysaudio again for the device path */
+ Status = KsSynchronousIoControlDevice(DeviceExtension->FileObject, KernelMode,
IOCTL_KS_PROPERTY, (PVOID)&Pin, sizeof(KSPROPERTY) + sizeof(ULONG), (PVOID)*Device,
BytesReturned, &BytesReturned);
+
+ if (!NT_SUCCESS(Status))
+ {
+ /* failed */
+ ExFreePool(*Device);
+ return Status;
+ }
+
+ return Status;
+}
+
+NTSTATUS
OpenSysAudioDeviceByIndex(
IN PDEVICE_OBJECT DeviceObject,
IN ULONG DeviceIndex,
IN PHANDLE DeviceHandle,
IN PFILE_OBJECT * FileObject)
{
- LPWSTR Device;
+ LPWSTR Device = NULL;
+ NTSTATUS Status;
HANDLE hDevice;
- ULONG BytesReturned;
- KSP_PIN Pin;
- NTSTATUS Status;
- PWDMAUD_DEVICE_EXTENSION DeviceExtension;
-
- /* first check if the device index is within bounds */
- if (DeviceIndex >= GetSysAudioDeviceCount(DeviceObject))
- return STATUS_INVALID_PARAMETER;
-
- /* setup the query request */
- Pin.Property.Set = KSPROPSETID_Sysaudio;
- Pin.Property.Id = KSPROPERTY_SYSAUDIO_DEVICE_INTERFACE_NAME;
- Pin.Property.Flags = KSPROPERTY_TYPE_GET;
- Pin.PinId = DeviceIndex;
-
-
- DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
- /* query sysaudio for the device path */
- Status = KsSynchronousIoControlDevice(DeviceExtension->FileObject, KernelMode,
IOCTL_KS_PROPERTY, (PVOID)&Pin, sizeof(KSPROPERTY) + sizeof(ULONG), NULL, 0,
&BytesReturned);
-
- /* check if the request failed */
- if (Status != STATUS_BUFFER_TOO_SMALL || BytesReturned == 0)
- return STATUS_UNSUCCESSFUL;
-
- /* allocate buffer for the device */
- Device = ExAllocatePool(NonPagedPool, BytesReturned);
- if (!Device)
- return STATUS_INSUFFICIENT_RESOURCES;
-
- /* query sysaudio again for the device path */
- Status = KsSynchronousIoControlDevice(DeviceExtension->FileObject, KernelMode,
IOCTL_KS_PROPERTY, (PVOID)&Pin, sizeof(KSPROPERTY) + sizeof(ULONG), (PVOID)Device,
BytesReturned, &BytesReturned);
-
- if (!NT_SUCCESS(Status))
- {
- /* failed */
- ExFreePool(Device);
- return Status;
- }
+
+ Status = GetSysAudioDevicePnpName(DeviceObject, DeviceIndex, &Device);
+ if (!NT_SUCCESS(Status))
+ return Status;
/* now open the device */
Status = WdmAudOpenSysAudioDevice(Device, &hDevice);
@@ -228,6 +242,122 @@
return Count;
}
+ULONG
+IsOutputMixer(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN ULONG DeviceIndex)
+{
+ ULONG DeviceCount, Index, Count;
+ NTSTATUS Status;
+ HANDLE hDevice;
+ PFILE_OBJECT FileObject;
+ PKSMULTIPLE_ITEM MultipleItem;
+
+ /* get number of devices */
+ DeviceCount = GetSysAudioDeviceCount(DeviceObject);
+
+ if (!DeviceCount)
+ return 0;
+
+ Index = 0;
+ Count = 0;
+ do
+ {
+ /* open the virtual audio device */
+ Status = OpenSysAudioDeviceByIndex(DeviceObject, Index, &hDevice,
&FileObject);
+
+ if (NT_SUCCESS(Status))
+ {
+ /* retrieve all available node types */
+ Status = GetFilterNodeTypes(FileObject, &MultipleItem);
+ if (NT_SUCCESS(Status))
+ {
+ if (CountNodeType(MultipleItem, (LPGUID)&KSNODETYPE_DAC))
+ {
+ /* increment (output) mixer count */
+ if (DeviceIndex == Count)
+ {
+ ExFreePool(MultipleItem);
+ ObDereferenceObject(FileObject);
+ ZwClose(hDevice);
+ return TRUE;
+ }
+
+ Count++;
+ }
+
+ if (CountNodeType(MultipleItem, (LPGUID)&KSNODETYPE_ADC))
+ {
+ /* increment (input) mixer count */
+ if (DeviceIndex == Count)
+ {
+ ExFreePool(MultipleItem);
+ ObDereferenceObject(FileObject);
+ ZwClose(hDevice);
+ return FALSE;
+ }
+ Count++;
+ }
+ ExFreePool(MultipleItem);
+ }
+ ObDereferenceObject(FileObject);
+ ZwClose(hDevice);
+ }
+
+ Index++;
+ }while(Index < DeviceCount);
+
+ ASSERT(0);
+ return FALSE;
+}
+
+
+
+
+NTSTATUS
+WdmAudMixerCapabilities(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PWDMAUD_DEVICE_INFO DeviceInfo,
+ IN PWDMAUD_CLIENT ClientInfo)
+{
+ NTSTATUS Status;
+ LPWSTR Device;
+ WCHAR Buffer[100];
+
+ Status = GetSysAudioDevicePnpName(DeviceObject,
DeviceInfo->DeviceIndex,&Device);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to get device name %x\n", Status);
+ return Status;
+ }
+
+ DeviceInfo->u.MixCaps.cDestinations = 1; //FIXME
+
+ Status = FindProductName(Device, sizeof(Buffer) / sizeof(WCHAR), Buffer);
+
+ /* check for success */
+ if (!NT_SUCCESS(Status))
+ {
+ DeviceInfo->u.MixCaps.szPname[0] = L'\0';
+ }
+ else
+ {
+ if (IsOutputMixer(DeviceObject, DeviceInfo->DeviceIndex))
+ {
+ wcscat(Buffer, L" output");
+ }
+ else
+ {
+ wcscat(Buffer, L" Input");
+ }
+ RtlMoveMemory(DeviceInfo->u.MixCaps.szPname, Buffer, min(MAXPNAMELEN,
wcslen(Buffer)+1) * sizeof(WCHAR));
+ DeviceInfo->u.MixCaps.szPname[MAXPNAMELEN-1] = L'\0';
+ }
+
+ return Status;
+}
+
+
NTSTATUS
WdmAudControlOpenMixer(
IN PDEVICE_OBJECT DeviceObject,
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- 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] Thu Sep 24
21:24:22 2009
@@ -108,4 +108,16 @@
IN LPWSTR DeviceName,
OUT PHANDLE Handle);
+NTSTATUS
+FindProductName(
+ IN LPWSTR PnpName,
+ IN ULONG ProductNameSize,
+ OUT LPWSTR ProductName);
+
+NTSTATUS
+WdmAudMixerCapabilities(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PWDMAUD_DEVICE_INFO DeviceInfo,
+ IN PWDMAUD_CLIENT ClientInfo);
+
#endif