Author: janderwald
Date: Tue Feb 10 10:28:24 2009
New Revision: 39535
URL:
http://svn.reactos.org/svn/reactos?rev=39535&view=rev
Log:
- Handle IRP_MN_QUERY_PNP_DEVICE_STATE
- Implement opening KS_CATEGORY_AUDIO devices (used with extreme hack since opening sym
link is not working atm)
Modified:
trunk/reactos/drivers/wdm/audio/sysaudio/main.c
trunk/reactos/drivers/wdm/audio/sysaudio/sysaudio.h
Modified: trunk/reactos/drivers/wdm/audio/sysaudio/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/sysaudio/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/sysaudio/main.c [iso-8859-1] Tue Feb 10 10:28:24 2009
@@ -16,76 +16,146 @@
//#include <dxsdk/mediaobj.h>
#include "sysaudio.h"
-
-
-const GUID KS_CATEGORY_AUDIO = {0x6994AD04, 0x93EF, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0,
0xC9, 0x22, 0x31, 0x96}};
-VOID
-NTAPI
-SysAudio_Unload(IN PDRIVER_OBJECT DriverObject)
-{
- DPRINT1("SysAudio_Unload called\n");
-}
-
-NTSTATUS
-NTAPI
-SysAudio_Pnp(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- PIO_STACK_LOCATION IrpStack;
- UNICODE_STRING SymlinkName =
RTL_CONSTANT_STRING(L"\\DosDevices\\sysaudio");
- SYSAUDIODEVEXT *DeviceExtension;
-
- DPRINT1("SysAudio_Pnp called\n");
-
-
- IrpStack = IoGetCurrentIrpStackLocation(Irp);
-
- DeviceExtension = (SYSAUDIODEVEXT*)DeviceObject->DeviceExtension;
-
- if (IrpStack->MinorFunction == IRP_MN_REMOVE_DEVICE)
- {
- if (DeviceExtension->EchoCancelNotificationEntry)
-
IoUnregisterPlugPlayNotification(DeviceExtension->EchoCancelNotificationEntry);
-
- if (DeviceExtension->KsAudioNotificationEntry)
-
IoUnregisterPlugPlayNotification(DeviceExtension->KsAudioNotificationEntry);
-
- IoDeleteSymbolicLink(&SymlinkName);
- }
-
- return KsDefaultDispatchPnp(DeviceObject, Irp);
-}
-
-NTSTATUS
-NTAPI
-DeviceInterfaceChangeCallback(
- IN PVOID NotificationStructure,
- IN PVOID Context)
-{
- DEVICE_INTERFACE_CHANGE_NOTIFICATION * Event =
(DEVICE_INTERFACE_CHANGE_NOTIFICATION*)NotificationStructure;
-
- DPRINT1("DeviceInterfaceChangeCallback called %p\n", Event);
- return STATUS_SUCCESS;
-}
-
-NTSTATUS
-NTAPI
-DispatchCreate(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- DPRINT1("DispatchCreate\n");
-
- return STATUS_SUCCESS;
-}
-
const GUID KSCATEGORY_AUDIO_DEVICE = {0xFBF6F530L, 0x07B9, 0x11D2, {0xA7,
0x1E, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}};
const GUID KSCATEGORY_PREFERRED_WAVEOUT_DEVICE = {0xD6C5066EL, 0x72C1, 0x11D2, {0x97,
0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}};
const GUID KSCATEGORY_PREFERRED_WAVEIN_DEVICE = {0xD6C50671L, 0x72C1, 0x11D2, {0x97,
0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}};
const GUID KSCATEGORY_PREFERRED_MIDIOUT_DEVICE = {0xD6C50674L, 0x72C1, 0x11D2, {0x97,
0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}};
-
-
+const GUID KS_CATEGORY_AUDIO = {0x6994AD04L, 0x93EF, 0x11D0, {0xA3,
0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
+const GUID GUID_DEVICE_INTERFACE_ARRIVAL = {0xCB3A4004L, 0x46F0, 0x11D0, {0xB0,
0x8F, 0x00, 0x60, 0x97, 0x13, 0x05, 0x3F}};
+const GUID GUID_DEVICE_INTERFACE_REMOVAL = {0xCB3A4005L, 0x46F0, 0x11D0, {0xB0,
0x8F, 0x00, 0x60, 0x97, 0x13, 0x05, 0x3F}};
+
+
+VOID
+NTAPI
+SysAudio_Unload(IN PDRIVER_OBJECT DriverObject)
+{
+ DPRINT1("SysAudio_Unload called\n");
+}
+
+NTSTATUS
+NTAPI
+SysAudio_Pnp(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ PIO_STACK_LOCATION IrpStack;
+ UNICODE_STRING SymlinkName =
RTL_CONSTANT_STRING(L"\\DosDevices\\sysaudio");
+ SYSAUDIODEVEXT *DeviceExtension;
+
+ DPRINT1("SysAudio_Pnp called\n");
+
+
+ IrpStack = IoGetCurrentIrpStackLocation(Irp);
+
+ DeviceExtension = (SYSAUDIODEVEXT*)DeviceObject->DeviceExtension;
+
+ if (IrpStack->MinorFunction == IRP_MN_REMOVE_DEVICE)
+ {
+ if (DeviceExtension->EchoCancelNotificationEntry)
+
IoUnregisterPlugPlayNotification(DeviceExtension->EchoCancelNotificationEntry);
+
+ if (DeviceExtension->KsAudioNotificationEntry)
+
IoUnregisterPlugPlayNotification(DeviceExtension->KsAudioNotificationEntry);
+
+ IoDeleteSymbolicLink(&SymlinkName);
+ }
+ else if (IrpStack->MinorFunction == IRP_MN_QUERY_PNP_DEVICE_STATE)
+ {
+ Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE;
+ }
+
+ return KsDefaultDispatchPnp(DeviceObject, Irp);
+}
+
+NTSTATUS
+NTAPI
+DeviceInterfaceChangeCallback(
+ IN PVOID NotificationStructure,
+ IN PVOID Context)
+{
+ DEVICE_INTERFACE_CHANGE_NOTIFICATION * Event;
+ SYSAUDIODEVEXT *DeviceExtension = (SYSAUDIODEVEXT*)Context;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ Event = (DEVICE_INTERFACE_CHANGE_NOTIFICATION*)NotificationStructure;
+
+ if (IsEqualGUIDAligned(&Event->Event,
+ &GUID_DEVICE_INTERFACE_ARRIVAL))
+ {
+ /* a new device has arrived */
+
+ PFILE_OBJECT FileObject = NULL;
+ PDEVICE_OBJECT DeviceObject = NULL;
+ UNICODE_STRING DeviceName;
+ PKSAUDIO_DEVICE_ENTRY DeviceEntry;
+
+ DeviceEntry = ExAllocatePool(NonPagedPool, sizeof(KSAUDIO_DEVICE_ENTRY));
+ if (!DeviceEntry)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ if (!RtlCreateUnicodeString(&DeviceEntry->DeviceName,
Event->SymbolicLinkName->Buffer))
+ {
+ ExFreePool(DeviceEntry);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+#if 1 //HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
+ RtlInitUnicodeString(&DeviceName, L"\\Device\\00000017");
+#else
+ RtlInitUnicodeString(&DeviceName, Event->SymbolicLinkName->Buffer);
+#endif
+
+ Status = IoGetDeviceObjectPointer(&DeviceName,
+ FILE_READ_DATA | FILE_WRITE_DATA,
+ &FileObject,
+ &DeviceObject);
+
+ if (!NT_SUCCESS(Status))
+ {
+ ExFreePool(DeviceEntry);
+ return Status;
+ }
+
+ DeviceEntry->DeviceObject = DeviceObject;
+ DeviceEntry->FileObject = FileObject;
+
+ InsertTailList(&DeviceExtension->KsAudioDeviceList,
&DeviceEntry->Entry);
+ DeviceExtension->NumberOfKsAudioDevices++;
+
+ DPRINT1("Successfully opened audio device\n");
+ return Status;
+ }
+ else if (IsEqualGUIDAligned(&Event->Event,
+ &GUID_DEVICE_INTERFACE_REMOVAL))
+ {
+ DPRINT1("Remove interface to audio device!\n");
+ ///FIXME
+ ///
+ return STATUS_SUCCESS;
+ }
+ else
+ {
+ UNICODE_STRING EventName, InterfaceGuid;
+
+ RtlStringFromGUID(&Event->Event, &EventName);
+ RtlStringFromGUID(&Event->InterfaceClassGuid, &InterfaceGuid);
+ DPRINT1("Unknown event: Event %wZ GUID %wZ\n", &EventName,
&InterfaceGuid);
+ return STATUS_SUCCESS;
+ }
+
+
+}
+
+NTSTATUS
+NTAPI
+DispatchCreate(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ DPRINT1("DispatchCreate\n");
+
+ return STATUS_SUCCESS;
+}
NTSTATUS
NTAPI
@@ -135,8 +205,8 @@
RtlZeroMemory(DeviceExtension, sizeof(SYSAUDIODEVEXT));
KeInitializeMutex(&DeviceExtension->Mutex, 0);
-
DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
+ InitializeListHead(&DeviceExtension->KsAudioDeviceList);
/* initialize create item struct */
RtlZeroMemory(&CreateItem, sizeof(KSOBJECT_CREATE_ITEM));
@@ -222,6 +292,24 @@
return Status;
}
+NTSTATUS
+NTAPI
+SysAudio_Stub(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ DPRINT1("SysAudio_Stub called\n");
+
+ /* TODO */
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ return STATUS_SUCCESS;
+}
+
+
NTSTATUS NTAPI
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
@@ -230,10 +318,19 @@
DPRINT1("System audio graph builder (sysaudio) started\n");
DPRINT1("Setting KS function handlers\n");
+
+#if KS_IMPLEMENTED
KsSetMajorFunctionHandler(DriverObject, IRP_MJ_CREATE);
KsSetMajorFunctionHandler(DriverObject, IRP_MJ_CLOSE);
KsSetMajorFunctionHandler(DriverObject, IRP_MJ_WRITE);
KsSetMajorFunctionHandler(DriverObject, IRP_MJ_DEVICE_CONTROL);
+#else
+ DriverObject->MajorFunction[IRP_MJ_CREATE] = SysAudio_Stub;
+ DriverObject->MajorFunction[IRP_MJ_CLOSE] = SysAudio_Stub;
+ DriverObject->MajorFunction[IRP_MJ_WRITE] = SysAudio_Stub;
+ DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = SysAudio_Stub;
+#endif
+
DriverObject->MajorFunction[IRP_MJ_POWER] = KsDefaultDispatchPower;
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = KsDefaultForwardIrp;
Modified: trunk/reactos/drivers/wdm/audio/sysaudio/sysaudio.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/sysaudio/sysaudio.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/sysaudio/sysaudio.h [iso-8859-1] Tue Feb 10 10:28:24
2009
@@ -1,6 +1,14 @@
#ifndef SYSAUDIO_H__
#define SYSAUDIO_H__
+typedef struct
+{
+ LIST_ENTRY Entry;
+ PDEVICE_OBJECT DeviceObject;
+ PFILE_OBJECT FileObject;
+ UNICODE_STRING DeviceName;
+
+}KSAUDIO_DEVICE_ENTRY, *PKSAUDIO_DEVICE_ENTRY;
typedef struct
@@ -8,13 +16,20 @@
PDEVICE_OBJECT PhysicalDeviceObject;
PDEVICE_OBJECT NextDeviceObject;
KSDEVICE_HEADER KsDeviceHeader;
+ ULONG NumberOfKsAudioDevices;
+ LIST_ENTRY KsAudioDeviceList;
PVOID KsAudioNotificationEntry;
PVOID EchoCancelNotificationEntry;
KMUTEX Mutex;
}SYSAUDIODEVEXT;
-
+BOOLEAN
+NTAPI
+ RtlCreateUnicodeString(
+ OUT PUNICODE_STRING DestinationString,
+ IN PCWSTR SourceString
+ );
#endif