ReactOS  0.4.13-dev-235-g7373cb3
pin.c File Reference
#include "sysaudio.h"
#include <debug.h>
Include dependency graph for pin.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI Pin_fnDeviceIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI Pin_fnWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI Pin_fnClose (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS SetMixerInputOutputFormat (IN PFILE_OBJECT FileObject, IN PKSDATAFORMAT InputFormat, IN PKSDATAFORMAT OutputFormat)
 
NTSTATUS CreateMixerPinAndSetFormat (IN HANDLE KMixerHandle, IN KSPIN_CONNECT *PinConnect, IN PKSDATAFORMAT InputFormat, IN PKSDATAFORMAT OutputFormat, OUT PHANDLE MixerPinHandle)
 
NTSTATUS NTAPI InstantiatePins (IN PKSAUDIO_DEVICE_ENTRY DeviceEntry, IN PKSPIN_CONNECT Connect, IN PDISPATCH_CONTEXT DispatchContext, IN PSYSAUDIODEVEXT DeviceExtension)
 
NTSTATUS GetConnectRequest (IN PIRP Irp, OUT PKSPIN_CONNECT *Result)
 
NTSTATUS NTAPI DispatchCreateSysAudioPin (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Variables

static KSDISPATCH_TABLE PinTable
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file pin.c.

Function Documentation

◆ CreateMixerPinAndSetFormat()

NTSTATUS CreateMixerPinAndSetFormat ( IN HANDLE  KMixerHandle,
IN KSPIN_CONNECT PinConnect,
IN PKSDATAFORMAT  InputFormat,
IN PKSDATAFORMAT  OutputFormat,
OUT PHANDLE  MixerPinHandle 
)

Definition at line 218 of file pin.c.

224 {
226  HANDLE PinHandle;
228 
229  Status = KsCreatePin(KMixerHandle, PinConnect, GENERIC_READ | GENERIC_WRITE, &PinHandle);
230 
231  if (!NT_SUCCESS(Status))
232  {
233  DPRINT1("Failed to create Mixer Pin with %x\n", Status);
234  return STATUS_UNSUCCESSFUL;
235  }
236 
237  Status = ObReferenceObjectByHandle(PinHandle,
240 
241  if (!NT_SUCCESS(Status))
242  {
243  DPRINT1("Failed to get file object with %x\n", Status);
244  return STATUS_UNSUCCESSFUL;
245  }
246 
248  if (!NT_SUCCESS(Status))
249  {
251  ZwClose(PinHandle);
252  return Status;
253  }
254 
256 
257  *MixerPinHandle = PinHandle;
258  return Status;
259 }
KSDDKAPI DWORD NTAPI KsCreatePin(HANDLE FilterHandle, PKSPIN_CONNECT Connect, ACCESS_MASK DesiredAccess, PHANDLE ConnectionHandle)
Definition: ksuser.c:192
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
enum OutputFormat_ OutputFormat
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
NTSTATUS SetMixerInputOutputFormat(IN PFILE_OBJECT FileObject, IN PKSDATAFORMAT InputFormat, IN PKSDATAFORMAT OutputFormat)
Definition: pin.c:178
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
* PFILE_OBJECT
Definition: iotypes.h:1954
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define GENERIC_READ
Definition: compat.h:124
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8

Referenced by InstantiatePins().

◆ DispatchCreateSysAudioPin()

NTSTATUS NTAPI DispatchCreateSysAudioPin ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 431 of file pin.c.

434 {
436  PIO_STACK_LOCATION IoStack;
437  PKSAUDIO_DEVICE_ENTRY DeviceEntry;
439  PDISPATCH_CONTEXT DispatchContext;
440 
441  DPRINT("DispatchCreateSysAudioPin entered\n");
442 
443  /* get current stack location */
445 
446  /* sanity checks */
447  ASSERT(IoStack->FileObject);
448  ASSERT(IoStack->FileObject->RelatedFileObject);
449  ASSERT(IoStack->FileObject->RelatedFileObject->FsContext);
450 
451  /* get current attached virtual device */
452  DeviceEntry = (PKSAUDIO_DEVICE_ENTRY)IoStack->FileObject->RelatedFileObject->FsContext;
453 
454  /* check for success */
455  if (!NT_SUCCESS(Status))
456  {
457  /* failed */
458  Irp->IoStatus.Status = Status;
460  return Status;
461  }
462 
463  /* get connect details */
465 
466  /* check for success */
467  if (!NT_SUCCESS(Status))
468  {
469  /* failed to obtain connect details */
470  Irp->IoStatus.Status = Status;
472  return Status;
473  }
474 
475 
476  /* allocate dispatch context */
477  DispatchContext = AllocateItem(NonPagedPool, sizeof(DISPATCH_CONTEXT));
478  if (!DispatchContext)
479  {
480  /* failed */
481  Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
484  }
485 
486  /* zero dispatch context */
487  RtlZeroMemory(DispatchContext, sizeof(DISPATCH_CONTEXT));
488 
489  /* allocate object header */
490  Status = KsAllocateObjectHeader(&DispatchContext->ObjectHeader, 0, NULL, Irp, &PinTable);
491  if (!NT_SUCCESS(Status))
492  {
493  /* failed */
494  FreeItem(DispatchContext);
495  Irp->IoStatus.Status = Status;
497  return Status;
498  }
499 
500  /* now instantiate the pins */
501  Status = InstantiatePins(DeviceEntry, Connect, DispatchContext, (PSYSAUDIODEVEXT)DeviceObject->DeviceExtension);
502  if (!NT_SUCCESS(Status))
503  {
504  /* failed */
505  KsFreeObjectHeader(DispatchContext->ObjectHeader);
506  FreeItem(DispatchContext);
507  }
508  else
509  {
510  /* store dispatch context */
511  IoStack->FileObject->FsContext = (PVOID)DispatchContext;
512  }
513 
514 
515  /* FIXME create items for clocks / allocators */
516  Irp->IoStatus.Status = Status;
518  return Status;
519 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PKSPIN_CONNECT Connect
Definition: ks.h:4565
_In_ PIRP Irp
Definition: csq.h:116
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
struct KSAUDIO_DEVICE_ENTRY * PKSAUDIO_DEVICE_ENTRY
KSDDKAPI VOID NTAPI KsFreeObjectHeader(IN PVOID Header)
Definition: api.c:720
NTSTATUS GetConnectRequest(IN PIRP Irp, OUT PKSPIN_CONNECT *Result)
Definition: pin.c:392
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
void * PVOID
Definition: retypes.h:9
NTSTATUS NTAPI InstantiatePins(IN PKSAUDIO_DEVICE_ENTRY DeviceEntry, IN PKSPIN_CONNECT Connect, IN PDISPATCH_CONTEXT DispatchContext, IN PSYSAUDIODEVEXT DeviceExtension)
Definition: pin.c:264
if(!(yy_init))
Definition: macro.lex.yy.c:714
static KSDISPATCH_TABLE PinTable
Definition: pin.c:163
Definition: sysaudio.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
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
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
KSOBJECT_HEADER ObjectHeader
Definition: private.hpp:430
return STATUS_SUCCESS
Definition: btrfs.c:2745

Referenced by DispatchCreateSysAudio().

◆ GetConnectRequest()

NTSTATUS GetConnectRequest ( IN PIRP  Irp,
OUT PKSPIN_CONNECT Result 
)

Definition at line 392 of file pin.c.

395 {
396  PIO_STACK_LOCATION IoStack;
397  ULONG ObjectLength, ParametersLength;
398  PVOID Buffer;
399 
400  /* get current irp stack */
402 
403  /* get object class length */
404  ObjectLength = (wcslen(KSSTRING_Pin) + 1) * sizeof(WCHAR);
405 
406  /* check for minium length requirement */
407  if (ObjectLength + sizeof(KSPIN_CONNECT) > IoStack->FileObject->FileName.MaximumLength)
408  return STATUS_UNSUCCESSFUL;
409 
410  /* extract parameters length */
411  ParametersLength = IoStack->FileObject->FileName.MaximumLength - ObjectLength;
412 
413  /* allocate buffer */
414  Buffer = AllocateItem(NonPagedPool, ParametersLength);
415  if (!Buffer)
417 
418  /* copy parameters */
419  RtlMoveMemory(Buffer, &IoStack->FileObject->FileName.Buffer[ObjectLength / sizeof(WCHAR)], ParametersLength);
420 
421  /* store result */
423 
424  return STATUS_SUCCESS;
425 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
#define KSSTRING_Pin
Definition: ks.h:48
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
struct KSPIN_CONNECT * PKSPIN_CONNECT
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2745
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by DispatchCreateSysAudioPin().

◆ InstantiatePins()

NTSTATUS NTAPI InstantiatePins ( IN PKSAUDIO_DEVICE_ENTRY  DeviceEntry,
IN PKSPIN_CONNECT  Connect,
IN PDISPATCH_CONTEXT  DispatchContext,
IN PSYSAUDIODEVEXT  DeviceExtension 
)

Definition at line 264 of file pin.c.

269 {
271  HANDLE RealPinHandle;
272  PKSDATAFORMAT_WAVEFORMATEX InputFormat;
274  PKSPIN_CONNECT MixerPinConnect = NULL;
275  KSPIN_CINSTANCES PinInstances;
276 
277  DPRINT("InstantiatePins entered\n");
278 
279  /* query instance count */
280  Status = GetPinInstanceCount(DeviceEntry, &PinInstances, Connect);
281  if (!NT_SUCCESS(Status))
282  {
283  /* failed to query instance count */
284  return Status;
285  }
286 
287  /* can be the pin be instantiated */
288  if (PinInstances.PossibleCount == 0)
289  {
290  /* caller wanted to open an instance-less pin */
291  return STATUS_UNSUCCESSFUL;
292  }
293 
294  /* has the maximum instance count been exceeded */
295  if (PinInstances.CurrentCount == PinInstances.PossibleCount)
296  {
297  /* FIXME pin already exists
298  * and kmixer infrastructure is not implemented
299  */
300  return STATUS_UNSUCCESSFUL;
301  }
302 
303  /* Fetch input format */
304  InputFormat = (PKSDATAFORMAT_WAVEFORMATEX)(Connect + 1);
305 
306  /* Let's try to create the audio irp pin */
307  Status = KsCreatePin(DeviceEntry->Handle, Connect, GENERIC_READ | GENERIC_WRITE, &RealPinHandle);
308 
309  if (!NT_SUCCESS(Status))
310  {
311  /* FIXME disable kmixer
312  */
313  return STATUS_UNSUCCESSFUL;
314  }
315 #if 0
316  if (!NT_SUCCESS(Status))
317  {
318  /* the audio irp pin didnt accept the input format
319  * let's compute a compatible format
320  */
321  MixerPinConnect = AllocateItem(NonPagedPool, sizeof(KSPIN_CONNECT) + sizeof(KSDATAFORMAT_WAVEFORMATEX));
322  if (!MixerPinConnect)
323  {
324  /* not enough memory */
326  }
327 
328  /* Zero pin connect */
329  RtlZeroMemory(MixerPinConnect, sizeof(KSPIN_CONNECT) + sizeof(KSDATAFORMAT_WAVEFORMATEX));
330 
331  /* Copy initial connect details */
332  RtlMoveMemory(MixerPinConnect, Connect, sizeof(KSPIN_CONNECT));
333 
334 
335  OutputFormat = (PKSDATAFORMAT_WAVEFORMATEX)(MixerPinConnect + 1);
336 
337  Status = ComputeCompatibleFormat(DeviceEntry, Connect->PinId, InputFormat, OutputFormat);
338  if (!NT_SUCCESS(Status))
339  {
340  DPRINT1("ComputeCompatibleFormat failed with %x\n", Status);
341  FreeItem(MixerPinConnect);
342  return Status;
343  }
344 
345  /* Retry with Mixer format */
346  Status = KsCreatePin(DeviceEntry->Handle, MixerPinConnect, GENERIC_READ | GENERIC_WRITE, &RealPinHandle);
347  if (!NT_SUCCESS(Status))
348  {
349  /* This should not fail */
350  DPRINT1("KsCreatePin failed with %x\n", Status);
351  DPRINT1(" InputFormat: SampleRate %u Bits %u Channels %u\n", InputFormat->WaveFormatEx.nSamplesPerSec, InputFormat->WaveFormatEx.wBitsPerSample, InputFormat->WaveFormatEx.nChannels);
352  DPRINT1("OutputFormat: SampleRate %u Bits %u Channels %u\n", OutputFormat->WaveFormatEx.nSamplesPerSec, OutputFormat->WaveFormatEx.wBitsPerSample, OutputFormat->WaveFormatEx.nChannels);
353 
354  FreeItem(MixerPinConnect);
355  return Status;
356  }
357  }
358 #endif
359 
360  //DeviceEntry->Pins[Connect->PinId].References = 0;
361 
362  /* initialize dispatch context */
363  DispatchContext->Handle = RealPinHandle;
364  DispatchContext->PinId = Connect->PinId;
365  DispatchContext->AudioEntry = DeviceEntry;
366 
367 
368  DPRINT("RealPinHandle %p\n", RealPinHandle);
369 
370  /* Do we need to transform the audio stream */
371  if (OutputFormat != NULL)
372  {
373  /* Now create the mixer pin */
374  Status = CreateMixerPinAndSetFormat(DeviceExtension->KMixerHandle,
375  MixerPinConnect,
376  (PKSDATAFORMAT)InputFormat,
378  &DispatchContext->hMixerPin);
379 
380  /* check for success */
381  if (!NT_SUCCESS(Status))
382  {
383  DPRINT1("Failed to create Mixer Pin with %x\n", Status);
384  FreeItem(MixerPinConnect);
385  }
386  }
387  /* done */
388  return Status;
389 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PKSPIN_CONNECT Connect
Definition: ks.h:4565
KSDDKAPI DWORD NTAPI KsCreatePin(HANDLE FilterHandle, PKSPIN_CONNECT Connect, ACCESS_MASK DesiredAccess, PHANDLE ConnectionHandle)
Definition: ksuser.c:192
NTSTATUS CreateMixerPinAndSetFormat(IN HANDLE KMixerHandle, IN KSPIN_CONNECT *PinConnect, IN PKSDATAFORMAT InputFormat, IN PKSDATAFORMAT OutputFormat, OUT PHANDLE MixerPinHandle)
Definition: pin.c:218
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
enum OutputFormat_ OutputFormat
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
ULONG PinId
Definition: ks.h:2632
#define GENERIC_WRITE
Definition: nt_native.h:90
WORD wBitsPerSample
Definition: audioclient.idl:45
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
DWORD nSamplesPerSec
Definition: audioclient.idl:42
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG PossibleCount
Definition: ks.h:681
WAVEFORMATEX WaveFormatEx
Definition: ksmedia.h:532
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS ComputeCompatibleFormat(IN PKSAUDIO_DEVICE_ENTRY Entry, IN ULONG PinId, IN PKSDATAFORMAT_WAVEFORMATEX ClientFormat, OUT PKSDATAFORMAT_WAVEFORMATEX MixerFormat)
Definition: control.c:135
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
struct KSDATAFORMAT_WAVEFORMATEX * PKSDATAFORMAT_WAVEFORMATEX
ULONG CurrentCount
Definition: ks.h:682
#define DPRINT1
Definition: precomp.h:8
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
NTSTATUS GetPinInstanceCount(PKSAUDIO_DEVICE_ENTRY Entry, PKSPIN_CINSTANCES PinInstances, PKSPIN_CONNECT PinConnect)
Definition: control.c:269

Referenced by DispatchCreateSysAudioPin().

◆ Pin_fnClose()

NTSTATUS NTAPI Pin_fnClose ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 130 of file pin.c.

133 {
135  PIO_STACK_LOCATION IoStack;
136 
137  //DPRINT("Pin_fnClose called DeviceObject %p Irp %p\n", DeviceObject, Irp);
138 
139  /* Get current stack location */
141 
142  /* The dispatch context is stored in the FsContext member */
143  Context = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
144 
145  if (Context->Handle)
146  {
147  ZwClose(Context->Handle);
148  }
149 
150  if (Context->hMixerPin)
151  {
152  ZwClose(Context->hMixerPin);
153  }
154 
155  FreeItem(Context);
156 
157  Irp->IoStatus.Status = STATUS_SUCCESS;
158  Irp->IoStatus.Information = 0;
160  return STATUS_SUCCESS;
161 }
_In_ PIRP Irp
Definition: csq.h:116
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
#define IoCompleteRequest
Definition: irp.c:1240
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
if(!(yy_init))
Definition: macro.lex.yy.c:714
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
struct tagContext Context
Definition: acpixf.h:1012
#define IO_NO_INCREMENT
Definition: iotypes.h:565
return STATUS_SUCCESS
Definition: btrfs.c:2745

◆ Pin_fnDeviceIoControl()

NTSTATUS NTAPI Pin_fnDeviceIoControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 16 of file pin.c.

19 {
24  PIO_STACK_LOCATION IoStack;
25 
26  DPRINT("Pin_fnDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject, Irp);
27 
28  /* Get current stack location */
30 
31  /* The dispatch context is stored in the FsContext member */
32  Context = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
33 
34  /* Sanity check */
35  ASSERT(Context);
36 
37  /* acquire real pin file object */
39  if (!NT_SUCCESS(Status))
40  {
41  Irp->IoStatus.Information = 0;
42  Irp->IoStatus.Status = Status;
43  /* Complete the irp */
45  return Status;
46  }
47 
48  /* Re-dispatch the request to the real target pin */
49  Status = KsSynchronousIoControlDevice(FileObject, KernelMode, IoStack->Parameters.DeviceIoControl.IoControlCode,
50  IoStack->Parameters.DeviceIoControl.Type3InputBuffer,
51  IoStack->Parameters.DeviceIoControl.InputBufferLength,
52  Irp->UserBuffer,
53  IoStack->Parameters.DeviceIoControl.OutputBufferLength,
54  &BytesReturned);
55  /* release file object */
57 
58  /* Save status and information */
59  Irp->IoStatus.Information = BytesReturned;
60  Irp->IoStatus.Status = Status;
61  /* Complete the irp */
63  /* Done */
64  return Status;
65 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
KSDDKAPI NTSTATUS NTAPI KsSynchronousIoControlDevice(IN PFILE_OBJECT FileObject, IN KPROCESSOR_MODE RequestorMode, IN ULONG IoControl, IN PVOID InBuffer, IN ULONG InSize, OUT PVOID OutBuffer, IN ULONG OutSize, OUT PULONG BytesReturned)
Definition: api.c:1099
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
* PFILE_OBJECT
Definition: iotypes.h:1954
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
_In_ FILTER_INFORMATION_CLASS _In_ ULONG _Out_ PULONG BytesReturned
Definition: fltkernel.h:1716
struct tagContext Context
Definition: acpixf.h:1012
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771

◆ Pin_fnWrite()

NTSTATUS NTAPI Pin_fnWrite ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 71 of file pin.c.

74 {
76  PIO_STACK_LOCATION IoStack;
79 
80  /* Get current stack location */
82 
83  /* The dispatch context is stored in the FsContext member */
84  Context = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
85 
86  /* Sanity check */
87  ASSERT(Context);
88 
89  if (Context->hMixerPin)
90  {
91  // FIXME
92  // call kmixer to convert stream
94  }
95 
96  /* acquire real pin file object */
98  if (!NT_SUCCESS(Status))
99  {
100  DPRINT1("failed\n");
101  Irp->IoStatus.Information = 0;
102  Irp->IoStatus.Status = Status;
103  /* Complete the irp */
105  return Status;
106  }
107 
108  /* skip current irp location */
110 
111  /* get next stack location */
112  IoStack = IoGetNextIrpStackLocation(Irp);
113  /* store file object of next device object */
114  IoStack->FileObject = FileObject;
116  //ASSERT(Irp->AssociatedIrp.SystemBuffer);
117 
118  /* now call the driver */
120 
121  /* dereference file object */
123 
124  return Status;
125 
126 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1538
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
* PFILE_OBJECT
Definition: iotypes.h:1954
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define DPRINT1
Definition: precomp.h:8
struct tagContext Context
Definition: acpixf.h:1012
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define UNIMPLEMENTED
Definition: debug.h:114
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

◆ SetMixerInputOutputFormat()

NTSTATUS SetMixerInputOutputFormat ( IN PFILE_OBJECT  FileObject,
IN PKSDATAFORMAT  InputFormat,
IN PKSDATAFORMAT  OutputFormat 
)

Definition at line 178 of file pin.c.

182 {
183  KSP_PIN PinRequest;
186 
187  /* re-using pin */
188  PinRequest.Property.Set = KSPROPSETID_Connection;
189  PinRequest.Property.Flags = KSPROPERTY_TYPE_SET;
191 
192  /* set the input format */
193  PinRequest.PinId = 0;
194  DPRINT("InputFormat %p Size %u WaveFormatSize %u DataFormat %u WaveEx %u\n", InputFormat, InputFormat->FormatSize, sizeof(KSDATAFORMAT_WAVEFORMATEX), sizeof(KSDATAFORMAT), sizeof(WAVEFORMATEX));
196  (PVOID)&PinRequest,
197  sizeof(KSP_PIN),
198  (PVOID)InputFormat,
199  InputFormat->FormatSize,
200  &BytesReturned);
201  if (!NT_SUCCESS(Status))
202  return Status;
203 
204  /* set the the output format */
205  PinRequest.PinId = 1;
206  DPRINT("OutputFormat %p Size %u WaveFormatSize %u DataFormat %u WaveEx %u\n", OutputFormat, OutputFormat->FormatSize, sizeof(KSDATAFORMAT_WAVEFORMATEX), sizeof(KSDATAFORMAT), sizeof(WAVEFORMATEX));
208  (PVOID)&PinRequest,
209  sizeof(KSP_PIN),
211  OutputFormat->FormatSize,
212  &BytesReturned);
213  return Status;
214 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:150
LONG NTSTATUS
Definition: precomp.h:26
enum OutputFormat_ OutputFormat
GUID Set
Definition: dmksctrl.h:76
KSDDKAPI NTSTATUS NTAPI KsSynchronousIoControlDevice(IN PFILE_OBJECT FileObject, IN KPROCESSOR_MODE RequestorMode, IN ULONG IoControl, IN PVOID InBuffer, IN ULONG InSize, OUT PVOID OutBuffer, IN ULONG OutSize, OUT PULONG BytesReturned)
Definition: api.c:1099
KSPROPERTY Property
Definition: ks.h:673
const GUID KSPROPSETID_Connection
Definition: pin.c:113
void DPRINT(...)
Definition: polytest.cpp:61
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
ULONG PinId
Definition: ks.h:674
Definition: ks.h:672
ULONG Id
Definition: dmksctrl.h:77
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG Flags
Definition: dmksctrl.h:78
Status
Definition: gdiplustypes.h:24
_In_ FILTER_INFORMATION_CLASS _In_ ULONG _Out_ PULONG BytesReturned
Definition: fltkernel.h:1716
unsigned int ULONG
Definition: retypes.h:1
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43

Referenced by CreateMixerPinAndSetFormat().

Variable Documentation

◆ PinTable

KSDISPATCH_TABLE PinTable
static
Initial value:
=
{
KsDispatchFastWriteFailure,
}
NTSTATUS NTAPI Pin_fnClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: pin.c:513
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:1218
KSDDKAPI NTSTATUS NTAPI KsDispatchInvalidDeviceRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1156
NTSTATUS NTAPI Pin_fnWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: pin.c:485
NTSTATUS NTAPI Pin_fnDeviceIoControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: pin.c:423
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:1238

Definition at line 163 of file pin.c.

Referenced by DispatchCreateSysAudioPin().