ReactOS  0.4.15-dev-5496-g599ba9c
CPortPinWaveCyclic Class Reference
Inheritance diagram for CPortPinWaveCyclic:
Collaboration diagram for CPortPinWaveCyclic:

Public Member Functions

PVOID operator new (size_t Size, POOL_TYPE PoolType, ULONG Tag)
 
STDMETHODIMP QueryInterface (REFIID InterfaceId, PVOID *Interface)
 
 CPortPinWaveCyclic (IUnknown *OuterUnknown)
 
virtual ~CPortPinWaveCyclic ()
 
- Public Member Functions inherited from CUnknownImpl< IPortPinWaveCyclic, IServiceSink >
 STDMETHODIMP_ (ULONG) AddRef()
 
 STDMETHODIMP_ (ULONG) Release()
 

Public Attributes

 IMP_IPortPinWaveCyclic
 
 IMP_IServiceSink
 

Protected Member Functions

VOID UpdateCommonBuffer (ULONG Position, ULONG MaxTransferCount)
 
VOID UpdateCommonBufferOverlap (ULONG Position, ULONG MaxTransferCount)
 
VOID GeneratePositionEvents (IN ULONGLONG OldOffset, IN ULONGLONG NewOffset)
 
- Protected Member Functions inherited from CUnknownImpl< IPortPinWaveCyclic, IServiceSink >
 CUnknownImpl ()
 
virtual ~CUnknownImpl ()
 

Protected Attributes

IPortWaveCyclic * m_Port
 
IPortFilterWaveCyclic * m_Filter
 
KSPIN_DESCRIPTOR * m_KsPinDescriptor
 
PMINIPORTWAVECYCLIC m_Miniport
 
PSERVICEGROUP m_ServiceGroup
 
PDMACHANNEL m_DmaChannel
 
PMINIPORTWAVECYCLICSTREAM m_Stream
 
KSSTATE m_State
 
PKSDATAFORMAT m_Format
 
PKSPIN_CONNECT m_ConnectDetails
 
PVOID m_CommonBuffer
 
ULONG m_CommonBufferSize
 
ULONG m_CommonBufferOffset
 
IIrpQueue * m_IrpQueue
 
ULONG m_FrameSize
 
BOOL m_Capture
 
ULONG m_TotalPackets
 
ULONG m_StopCount
 
KSAUDIO_POSITION m_Position
 
KSALLOCATOR_FRAMING m_AllocatorFraming
 
PSUBDEVICE_DESCRIPTOR m_Descriptor
 
KSPIN_LOCK m_EventListLock
 
LIST_ENTRY m_EventList
 
KSRESET m_ResetState
 
ULONG m_Delay
 

Friends

NTSTATUS NTAPI PinWaveCyclicState (IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
 
NTSTATUS NTAPI PinWaveCyclicDataFormat (IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
 
NTSTATUS NTAPI PinWaveCyclicAudioPosition (IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
 
NTSTATUS NTAPI PinWaveCyclicAllocatorFraming (IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
 
NTSTATUS NTAPI PinWaveCyclicAddEndOfStreamEvent (IN PIRP Irp, IN PKSEVENTDATA EventData, IN PKSEVENT_ENTRY EventEntry)
 
NTSTATUS NTAPI PinWaveCyclicAddLoopedStreamEvent (IN PIRP Irp, IN PKSEVENTDATA EventData, IN PKSEVENT_ENTRY EventEntry)
 
VOID CALLBACK PinSetStateWorkerRoutine (IN PDEVICE_OBJECT DeviceObject, IN PVOID Context)
 

Detailed Description

Definition at line 17 of file pin_wavecyclic.cpp.

Constructor & Destructor Documentation

◆ CPortPinWaveCyclic()

CPortPinWaveCyclic::CPortPinWaveCyclic ( IUnknown OuterUnknown)
inline

Definition at line 34 of file pin_wavecyclic.cpp.

34  :
35  m_Port(nullptr),
36  m_Filter(nullptr),
37  m_KsPinDescriptor(nullptr),
38  m_Miniport(nullptr),
39  m_ServiceGroup(nullptr),
40  m_DmaChannel(nullptr),
41  m_Stream(nullptr),
43  m_Format(nullptr),
44  m_ConnectDetails(nullptr),
45  m_CommonBuffer(nullptr),
48  m_IrpQueue(nullptr),
49  m_FrameSize(0),
51  m_TotalPackets(0),
52  m_StopCount(0),
53  m_Position({0}),
54  m_AllocatorFraming({{0}}),
55  m_Descriptor(nullptr),
56  m_EventListLock(0),
57  m_EventList({nullptr}),
59  m_Delay(0)
60  {
61  }
KSAUDIO_POSITION m_Position
KSALLOCATOR_FRAMING m_AllocatorFraming
KSPIN_LOCK m_EventListLock
IIrpQueue * m_IrpQueue
#define FALSE
Definition: types.h:117
PMINIPORTWAVECYCLICSTREAM m_Stream
IPortFilterWaveCyclic * m_Filter
IPortWaveCyclic * m_Port
PDMACHANNEL m_DmaChannel
KSPIN_DESCRIPTOR * m_KsPinDescriptor
PMINIPORTWAVECYCLIC m_Miniport
PKSDATAFORMAT m_Format
PKSPIN_CONNECT m_ConnectDetails
PSUBDEVICE_DESCRIPTOR m_Descriptor
PSERVICEGROUP m_ServiceGroup

◆ ~CPortPinWaveCyclic()

virtual CPortPinWaveCyclic::~CPortPinWaveCyclic ( )
inlinevirtual

Definition at line 62 of file pin_wavecyclic.cpp.

62 {}

Member Function Documentation

◆ GeneratePositionEvents()

VOID CPortPinWaveCyclic::GeneratePositionEvents ( IN ULONGLONG  OldOffset,
IN ULONGLONG  NewOffset 
)
protected

Definition at line 645 of file pin_wavecyclic.cpp.

648 {
650  PKSEVENT_ENTRY EventEntry;
652 
653  // acquire event lock
655 
656  // point to first entry
658 
659  while(Entry != &m_EventList)
660  {
661  // get event entry
662  EventEntry = (PKSEVENT_ENTRY)CONTAINING_RECORD(Entry, KSEVENT_ENTRY, ListEntry);
663 
664  // get event entry context
665  Context = (PLOOPEDSTREAMING_EVENT_CONTEXT)(EventEntry + 1);
666 
667  if (Context->bLoopedStreaming != FALSE)
668  {
669  if (NewOffset > OldOffset)
670  {
671  /* buffer progress no overlap */
672  if (OldOffset < Context->Position && Context->Position <= NewOffset)
673  {
674  /* when someone eventually fixes sprintf... */
675  DPRINT("Generating event at OldOffset %I64u\n", OldOffset);
676  DPRINT("Context->Position %I64u\n", Context->Position);
677  DPRINT("NewOffset %I64u\n", NewOffset);
678  /* generate event */
679  KsGenerateEvent(EventEntry);
680  }
681  }
682  else
683  {
684  /* buffer wrap-arround */
685  if (OldOffset < Context->Position || NewOffset > Context->Position)
686  {
687  /* when someone eventually fixes sprintf... */
688  DPRINT("Generating event at OldOffset %I64u\n", OldOffset);
689  DPRINT("Context->Position %I64u\n", Context->Position);
690  DPRINT("NewOffset %I64u\n", NewOffset);
691  /* generate event */
692  KsGenerateEvent(EventEntry);
693  }
694  }
695  }
696 
697  // move to next entry
698  Entry = Entry->Flink;
699  }
700 
701  // release lock
703 }
struct _Entry Entry
Definition: kefuncs.h:629
static COORD Position
Definition: mouse.c:34
ULONG OldOffset
Definition: shell.c:90
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:198
KSPIN_LOCK m_EventListLock
#define FALSE
Definition: types.h:117
struct _KSEVENT_ENTRY KSEVENT_ENTRY
Definition: ks.h:2101
struct LOOPEDSTREAMING_EVENT_CONTEXT * PLOOPEDSTREAMING_EVENT_CONTEXT
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
KSDDKAPI NTSTATUS NTAPI KsGenerateEvent(IN PKSEVENT_ENTRY EntryEvent)
Definition: event.c:608
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:221
Definition: typedefs.h:119
struct tagContext Context
Definition: acpixf.h:1038
struct _KSEVENT_ENTRY * PKSEVENT_ENTRY
Definition: ks.h:2101
#define DPRINT
Definition: sndvol32.h:71
base of all file and directory entries
Definition: entries.h:82

◆ operator new()

PVOID CPortPinWaveCyclic::operator new ( size_t  Size,
POOL_TYPE  PoolType,
ULONG  Tag 
)
inline

Definition at line 22 of file pin_wavecyclic.cpp.

26  {
28  }
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810

◆ QueryInterface()

NTSTATUS NTAPI CPortPinWaveCyclic::QueryInterface ( REFIID  InterfaceId,
PVOID Interface 
)

Definition at line 204 of file pin_wavecyclic.cpp.

207 {
208  DPRINT("IServiceSink_fnQueryInterface entered\n");
209 
210  if (IsEqualGUIDAligned(refiid, IID_IIrpTarget) ||
212  {
213  *Output = PVOID(PUNKNOWN((IIrpTarget*)this));
214  PUNKNOWN(*Output)->AddRef();
215  return STATUS_SUCCESS;
216  }
217 
218  if (IsEqualGUIDAligned(refiid, IID_IServiceSink))
219  {
220  *Output = PVOID(PUNKNOWN(PSERVICESINK(this)));
221  PUNKNOWN(*Output)->AddRef();
222  return STATUS_SUCCESS;
223  }
224 
225  return STATUS_UNSUCCESSFUL;
226 }
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
IServiceSink * PSERVICESINK
Definition: portcls.h:569
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
void * PVOID
Definition: retypes.h:9
const GUID IID_IUnknown
ULONG AddRef()
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Definition: arc.h:85
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71

◆ UpdateCommonBuffer()

VOID CPortPinWaveCyclic::UpdateCommonBuffer ( ULONG  Position,
ULONG  MaxTransferCount 
)
protected

Definition at line 706 of file pin_wavecyclic.cpp.

709 {
713  ULONG Gap;
714  PUCHAR Buffer;
716 
718  BufferLength = min(BufferLength, MaxTransferCount);
719 
720  while(BufferLength)
721  {
722  Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize);
723  if (!NT_SUCCESS(Status))
724  {
726  if (Gap > BufferLength)
727  {
728  // insert silence samples
729  DPRINT("Inserting Silence Buffer Offset %lu GapLength %lu\n", m_CommonBufferOffset, BufferLength);
731 
733  }
734  break;
735  }
736 
738 
739  if (m_Capture)
740  {
742  }
743  else
744  {
746  }
747 
748  m_IrpQueue->UpdateMapping(BytesToCopy);
750 
753 
755  {
757  {
758  // normalize position
760  }
761  }
762  }
763 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
KSPIN_INTERFACE Interface
Definition: ks.h:2601
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
static COORD Position
Definition: mouse.c:34
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
KSAUDIO_POSITION m_Position
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3167
IIrpQueue * m_IrpQueue
Definition: bufpool.h:45
Status
Definition: gdiplustypes.h:24
DWORDLONG PlayOffset
Definition: ksmedia.h:1250
ULONG Id
Definition: dmksctrl.h:77
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PMINIPORTWAVECYCLICSTREAM m_Stream
PDMACHANNEL m_DmaChannel
DWORDLONG WriteOffset
Definition: ksmedia.h:1251
#define min(a, b)
Definition: monoChain.cc:55
PKSPIN_CONNECT m_ConnectDetails
unsigned int ULONG
Definition: retypes.h:1
#define DPRINT
Definition: sndvol32.h:71
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Referenced by UpdateCommonBufferOverlap().

◆ UpdateCommonBufferOverlap()

VOID CPortPinWaveCyclic::UpdateCommonBufferOverlap ( ULONG  Position,
ULONG  MaxTransferCount 
)
protected

Definition at line 766 of file pin_wavecyclic.cpp.

769 {
770  ULONG BufferLength, Length, Gap;
773  PUCHAR Buffer;
775 
776 
778  BufferLength = Length = min(BufferLength, MaxTransferCount);
779  while(BufferLength)
780  {
781  Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize);
782  if (!NT_SUCCESS(Status))
783  {
785  if (Gap > BufferLength)
786  {
787  // insert silence samples
788  DPRINT("Overlap Inserting Silence Buffer Size %lu Offset %lu Gap %lu Position %lu\n", m_CommonBufferSize, m_CommonBufferOffset, Gap, Position);
790 
792  }
793  break;
794  }
795 
797 
798  if (m_Capture)
799  {
800  m_DmaChannel->CopyFrom(Buffer,
802  BytesToCopy);
803  }
804  else
805  {
807  Buffer,
808  BytesToCopy);
809  }
810 
811  m_IrpQueue->UpdateMapping(BytesToCopy);
814 
816 
818  {
820  {
821  // normalize position
823  }
824  }
825  }
826 
827  if (Gap == Length)
828  {
830 
831  MaxTransferCount -= Length;
832 
833  if (MaxTransferCount)
834  {
835  UpdateCommonBuffer(Position, MaxTransferCount);
836  }
837  }
838 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
KSPIN_INTERFACE Interface
Definition: ks.h:2601
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
static COORD Position
Definition: mouse.c:34
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
VOID UpdateCommonBuffer(ULONG Position, ULONG MaxTransferCount)
KSAUDIO_POSITION m_Position
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3167
IIrpQueue * m_IrpQueue
Definition: bufpool.h:45
Status
Definition: gdiplustypes.h:24
DWORDLONG PlayOffset
Definition: ksmedia.h:1250
ULONG Id
Definition: dmksctrl.h:77
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PMINIPORTWAVECYCLICSTREAM m_Stream
PDMACHANNEL m_DmaChannel
DWORDLONG WriteOffset
Definition: ksmedia.h:1251
#define min(a, b)
Definition: monoChain.cc:55
PKSPIN_CONNECT m_ConnectDetails
unsigned int ULONG
Definition: retypes.h:1
#define DPRINT
Definition: sndvol32.h:71
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Friends And Related Function Documentation

◆ PinSetStateWorkerRoutine

VOID CALLBACK PinSetStateWorkerRoutine ( IN PDEVICE_OBJECT  DeviceObject,
IN PVOID  Context 
)
friend

Definition at line 415 of file pin_wavecyclic.cpp.

418 {
419  PSETPIN_CONTEXT PinWorkContext = (PSETPIN_CONTEXT)Context;
421 
422  // try set stream
423  Status = PinWorkContext->Pin->m_Stream->SetState(PinWorkContext->NewState);
424 
425  DPRINT1("Setting state %u %x\n", PinWorkContext->NewState, Status);
426  if (NT_SUCCESS(Status))
427  {
428  // store new state
429  PinWorkContext->Pin->m_State = PinWorkContext->NewState;
430 
431  if (PinWorkContext->Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING && PinWorkContext->Pin->m_State == KSSTATE_STOP)
432  {
433  /* FIXME complete pending irps with successful state */
434  PinWorkContext->Pin->m_IrpQueue->CancelBuffers();
435  }
436  //HACK
437  //PinWorkContext->Pin->m_IrpQueue->CancelBuffers();
438  }
439 
440  // store result
441  PinWorkContext->Irp->IoStatus.Information = sizeof(KSSTATE);
442  PinWorkContext->Irp->IoStatus.Status = Status;
443 
444  // complete irp
445  IoCompleteRequest(PinWorkContext->Irp, IO_NO_INCREMENT);
446 
447  // free work item
448  IoFreeWorkItem(PinWorkContext->WorkItem);
449 
450  // free work context
451  FreeItem(PinWorkContext, TAG_PORTCLASS);
452 
453 }
KSPIN_INTERFACE Interface
Definition: ks.h:2601
#define TAG_PORTCLASS
Definition: private.hpp:24
LONG NTSTATUS
Definition: precomp.h:26
IO_STATUS_BLOCK IoStatus
PIO_WORKITEM WorkItem
CPortPinWaveCyclic * Pin
VOID NTAPI IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
Definition: iowork.c:64
struct SETPIN_CONTEXT * PSETPIN_CONTEXT
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
IIrpQueue * m_IrpQueue
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
ULONG Id
Definition: dmksctrl.h:77
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PMINIPORTWAVECYCLICSTREAM m_Stream
KSSTATE
Definition: ks.h:1214
#define DPRINT1
Definition: precomp.h:8
PKSPIN_CONNECT m_ConnectDetails
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ PinWaveCyclicAddEndOfStreamEvent

NTSTATUS NTAPI PinWaveCyclicAddEndOfStreamEvent ( IN PIRP  Irp,
IN PKSEVENTDATA  EventData,
IN PKSEVENT_ENTRY  EventEntry 
)
friend

Definition at line 243 of file pin_wavecyclic.cpp.

247 {
251 
252  // get sub device descriptor
253  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
254 
255  // sanity check
257  PC_ASSERT(Descriptor->PortPin);
259 
260  // cast to pin impl
261  Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
262 
263  // get extra size
264  Entry = (PENDOFSTREAM_EVENT_CONTEXT)(EventEntry + 1);
265 
266  // not a looped event
267  Entry->bLoopedStreaming = FALSE;
268 
269  // insert item
270  (void)ExInterlockedInsertTailList(&Pin->m_EventList, &EventEntry->ListEntry, &Pin->m_EventListLock);
271 
272  // done
273  return STATUS_SUCCESS;
274 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
struct _Entry Entry
Definition: kefuncs.h:629
#define PC_ASSERT(exp)
Definition: private.hpp:26
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:424
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define STATUS_SUCCESS
Definition: shellext.h:65
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
base of all file and directory entries
Definition: entries.h:82
#define PC_ASSERT_IRQL(x)
Definition: private.hpp:30

◆ PinWaveCyclicAddLoopedStreamEvent

NTSTATUS NTAPI PinWaveCyclicAddLoopedStreamEvent ( IN PIRP  Irp,
IN PKSEVENTDATA  EventData,
IN PKSEVENT_ENTRY  EventEntry 
)
friend

Definition at line 278 of file pin_wavecyclic.cpp.

282 {
287 
288  // get sub device descriptor
289  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSEVENT_ITEM_IRP_STORAGE(Irp);
290 
291  // sanity check
293  PC_ASSERT(Descriptor->PortPin);
295 
296  // cast to pin impl
297  Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
298 
299  // cast to looped event
301 
302  // get extra size
303  Entry = (PLOOPEDSTREAMING_EVENT_CONTEXT)(EventEntry + 1);
304 
305  Entry->bLoopedStreaming = TRUE;
306  Entry->Position = Data->Position;
307 
308  DPRINT1("Added event\n");
309 
310  // insert item
311  (void)ExInterlockedInsertTailList(&Pin->m_EventList, &EventEntry->ListEntry, &Pin->m_EventListLock);
312 
313  // done
314  return STATUS_SUCCESS;
315 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
#define PC_ASSERT(exp)
Definition: private.hpp:26
_In_ PIRP Irp
Definition: csq.h:116
struct LOOPEDSTREAMING_EVENT_CONTEXT * PLOOPEDSTREAMING_EVENT_CONTEXT
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:424
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define DPRINT1
Definition: precomp.h:8
#define STATUS_SUCCESS
Definition: shellext.h:65
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
base of all file and directory entries
Definition: entries.h:82
#define PC_ASSERT_IRQL(x)
Definition: private.hpp:30

◆ PinWaveCyclicAllocatorFraming

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

Definition at line 319 of file pin_wavecyclic.cpp.

323 {
326 
327  // get sub device descriptor
328  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSEVENT_ITEM_IRP_STORAGE(Irp);
329 
330  // sanity check
332  PC_ASSERT(Descriptor->PortPin);
334 
335  // cast to pin impl
336  Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
337 
338 
339  if (Request->Flags & KSPROPERTY_TYPE_GET)
340  {
341  // copy pin framing
342  RtlMoveMemory(Data, &Pin->m_AllocatorFraming, sizeof(KSALLOCATOR_FRAMING));
343 
344  Irp->IoStatus.Information = sizeof(KSALLOCATOR_FRAMING);
345  return STATUS_SUCCESS;
346  }
347 
348  // not supported
349  return STATUS_NOT_SUPPORTED;
350 }
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

◆ PinWaveCyclicAudioPosition

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

Definition at line 354 of file pin_wavecyclic.cpp.

358 {
362 
363  // get sub device descriptor
364  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
365 
366  // sanity check
368  PC_ASSERT(Descriptor->PortPin);
370 
371  // cast to pin impl
372  Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
373 
374  //sanity check
375  PC_ASSERT(Pin->m_Stream);
376 
377  if (Request->Flags & KSPROPERTY_TYPE_GET)
378  {
379  // FIXME non multithreading-safe
380  // copy audio position
381 
383 
384  if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_STREAMING)
385  {
386  RtlMoveMemory(Data, &Pin->m_Position, sizeof(KSAUDIO_POSITION));
387  DPRINT("Play %lu Record %lu\n", Pin->m_Position.PlayOffset, Pin->m_Position.WriteOffset);
388  }
389  else if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING)
390  {
391  Position->PlayOffset = Pin->m_Position.PlayOffset;
392  Position->WriteOffset = (ULONGLONG)Pin->m_IrpQueue->GetCurrentIrpOffset();
393  DPRINT("Play %lu Write %lu\n", Position->PlayOffset, Position->WriteOffset);
394  }
395 
396  Irp->IoStatus.Information = sizeof(KSAUDIO_POSITION);
397  return STATUS_SUCCESS;
398  }
399 
400  // not supported
401  return STATUS_NOT_SUPPORTED;
402 }
return STATUS_NOT_SUPPORTED
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
static COORD Position
Definition: mouse.c:34
_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
uint64_t ULONGLONG
Definition: typedefs.h:67
#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
struct KSAUDIO_POSITION * PKSAUDIO_POSITION
#define PC_ASSERT_IRQL(x)
Definition: private.hpp:30

◆ PinWaveCyclicDataFormat

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

Definition at line 530 of file pin_wavecyclic.cpp.

534 {
538  PIO_STACK_LOCATION IoStack;
539 
540  // get current irp stack location
542 
543  // get sub device descriptor
544  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
545 
546  // sanity check
548  PC_ASSERT(Descriptor->PortPin);
549 
550  // cast to pin impl
551  Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
552 
553  //sanity check
554  PC_ASSERT(Pin->m_Stream);
555  PC_ASSERT(Pin->m_Format);
556 
557  if (Request->Flags & KSPROPERTY_TYPE_SET)
558  {
559  // try to change data format
560  PKSDATAFORMAT NewDataFormat, DataFormat = (PKSDATAFORMAT)Irp->UserBuffer;
561  ULONG Size = min(Pin->m_Format->FormatSize, DataFormat->FormatSize);
562 
563  if (RtlCompareMemory(DataFormat, Pin->m_Format, Size) == Size)
564  {
565  // format is identical
566  Irp->IoStatus.Information = DataFormat->FormatSize;
567  return STATUS_SUCCESS;
568  }
569 
570  // new change request
571  PC_ASSERT(Pin->m_State != KSSTATE_RUN);
572  // FIXME queue a work item when Irql != PASSIVE_LEVEL
574 
575  // allocate new data format
576  NewDataFormat = (PKSDATAFORMAT)AllocateItem(NonPagedPool, DataFormat->FormatSize, TAG_PORTCLASS);
577  if (!NewDataFormat)
578  {
579  // not enough memory
580  return STATUS_NO_MEMORY;
581  }
582 
583  // copy new data format
584  RtlMoveMemory(NewDataFormat, DataFormat, DataFormat->FormatSize);
585 
586  // set new format
587  Status = Pin->m_Stream->SetFormat(NewDataFormat);
588  if (NT_SUCCESS(Status))
589  {
590  // free old format
591  FreeItem(Pin->m_Format, TAG_PORTCLASS);
592 
593  // store new format
594  Pin->m_Format = NewDataFormat;
595  Irp->IoStatus.Information = NewDataFormat->FormatSize;
596 
597 #if 0
598  PC_ASSERT(NewDataFormat->FormatSize == sizeof(KSDATAFORMAT_WAVEFORMATEX));
602 
603 
604  DPRINT("NewDataFormat: Channels %u Bits %u Samples %u\n", ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.nChannels,
605  ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.wBitsPerSample,
606  ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.nSamplesPerSec);
607 #endif
608 
609  }
610  else
611  {
612  // failed to set format
613  FreeItem(NewDataFormat, TAG_PORTCLASS);
614  }
615 
616 
617  // done
618  return Status;
619  }
620  else if (Request->Flags & KSPROPERTY_TYPE_GET)
621  {
622  // get current data format
623  PC_ASSERT(Pin->m_Format);
624 
625  if (Pin->m_Format->FormatSize > IoStack->Parameters.DeviceIoControl.OutputBufferLength)
626  {
627  // buffer too small
628  Irp->IoStatus.Information = Pin->m_Format->FormatSize;
629  return STATUS_MORE_ENTRIES;
630  }
631  // copy data format
632  RtlMoveMemory(Data, Pin->m_Format, Pin->m_Format->FormatSize);
633  // store result size
634  Irp->IoStatus.Information = Pin->m_Format->FormatSize;
635 
636  // done
637  return STATUS_SUCCESS;
638  }
639 
640  // unsupported request
641  return STATUS_NOT_SUPPORTED;
642 }
#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

◆ PinWaveCyclicState

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

Definition at line 458 of file pin_wavecyclic.cpp.

462 {
467 
468  // get sub device descriptor
469  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
470 
471  // sanity check
473  PC_ASSERT(Descriptor->PortPin);
475 
476  // cast to pin impl
477  Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
478 
479  //sanity check
480  PC_ASSERT(Pin->m_Stream);
481 
482  if (Request->Flags & KSPROPERTY_TYPE_SET)
483  {
484  // try set stream
485  Status = Pin->m_Stream->SetState(*State);
486 
487  DPRINT("Setting state %u %x\n", *State, Status);
488  if (NT_SUCCESS(Status))
489  {
490  // store new state
491  Pin->m_State = *State;
492 
493  if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING && Pin->m_State == KSSTATE_STOP)
494  {
495  // FIXME
496  // complete with successful state
497  Pin->m_Stream->Silence(Pin->m_CommonBuffer, Pin->m_CommonBufferSize);
498  Pin->m_IrpQueue->CancelBuffers();
499  Pin->m_Position.PlayOffset = 0;
500  Pin->m_Position.WriteOffset = 0;
501  }
502  else if (Pin->m_State == KSSTATE_STOP)
503  {
504  Pin->m_Stream->Silence(Pin->m_CommonBuffer, Pin->m_CommonBufferSize);
505  Pin->m_IrpQueue->CancelBuffers();
506  Pin->m_Position.PlayOffset = 0;
507  Pin->m_Position.WriteOffset = 0;
508  }
509  // store result
510  Irp->IoStatus.Information = sizeof(KSSTATE);
511  }
512  return Status;
513  }
514  else if (Request->Flags & KSPROPERTY_TYPE_GET)
515  {
516  // get current stream state
517  *State = Pin->m_State;
518  // store result
519  Irp->IoStatus.Information = sizeof(KSSTATE);
520 
521  return STATUS_SUCCESS;
522  }
523 
524  // unsupported request
525  return STATUS_NOT_SUPPORTED;
526 }
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
#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
#define PC_ASSERT_IRQL(x)
Definition: private.hpp:30

Member Data Documentation

◆ IMP_IPortPinWaveCyclic

CPortPinWaveCyclic::IMP_IPortPinWaveCyclic

Definition at line 32 of file pin_wavecyclic.cpp.

◆ IMP_IServiceSink

CPortPinWaveCyclic::IMP_IServiceSink

Definition at line 33 of file pin_wavecyclic.cpp.

◆ m_AllocatorFraming

KSALLOCATOR_FRAMING CPortPinWaveCyclic::m_AllocatorFraming
protected

Definition at line 101 of file pin_wavecyclic.cpp.

◆ m_Capture

BOOL CPortPinWaveCyclic::m_Capture
protected

Definition at line 96 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_CommonBuffer

PVOID CPortPinWaveCyclic::m_CommonBuffer
protected

Definition at line 89 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_CommonBufferOffset

ULONG CPortPinWaveCyclic::m_CommonBufferOffset
protected

Definition at line 91 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_CommonBufferSize

ULONG CPortPinWaveCyclic::m_CommonBufferSize
protected

Definition at line 90 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBufferOverlap().

◆ m_ConnectDetails

PKSPIN_CONNECT CPortPinWaveCyclic::m_ConnectDetails
protected

◆ m_Delay

ULONG CPortPinWaveCyclic::m_Delay
protected

Definition at line 109 of file pin_wavecyclic.cpp.

◆ m_Descriptor

PSUBDEVICE_DESCRIPTOR CPortPinWaveCyclic::m_Descriptor
protected

Definition at line 102 of file pin_wavecyclic.cpp.

◆ m_DmaChannel

PDMACHANNEL CPortPinWaveCyclic::m_DmaChannel
protected

Definition at line 83 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_EventList

LIST_ENTRY CPortPinWaveCyclic::m_EventList
protected

Definition at line 105 of file pin_wavecyclic.cpp.

Referenced by GeneratePositionEvents().

◆ m_EventListLock

KSPIN_LOCK CPortPinWaveCyclic::m_EventListLock
protected

Definition at line 104 of file pin_wavecyclic.cpp.

Referenced by GeneratePositionEvents().

◆ m_Filter

IPortFilterWaveCyclic* CPortPinWaveCyclic::m_Filter
protected

Definition at line 79 of file pin_wavecyclic.cpp.

◆ m_Format

PKSDATAFORMAT CPortPinWaveCyclic::m_Format
protected

Definition at line 86 of file pin_wavecyclic.cpp.

◆ m_FrameSize

ULONG CPortPinWaveCyclic::m_FrameSize
protected

Definition at line 95 of file pin_wavecyclic.cpp.

◆ m_IrpQueue

IIrpQueue* CPortPinWaveCyclic::m_IrpQueue
protected

◆ m_KsPinDescriptor

KSPIN_DESCRIPTOR* CPortPinWaveCyclic::m_KsPinDescriptor
protected

Definition at line 80 of file pin_wavecyclic.cpp.

◆ m_Miniport

PMINIPORTWAVECYCLIC CPortPinWaveCyclic::m_Miniport
protected

Definition at line 81 of file pin_wavecyclic.cpp.

◆ m_Port

IPortWaveCyclic* CPortPinWaveCyclic::m_Port
protected

Definition at line 78 of file pin_wavecyclic.cpp.

◆ m_Position

KSAUDIO_POSITION CPortPinWaveCyclic::m_Position
protected

Definition at line 100 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_ResetState

KSRESET CPortPinWaveCyclic::m_ResetState
protected

Definition at line 107 of file pin_wavecyclic.cpp.

◆ m_ServiceGroup

PSERVICEGROUP CPortPinWaveCyclic::m_ServiceGroup
protected

Definition at line 82 of file pin_wavecyclic.cpp.

◆ m_State

KSSTATE CPortPinWaveCyclic::m_State
protected

Definition at line 85 of file pin_wavecyclic.cpp.

Referenced by PinSetStateWorkerRoutine().

◆ m_StopCount

ULONG CPortPinWaveCyclic::m_StopCount
protected

Definition at line 99 of file pin_wavecyclic.cpp.

◆ m_Stream

PMINIPORTWAVECYCLICSTREAM CPortPinWaveCyclic::m_Stream
protected

◆ m_TotalPackets

ULONG CPortPinWaveCyclic::m_TotalPackets
protected

Definition at line 98 of file pin_wavecyclic.cpp.


The documentation for this class was generated from the following file: