ReactOS  0.4.14-dev-115-g4576127
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 1007 of file pin_wavepci.cpp.

1009 {
1011 
1013  if (!This)
1015 
1016  This->AddRef();
1017 
1018  // store result
1019  *OutPin = (IPortPinWavePci*)This;
1020 
1021  return STATUS_SUCCESS;
1022 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TAG_PORTCLASS
Definition: private.hpp:24
smooth NULL
Definition: ftsmooth.c:416
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ PinWavePciAllocatorFraming()

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

Definition at line 119 of file pin_wavepci.cpp.

123 {
126 
127  // get sub device descriptor
128  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
129 
130  // sanity check
132  PC_ASSERT(Descriptor->PortPin);
134 
135  // cast to pin impl
136  Pin = (CPortPinWavePci*)Descriptor->PortPin;
137 
138 
139  if (Request->Flags & KSPROPERTY_TYPE_GET)
140  {
141  // copy pin framing
142  RtlMoveMemory(Data, &Pin->m_AllocatorFraming, sizeof(KSALLOCATOR_FRAMING));
143 
144  Irp->IoStatus.Information = sizeof(KSALLOCATOR_FRAMING);
145  return STATUS_SUCCESS;
146  }
147 
148  // not supported
149  return STATUS_NOT_SUPPORTED;
150 }
#define PC_ASSERT(exp)
Definition: usbehci.h:17
_In_ PIRP Irp
Definition: csq.h:116
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
if(!(yy_init))
Definition: macro.lex.yy.c:714
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
return STATUS_SUCCESS
Definition: btrfs.c:2966
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
#define PC_ASSERT_IRQL(x)
Definition: private.hpp:30
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

◆ PinWavePciAudioPosition()

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

Definition at line 154 of file pin_wavepci.cpp.

158 {
161 
162  // get sub device descriptor
163  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
164 
165  // sanity check
167  PC_ASSERT(Descriptor->PortPin);
169 
170  // cast to pin impl
171  Pin = (CPortPinWavePci*)Descriptor->PortPin;
172 
173  //sanity check
174  PC_ASSERT(Pin->m_Stream);
175 
176  if (Request->Flags & KSPROPERTY_TYPE_GET)
177  {
178  // FIXME non multithreading-safe
179  // copy audio position
180  RtlMoveMemory(Data, &Pin->m_Position, sizeof(KSAUDIO_POSITION));
181 
182  DPRINT("Play %lu Record %lu\n", Pin->m_Position.PlayOffset, Pin->m_Position.WriteOffset);
183  Irp->IoStatus.Information = sizeof(KSAUDIO_POSITION);
184  return STATUS_SUCCESS;
185  }
186 
187  // not supported
188  return STATUS_NOT_SUPPORTED;
189 }
#define PC_ASSERT(exp)
Definition: usbehci.h:17
_In_ PIRP Irp
Definition: csq.h:116
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
void DPRINT(...)
Definition: polytest.cpp:61
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
return STATUS_SUCCESS
Definition: btrfs.c:2966
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
#define PC_ASSERT_IRQL(x)
Definition: private.hpp:30
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

◆ PinWavePciDataFormat()

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

Definition at line 280 of file pin_wavepci.cpp.

284 {
288  PIO_STACK_LOCATION IoStack;
289 
290  // get current irp stack location
292 
293  // get sub device descriptor
294  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
295 
296  // sanity check
298  PC_ASSERT(Descriptor->PortPin);
299 
300  // cast to pin impl
301  Pin = (CPortPinWavePci*)Descriptor->PortPin;
302 
303  //sanity check
304  PC_ASSERT(Pin->m_Stream);
305  PC_ASSERT(Pin->m_Format);
306 
307  if (Request->Flags & KSPROPERTY_TYPE_SET)
308  {
309  // try to change data format
310  PKSDATAFORMAT NewDataFormat, DataFormat = (PKSDATAFORMAT)Irp->UserBuffer;
311  ULONG Size = min(Pin->m_Format->FormatSize, DataFormat->FormatSize);
312 
313  if (RtlCompareMemory(DataFormat, Pin->m_Format, Size) == Size)
314  {
315  // format is identical
316  Irp->IoStatus.Information = DataFormat->FormatSize;
317  return STATUS_SUCCESS;
318  }
319 
320  // new change request
321  PC_ASSERT(Pin->m_State == KSSTATE_STOP);
322  // FIXME queue a work item when Irql != PASSIVE_LEVEL
324 
325  // allocate new data format
326  NewDataFormat = (PKSDATAFORMAT)AllocateItem(NonPagedPool, DataFormat->FormatSize, TAG_PORTCLASS);
327  if (!NewDataFormat)
328  {
329  // not enough memory
330  return STATUS_NO_MEMORY;
331  }
332 
333  // copy new data format
334  RtlMoveMemory(NewDataFormat, DataFormat, DataFormat->FormatSize);
335 
336  // set new format
337  Status = Pin->m_Stream->SetFormat(NewDataFormat);
338  if (NT_SUCCESS(Status))
339  {
340  // free old format
341  FreeItem(Pin->m_Format, TAG_PORTCLASS);
342 
343  // store new format
344  Pin->m_Format = NewDataFormat;
345  Irp->IoStatus.Information = NewDataFormat->FormatSize;
346 
347 #if 0
348  PC_ASSERT(NewDataFormat->FormatSize == sizeof(KSDATAFORMAT_WAVEFORMATEX));
352 
353 
354  DPRINT("NewDataFormat: Channels %u Bits %u Samples %u\n", ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.nChannels,
355  ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.wBitsPerSample,
356  ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.nSamplesPerSec);
357 #endif
358 
359  }
360  else
361  {
362  // failed to set format
363  FreeItem(NewDataFormat, TAG_PORTCLASS);
364  }
365 
366 
367  // done
368  return Status;
369  }
370  else if (Request->Flags & KSPROPERTY_TYPE_GET)
371  {
372  // get current data format
373  PC_ASSERT(Pin->m_Format);
374 
375  if (Pin->m_Format->FormatSize > IoStack->Parameters.DeviceIoControl.OutputBufferLength)
376  {
377  // buffer too small
378  Irp->IoStatus.Information = Pin->m_Format->FormatSize;
379  return STATUS_MORE_ENTRIES;
380  }
381  // copy data format
382  RtlMoveMemory(Data, Pin->m_Format, Pin->m_Format->FormatSize);
383  // store result size
384  Irp->IoStatus.Information = Pin->m_Format->FormatSize;
385 
386  // done
387  return STATUS_SUCCESS;
388  }
389 
390  // unsupported request
391  return STATUS_NOT_SUPPORTED;
392 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define KSDATAFORMAT_SUBTYPE_PCM
Definition: ksmedia.h:921
#define PC_ASSERT(exp)
Definition: usbehci.h:17
_In_ PIRP Irp
Definition: csq.h:116
#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
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define KSDATAFORMAT_SPECIFIER_WAVEFORMATEX
Definition: ksmedia.h:931
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
void DPRINT(...)
Definition: polytest.cpp:61
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define KSDATAFORMAT_TYPE_AUDIO
Definition: ksmedia.h:883
#define STATUS_MORE_ENTRIES
Definition: udferr_usr.h:124
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define min(a, b)
Definition: monoChain.cc:55
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2966
#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
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

◆ PinWavePciState()

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

Definition at line 194 of file pin_wavepci.cpp.

198 {
202  PVOID FirstTag, LastTag;
203  ULONG MappingsRevoked;
205 
206  // get sub device descriptor
207  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
208 
209  // sanity check
211  PC_ASSERT(Descriptor->PortPin);
213 
214  // cast to pin impl
215  Pin = (CPortPinWavePci*)Descriptor->PortPin;
216 
217  //sanity check
218  PC_ASSERT(Pin->m_Stream);
219 
220  if (Request->Flags & KSPROPERTY_TYPE_SET)
221  {
222  // try set stream
223  Status = Pin->m_Stream->SetState(*State);
224 
225  DPRINT("Setting state %u %x\n", *State, Status);
226  if (NT_SUCCESS(Status))
227  {
228  // store new state
229  Pin->m_State = *State;
230  if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING && Pin->m_State == KSSTATE_STOP)
231  {
232  // FIXME
233  // complete with successful state
234  Pin->m_IrpQueue->CancelBuffers();
235  while(Pin->m_IrpQueue->GetAcquiredTagRange(&FirstTag, &LastTag))
236  {
237  Status = Pin->m_Stream->RevokeMappings(FirstTag, LastTag, &MappingsRevoked);
238  DPRINT("RevokeMappings Status %lx MappingsRevoked: %lu\n", Status, MappingsRevoked);
240  }
241  Pin->m_Position.PlayOffset = 0;
242  Pin->m_Position.WriteOffset = 0;
243  }
244  else if (Pin->m_State == KSSTATE_STOP)
245  {
246  Pin->m_IrpQueue->CancelBuffers();
247  while(Pin->m_IrpQueue->GetAcquiredTagRange(&FirstTag, &LastTag))
248  {
249  Status = Pin->m_Stream->RevokeMappings(FirstTag, LastTag, &MappingsRevoked);
250  DPRINT("RevokeMappings Status %lx MappingsRevoked: %lu\n", Status, MappingsRevoked);
252  }
253  Pin->m_Position.PlayOffset = 0;
254  Pin->m_Position.WriteOffset = 0;
255  }
256  // store result
257  Irp->IoStatus.Information = sizeof(KSSTATE);
258 
259  }
260  // store result
261  Irp->IoStatus.Information = sizeof(KSSTATE);
262  return Status;
263  }
264  else if (Request->Flags & KSPROPERTY_TYPE_GET)
265  {
266  // get current stream state
267  *State = Pin->m_State;
268  // store result
269  Irp->IoStatus.Information = sizeof(KSSTATE);
270 
271  return STATUS_SUCCESS;
272  }
273 
274  // unsupported request
275  return STATUS_NOT_SUPPORTED;
276 }
#define PC_ASSERT(exp)
Definition: usbehci.h:17
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
enum KSSTATE * PKSSTATE
void DPRINT(...)
Definition: polytest.cpp:61
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
enum State_ State
Definition: pofuncs.h:54
KSSTATE
Definition: ks.h:1214
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:99
#define PC_ASSERT_IRQL(x)
Definition: private.hpp:30
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

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:951
#define KSPROPSETID_Connection
Definition: ks.h:346
smooth NULL
Definition: ftsmooth.c:416

Definition at line 98 of file pin_wavepci.cpp.