ReactOS 0.4.16-dev-297-gc569aee
dispatcher.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel Streaming
4 * FILE: drivers/wdm/audio/sysaudio/dispatcher.c
5 * PURPOSE: System Audio graph builder
6 * PROGRAMMER: Johannes Anderwald
7 */
8
9#include "sysaudio.h"
10
11#define NDEBUG
12#include <debug.h>
13
18 PIRP Irp)
19{
20 PIO_STACK_LOCATION IoStack;
21
23 if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KS_PROPERTY)
24 {
26 }
27
28 /* unsupported request */
29 Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
30 Irp->IoStatus.Information = 0;
33}
34
39 PIRP Irp)
40{
41 DPRINT("Dispatch_fnClose called DeviceObject %p Irp %p\n", DeviceObject);
42
43 Irp->IoStatus.Status = STATUS_SUCCESS;
44 Irp->IoStatus.Information = 0;
46 return STATUS_SUCCESS;
47}
48
49static KSDISPATCH_TABLE DispatchTable =
50{
60 KsDispatchFastWriteFailure,
61};
62
67 IN PIRP Irp)
68{
70 KSOBJECT_HEADER ObjectHeader;
71 PKSOBJECT_CREATE_ITEM CreateItem;
72
73 DPRINT("DispatchCreateSysAudio entered\n");
74
75 /* allocate create item */
76 CreateItem = AllocateItem(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM));
77 if (!CreateItem)
78 {
79 Irp->IoStatus.Information = 0;
80 Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
83 }
84
85 /* zero create struct */
86 RtlZeroMemory(CreateItem, sizeof(KSOBJECT_CREATE_ITEM));
87
88 /* setup create context */
89 CreateItem->Create = DispatchCreateSysAudioPin;
90 RtlInitUnicodeString(&CreateItem->ObjectClass, KSSTRING_Pin);
91
92 /* allocate object header */
93 Status = KsAllocateObjectHeader(&ObjectHeader, 1, CreateItem, Irp, &DispatchTable);
94
95 DPRINT("KsAllocateObjectHeader result %x\n", Status);
96 /* complete the irp */
97 Irp->IoStatus.Information = 0;
98 Irp->IoStatus.Status = Status;
100 return Status;
101}
102
105 IN SYSAUDIODEVEXT *DeviceExtension)
106{
108 PKSOBJECT_CREATE_ITEM CreateItem;
109
110 /* allocate create item */
111 CreateItem = AllocateItem(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM));
112 if (!CreateItem)
114
115 /* initialize create item struct */
116 RtlZeroMemory(CreateItem, sizeof(KSOBJECT_CREATE_ITEM));
117 CreateItem->Create = DispatchCreateSysAudio;
118
119 /* FIXME Sysaudio doesnt need a named create item because it installs itself
120 * via the device interface
121 */
122 RtlInitUnicodeString(&CreateItem->ObjectClass, L"GLOBAL");
123 CreateItem->Flags = KSCREATE_ITEM_WILDCARD;
124
125 Status = KsAllocateDeviceHeader(&DeviceExtension->KsDeviceHeader,
126 1,
127 CreateItem);
128 return Status;
129}
130
133 IN SYSAUDIODEVEXT *DeviceExtension)
134{
136 UNICODE_STRING DeviceInstanceName = RTL_CONSTANT_STRING(L"\\Device\\kmixer\\GLOBAL");
137 UNICODE_STRING DevicePath = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\kmixer");
138
139 Status = ZwLoadDriver(&DevicePath);
140
141 if (NT_SUCCESS(Status))
142 {
143 Status = OpenDevice(&DeviceInstanceName, &DeviceExtension->KMixerHandle, &DeviceExtension->KMixerFileObject);
144 if (!NT_SUCCESS(Status))
145 {
146 DeviceExtension->KMixerHandle = NULL;
147 DeviceExtension->KMixerFileObject = NULL;
148 }
149 }
150
151 DPRINT("Status %lx KMixerHandle %p KMixerFileObject %p\n", Status, DeviceExtension->KMixerHandle, DeviceExtension->KMixerFileObject);
152 return STATUS_SUCCESS;
153}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
LONG NTSTATUS
Definition: precomp.h:26
MMRESULT OpenDevice(DeviceInfo **private_data, MIDIOPENDESC *open_desc, DWORD flags)
Definition: beepmidi.c:264
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
KSDDKAPI NTSTATUS NTAPI KsAllocateDeviceHeader(OUT KSDEVICE_HEADER *OutHeader, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList OPTIONAL)
Definition: api.c:522
KSDDKAPI NTSTATUS NTAPI KsAllocateObjectHeader(OUT KSOBJECT_HEADER *Header, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList OPTIONAL, IN PIRP Irp, IN KSDISPATCH_TABLE *Table)
Definition: api.c:610
KSDDKAPI NTSTATUS NTAPI KsDispatchInvalidDeviceRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1189
KSDDKAPI BOOLEAN NTAPI KsDispatchFastReadFailure(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: irp.c:1271
KSDDKAPI BOOLEAN NTAPI KsDispatchFastIoDeviceControlFailure(IN PFILE_OBJECT FileObject, IN BOOLEAN Wait, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength, IN ULONG IoControlCode, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: irp.c:1251
NTSTATUS SysAudioHandleProperty(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: control.c:288
NTSTATUS NTAPI Dispatch_fnDeviceIoControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.c:16
NTSTATUS NTAPI Dispatch_fnClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.c:37
NTSTATUS NTAPI DispatchCreateSysAudio(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatcher.c:65
NTSTATUS SysAudioAllocateDeviceHeader(IN SYSAUDIODEVEXT *DeviceExtension)
Definition: dispatcher.c:104
NTSTATUS SysAudioOpenKMixer(IN SYSAUDIODEVEXT *DeviceExtension)
Definition: dispatcher.c:132
NTSTATUS NTAPI DispatchCreateSysAudioPin(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pin.c:431
#define NonPagedPool
Definition: env_spec_w32.h:307
Status
Definition: gdiplustypes.h:25
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define KSSTRING_Pin
Definition: ks.h:48
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:29
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define IoCompleteRequest
Definition: irp.c:1240
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
struct _IO_STACK_LOCATION::@1579::@1580 DeviceIoControl
union _IO_STACK_LOCATION::@1579 Parameters
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define NTAPI
Definition: typedefs.h:36
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:248
#define IO_NO_INCREMENT
Definition: iotypes.h:598