ReactOS  0.4.15-dev-5496-g599ba9c
pin_wavepci.cpp File Reference
#include "private.hpp"
#include <debug.h>
Include dependency graph for pin_wavepci.cpp:

Go to the source code of this file.

Classes

class  CPortPinWavePci
 
struct  SETSTREAM_CONTEXT
 

Macros

#define NDEBUG
 

Typedefs

typedef struct SETSTREAM_CONTEXTPSETSTREAM_CONTEXT
 

Functions

NTSTATUS NTAPI PinWavePciState (IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
 
NTSTATUS NTAPI PinWavePciDataFormat (IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
 
NTSTATUS NTAPI PinWavePciAudioPosition (IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
 
NTSTATUS NTAPI PinWavePciAllocatorFraming (IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
 
 DEFINE_KSPROPERTY_CONNECTIONSET (PinWavePciConnectionSet, PinWavePciState, PinWavePciDataFormat, PinWavePciAllocatorFraming)
 
 DEFINE_KSPROPERTY_AUDIOSET (PinWavePciAudioSet, PinWavePciAudioPosition)
 
NTSTATUS NewPortPinWavePci (OUT IPortPinWavePci **OutPin)
 

Variables

KSPROPERTY_SET PinWavePciPropertySet []
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file pin_wavepci.cpp.

Typedef Documentation

◆ PSETSTREAM_CONTEXT

Function Documentation

◆ DEFINE_KSPROPERTY_AUDIOSET()

DEFINE_KSPROPERTY_AUDIOSET ( PinWavePciAudioSet  ,
PinWavePciAudioPosition   
)

◆ DEFINE_KSPROPERTY_CONNECTIONSET()

DEFINE_KSPROPERTY_CONNECTIONSET ( PinWavePciConnectionSet  ,
PinWavePciState  ,
PinWavePciDataFormat  ,
PinWavePciAllocatorFraming   
)

◆ NewPortPinWavePci()

NTSTATUS NewPortPinWavePci ( OUT IPortPinWavePci **  OutPin)

Definition at line 984 of file pin_wavepci.cpp.

986 {
988 
990  if (!This)
992 
993  This->AddRef();
994 
995  // store result
996  *OutPin = (IPortPinWavePci*)This;
997 
998  return STATUS_SUCCESS;
999 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TAG_PORTCLASS
Definition: private.hpp:24
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ PinWavePciAllocatorFraming()

NTSTATUS NTAPI PinWavePciAllocatorFraming ( IN PIRP  Irp,
IN PKSIDENTIFIER  Request,
IN OUT PVOID  Data 
)

Definition at line 99 of file pin_wavepci.cpp.

103 {
106 
107  // get sub device descriptor
108  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
109 
110  // sanity check
112  PC_ASSERT(Descriptor->PortPin);
114 
115  // cast to pin impl
116  Pin = (CPortPinWavePci*)Descriptor->PortPin;
117 
118 
119  if (Request->Flags & KSPROPERTY_TYPE_GET)
120  {
121  // copy pin framing
122  RtlMoveMemory(Data, &Pin->m_AllocatorFraming, sizeof(KSALLOCATOR_FRAMING));
123 
124  Irp->IoStatus.Information = sizeof(KSALLOCATOR_FRAMING);
125  return STATUS_SUCCESS;
126  }
127 
128  // not supported
129  return STATUS_NOT_SUPPORTED;
130 }
return STATUS_NOT_SUPPORTED
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define PC_ASSERT(exp)
Definition: private.hpp:26
_In_ PIRP Irp
Definition: csq.h:116
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:424
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define STATUS_SUCCESS
Definition: shellext.h:65
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
#define PC_ASSERT_IRQL(x)
Definition: private.hpp:30

◆ PinWavePciAudioPosition()

NTSTATUS NTAPI PinWavePciAudioPosition ( IN PIRP  Irp,
IN PKSIDENTIFIER  Request,
IN OUT PVOID  Data 
)

Definition at line 134 of file pin_wavepci.cpp.

138 {
141 
142  // get sub device descriptor
143  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
144 
145  // sanity check
147  PC_ASSERT(Descriptor->PortPin);
149 
150  // cast to pin impl
151  Pin = (CPortPinWavePci*)Descriptor->PortPin;
152 
153  //sanity check
154  PC_ASSERT(Pin->m_Stream);
155 
156  if (Request->Flags & KSPROPERTY_TYPE_GET)
157  {
158  // FIXME non multithreading-safe
159  // copy audio position
160  RtlMoveMemory(Data, &Pin->m_Position, sizeof(KSAUDIO_POSITION));
161 
162  DPRINT("Play %lu Record %lu\n", Pin->m_Position.PlayOffset, Pin->m_Position.WriteOffset);
163  Irp->IoStatus.Information = sizeof(KSAUDIO_POSITION);
164  return STATUS_SUCCESS;
165  }
166 
167  // not supported
168  return STATUS_NOT_SUPPORTED;
169 }
return STATUS_NOT_SUPPORTED
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define PC_ASSERT(exp)
Definition: private.hpp:26
_In_ PIRP Irp
Definition: csq.h:116
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:424
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
#define PC_ASSERT_IRQL(x)
Definition: private.hpp:30

◆ PinWavePciDataFormat()

NTSTATUS NTAPI PinWavePciDataFormat ( IN PIRP  Irp,
IN PKSIDENTIFIER  Request,
IN OUT PVOID  Data 
)

Definition at line 260 of file pin_wavepci.cpp.

264 {
268  PIO_STACK_LOCATION IoStack;
269 
270  // get current irp stack location
272 
273  // get sub device descriptor
274  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
275 
276  // sanity check
278  PC_ASSERT(Descriptor->PortPin);
279 
280  // cast to pin impl
281  Pin = (CPortPinWavePci*)Descriptor->PortPin;
282 
283  //sanity check
284  PC_ASSERT(Pin->m_Stream);
285  PC_ASSERT(Pin->m_Format);
286 
287  if (Request->Flags & KSPROPERTY_TYPE_SET)
288  {
289  // try to change data format
290  PKSDATAFORMAT NewDataFormat, DataFormat = (PKSDATAFORMAT)Irp->UserBuffer;
291  ULONG Size = min(Pin->m_Format->FormatSize, DataFormat->FormatSize);
292 
293  if (RtlCompareMemory(DataFormat, Pin->m_Format, Size) == Size)
294  {
295  // format is identical
296  Irp->IoStatus.Information = DataFormat->FormatSize;
297  return STATUS_SUCCESS;
298  }
299 
300  // new change request
301  PC_ASSERT(Pin->m_State == KSSTATE_STOP);
302  // FIXME queue a work item when Irql != PASSIVE_LEVEL
304 
305  // allocate new data format
306  NewDataFormat = (PKSDATAFORMAT)AllocateItem(NonPagedPool, DataFormat->FormatSize, TAG_PORTCLASS);
307  if (!NewDataFormat)
308  {
309  // not enough memory
310  return STATUS_NO_MEMORY;
311  }
312 
313  // copy new data format
314  RtlMoveMemory(NewDataFormat, DataFormat, DataFormat->FormatSize);
315 
316  // set new format
317  Status = Pin->m_Stream->SetFormat(NewDataFormat);
318  if (NT_SUCCESS(Status))
319  {
320  // free old format
321  FreeItem(Pin->m_Format, TAG_PORTCLASS);
322 
323  // store new format
324  Pin->m_Format = NewDataFormat;
325  Irp->IoStatus.Information = NewDataFormat->FormatSize;
326 
327 #if 0
328  PC_ASSERT(NewDataFormat->FormatSize == sizeof(KSDATAFORMAT_WAVEFORMATEX));
332 
333 
334  DPRINT("NewDataFormat: Channels %u Bits %u Samples %u\n", ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.nChannels,
335  ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.wBitsPerSample,
336  ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.nSamplesPerSec);
337 #endif
338 
339  }
340  else
341  {
342  // failed to set format
343  FreeItem(NewDataFormat, TAG_PORTCLASS);
344  }
345 
346 
347  // done
348  return Status;
349  }
350  else if (Request->Flags & KSPROPERTY_TYPE_GET)
351  {
352  // get current data format
353  PC_ASSERT(Pin->m_Format);
354 
355  if (Pin->m_Format->FormatSize > IoStack->Parameters.DeviceIoControl.OutputBufferLength)
356  {
357  // buffer too small
358  Irp->IoStatus.Information = Pin->m_Format->FormatSize;
359  return STATUS_MORE_ENTRIES;
360  }
361  // copy data format
362  RtlMoveMemory(Data, Pin->m_Format, Pin->m_Format->FormatSize);
363  // store result size
364  Irp->IoStatus.Information = Pin->m_Format->FormatSize;
365 
366  // done
367  return STATUS_SUCCESS;
368  }
369 
370  // unsupported request
371  return STATUS_NOT_SUPPORTED;
372 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
return STATUS_NOT_SUPPORTED
#define KSDATAFORMAT_SUBTYPE_PCM
Definition: ksmedia.h:1021
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
#define TAG_PORTCLASS
Definition: private.hpp:24
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define KSDATAFORMAT_SPECIFIER_WAVEFORMATEX
Definition: ksmedia.h:1031
#define PC_ASSERT(exp)
Definition: private.hpp:26
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
_In_ PIRP Irp
Definition: csq.h:116
Status
Definition: gdiplustypes.h:24
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:424
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define KSDATAFORMAT_TYPE_AUDIO
Definition: ksmedia.h:983
#define STATUS_MORE_ENTRIES
Definition: udferr_usr.h:124
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define min(a, b)
Definition: monoChain.cc:55
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
KSDATAFORMAT * PKSDATAFORMAT

◆ PinWavePciState()

NTSTATUS NTAPI PinWavePciState ( IN PIRP  Irp,
IN PKSIDENTIFIER  Request,
IN OUT PVOID  Data 
)

Definition at line 174 of file pin_wavepci.cpp.

178 {
182  PVOID FirstTag, LastTag;
183  ULONG MappingsRevoked;
185 
186  // get sub device descriptor
187  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
188 
189  // sanity check
191  PC_ASSERT(Descriptor->PortPin);
193 
194  // cast to pin impl
195  Pin = (CPortPinWavePci*)Descriptor->PortPin;
196 
197  //sanity check
198  PC_ASSERT(Pin->m_Stream);
199 
200  if (Request->Flags & KSPROPERTY_TYPE_SET)
201  {
202  // try set stream
203  Status = Pin->m_Stream->SetState(*State);
204 
205  DPRINT("Setting state %u %x\n", *State, Status);
206  if (NT_SUCCESS(Status))
207  {
208  // store new state
209  Pin->m_State = *State;
210  if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING && Pin->m_State == KSSTATE_STOP)
211  {
212  // FIXME
213  // complete with successful state
214  Pin->m_IrpQueue->CancelBuffers();
215  while(Pin->m_IrpQueue->GetAcquiredTagRange(&FirstTag, &LastTag))
216  {
217  Status = Pin->m_Stream->RevokeMappings(FirstTag, LastTag, &MappingsRevoked);
218  DPRINT("RevokeMappings Status %lx MappingsRevoked: %lu\n", Status, MappingsRevoked);
220  }
221  Pin->m_Position.PlayOffset = 0;
222  Pin->m_Position.WriteOffset = 0;
223  }
224  else if (Pin->m_State == KSSTATE_STOP)
225  {
226  Pin->m_IrpQueue->CancelBuffers();
227  while(Pin->m_IrpQueue->GetAcquiredTagRange(&FirstTag, &LastTag))
228  {
229  Status = Pin->m_Stream->RevokeMappings(FirstTag, LastTag, &MappingsRevoked);
230  DPRINT("RevokeMappings Status %lx MappingsRevoked: %lu\n", Status, MappingsRevoked);
232  }
233  Pin->m_Position.PlayOffset = 0;
234  Pin->m_Position.WriteOffset = 0;
235  }
236  // store result
237  Irp->IoStatus.Information = sizeof(KSSTATE);
238 
239  }
240  // store result
241  Irp->IoStatus.Information = sizeof(KSSTATE);
242  return Status;
243  }
244  else if (Request->Flags & KSPROPERTY_TYPE_GET)
245  {
246  // get current stream state
247  *State = Pin->m_State;
248  // store result
249  Irp->IoStatus.Information = sizeof(KSSTATE);
250 
251  return STATUS_SUCCESS;
252  }
253 
254  // unsupported request
255  return STATUS_NOT_SUPPORTED;
256 }
return STATUS_NOT_SUPPORTED
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_ ULONG State
Definition: potypes.h:516
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define PC_ASSERT(exp)
Definition: private.hpp:26
enum KSSTATE * PKSSTATE
_In_ PIRP Irp
Definition: csq.h:116
Status
Definition: gdiplustypes.h:24
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:424
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
KSSTATE
Definition: ks.h:1214
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:81
#define PC_ASSERT_IRQL(x)
Definition: private.hpp:30

Variable Documentation

◆ PinWavePciPropertySet

KSPROPERTY_SET PinWavePciPropertySet[]
Initial value:
=
{
{
sizeof(PinWavePciConnectionSet) / sizeof(KSPROPERTY_ITEM),
(const KSPROPERTY_ITEM*)&PinWavePciConnectionSet,
0,
},
{
sizeof(PinWavePciAudioSet) / sizeof(KSPROPERTY_ITEM),
(const KSPROPERTY_ITEM*)&PinWavePciAudioSet,
0,
}
}
#define KSPROPSETID_Audio
Definition: ksmedia.h:1051
#define KSPROPSETID_Connection
Definition: ks.h:346
#define NULL
Definition: types.h:112

Definition at line 78 of file pin_wavepci.cpp.