ReactOS  0.4.13-dev-551-gf37fb1f
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)
 
 STDMETHODIMP_ (ULONG) AddRef()
 
 STDMETHODIMP_ (ULONG) Release()
 
 CPortPinWaveCyclic (IUnknown *OuterUnknown)
 
virtual ~CPortPinWaveCyclic ()
 

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 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
 
LONG m_Ref
 

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 51 of file pin_wavecyclic.cpp.

51 {}

◆ ~CPortPinWaveCyclic()

virtual CPortPinWaveCyclic::~CPortPinWaveCyclic ( )
inlinevirtual

Definition at line 52 of file pin_wavecyclic.cpp.

52 {}

Member Function Documentation

◆ GeneratePositionEvents()

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

Definition at line 637 of file pin_wavecyclic.cpp.

640 {
642  PKSEVENT_ENTRY EventEntry;
644 
645  // acquire event lock
647 
648  // point to first entry
650 
651  while(Entry != &m_EventList)
652  {
653  // get event entry
654  EventEntry = (PKSEVENT_ENTRY)CONTAINING_RECORD(Entry, KSEVENT_ENTRY, ListEntry);
655 
656  // get event entry context
657  Context = (PLOOPEDSTREAMING_EVENT_CONTEXT)(EventEntry + 1);
658 
659  if (Context->bLoopedStreaming != FALSE)
660  {
661  if (NewOffset > OldOffset)
662  {
663  /* buffer progress no overlap */
664  if (OldOffset < Context->Position && Context->Position <= NewOffset)
665  {
666  /* when someone eventually fixes sprintf... */
667  DPRINT("Generating event at OldOffset %I64u\n", OldOffset);
668  DPRINT("Context->Position %I64u\n", Context->Position);
669  DPRINT("NewOffset %I64u\n", NewOffset);
670  /* generate event */
671  KsGenerateEvent(EventEntry);
672  }
673  }
674  else
675  {
676  /* buffer wrap-arround */
677  if (OldOffset < Context->Position || NewOffset > Context->Position)
678  {
679  /* when someone eventually fixes sprintf... */
680  DPRINT("Generating event at OldOffset %I64u\n", OldOffset);
681  DPRINT("Context->Position %I64u\n", Context->Position);
682  DPRINT("NewOffset %I64u\n", NewOffset);
683  /* generate event */
684  KsGenerateEvent(EventEntry);
685  }
686  }
687  }
688 
689  // move to next entry
690  Entry = Entry->Flink;
691  }
692 
693  // release lock
695 }
struct _Entry Entry
Definition: kefuncs.h:640
static COORD Position
Definition: mouse.c:34
ULONG OldOffset
Definition: shell.c:90
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
KSPIN_LOCK m_EventListLock
struct _KSEVENT_ENTRY KSEVENT_ENTRY
Definition: ks.h:2131
struct LOOPEDSTREAMING_EVENT_CONTEXT * PLOOPEDSTREAMING_EVENT_CONTEXT
void DPRINT(...)
Definition: polytest.cpp:61
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:119
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
Definition: typedefs.h:117
struct tagContext Context
Definition: acpixf.h:1012
struct _KSEVENT_ENTRY * PKSEVENT_ENTRY
Definition: ks.h:2131
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 23 of file pin_wavecyclic.cpp.

27  {
29  }
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T _In_ POOL_TYPE PoolType
Definition: fltkernel.h:1444

◆ QueryInterface()

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

Definition at line 196 of file pin_wavecyclic.cpp.

199 {
200  DPRINT("IServiceSink_fnQueryInterface entered\n");
201 
202  if (IsEqualGUIDAligned(refiid, IID_IIrpTarget) ||
204  {
205  *Output = PVOID(PUNKNOWN((IIrpTarget*)this));
206  PUNKNOWN(*Output)->AddRef();
207  return STATUS_SUCCESS;
208  }
209 
210  if (IsEqualGUIDAligned(refiid, IID_IServiceSink))
211  {
212  *Output = PVOID(PUNKNOWN(PSERVICESINK(this)));
213  PUNKNOWN(*Output)->AddRef();
214  return STATUS_SUCCESS;
215  }
216 
217  return STATUS_UNSUCCESSFUL;
218 }
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
IServiceSink * PSERVICESINK
Definition: portcls.h:569
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
void DPRINT(...)
Definition: polytest.cpp:61
void * PVOID
Definition: retypes.h:9
const GUID IID_IUnknown
ULONG AddRef()
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Definition: arc.h:85
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ STDMETHODIMP_() [1/2]

CPortPinWaveCyclic::STDMETHODIMP_ ( ULONG  )
inline

Definition at line 33 of file pin_wavecyclic.cpp.

34  {
36  return m_Ref;
37  }
#define InterlockedIncrement
Definition: armddk.h:53

◆ STDMETHODIMP_() [2/2]

CPortPinWaveCyclic::STDMETHODIMP_ ( ULONG  )
inline

Definition at line 38 of file pin_wavecyclic.cpp.

39  {
41 
42  if (!m_Ref)
43  {
44  delete this;
45  return 0;
46  }
47  return m_Ref;
48  }
#define InterlockedDecrement
Definition: armddk.h:52

◆ UpdateCommonBuffer()

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

Definition at line 698 of file pin_wavecyclic.cpp.

701 {
705  ULONG Gap;
706  PUCHAR Buffer;
708 
710  BufferLength = min(BufferLength, MaxTransferCount);
711 
712  while(BufferLength)
713  {
714  Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize);
715  if (!NT_SUCCESS(Status))
716  {
718  if (Gap > BufferLength)
719  {
720  // insert silence samples
721  DPRINT("Inserting Silence Buffer Offset %lu GapLength %lu\n", m_CommonBufferOffset, BufferLength);
723 
725  }
726  break;
727  }
728 
730 
731  if (m_Capture)
732  {
734  }
735  else
736  {
738  }
739 
740  m_IrpQueue->UpdateMapping(BytesToCopy);
742 
745 
747  {
749  {
750  // normalize position
752  }
753  }
754  }
755 }
KSPIN_INTERFACE Interface
Definition: ks.h:2630
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
_In_ ULONG BufferLength
Definition: usbdlib.h:225
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
DWORDLONG PlayOffset
Definition: ksmedia.h:1150
ULONG Id
Definition: dmksctrl.h:77
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PMINIPORTWAVECYCLICSTREAM m_Stream
#define BufferSize
Definition: classpnp.h:419
PDMACHANNEL m_DmaChannel
Status
Definition: gdiplustypes.h:24
DWORDLONG WriteOffset
Definition: ksmedia.h:1151
#define min(a, b)
Definition: monoChain.cc:55
PKSPIN_CONNECT m_ConnectDetails
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by UpdateCommonBufferOverlap().

◆ UpdateCommonBufferOverlap()

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

Definition at line 758 of file pin_wavecyclic.cpp.

761 {
762  ULONG BufferLength, Length, Gap;
765  PUCHAR Buffer;
767 
768 
770  BufferLength = Length = min(BufferLength, MaxTransferCount);
771  while(BufferLength)
772  {
773  Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize);
774  if (!NT_SUCCESS(Status))
775  {
777  if (Gap > BufferLength)
778  {
779  // insert silence samples
780  DPRINT("Overlap Inserting Silence Buffer Size %lu Offset %lu Gap %lu Position %lu\n", m_CommonBufferSize, m_CommonBufferOffset, Gap, Position);
782 
784  }
785  break;
786  }
787 
789 
790  if (m_Capture)
791  {
792  m_DmaChannel->CopyFrom(Buffer,
794  BytesToCopy);
795  }
796  else
797  {
799  Buffer,
800  BytesToCopy);
801  }
802 
803  m_IrpQueue->UpdateMapping(BytesToCopy);
806 
808 
810  {
812  {
813  // normalize position
815  }
816  }
817  }
818 
819  if (Gap == Length)
820  {
822 
823  MaxTransferCount -= Length;
824 
825  if (MaxTransferCount)
826  {
827  UpdateCommonBuffer(Position, MaxTransferCount);
828  }
829  }
830 }
KSPIN_INTERFACE Interface
Definition: ks.h:2630
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
_In_ ULONG BufferLength
Definition: usbdlib.h:225
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
DWORDLONG PlayOffset
Definition: ksmedia.h:1150
ULONG Id
Definition: dmksctrl.h:77
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PMINIPORTWAVECYCLICSTREAM m_Stream
#define BufferSize
Definition: classpnp.h:419
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
PDMACHANNEL m_DmaChannel
Status
Definition: gdiplustypes.h:24
DWORDLONG WriteOffset
Definition: ksmedia.h:1151
#define min(a, b)
Definition: monoChain.cc:55
PKSPIN_CONNECT m_ConnectDetails
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Friends And Related Function Documentation

◆ PinSetStateWorkerRoutine

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

Definition at line 407 of file pin_wavecyclic.cpp.

410 {
411  PSETPIN_CONTEXT PinWorkContext = (PSETPIN_CONTEXT)Context;
413 
414  // try set stream
415  Status = PinWorkContext->Pin->m_Stream->SetState(PinWorkContext->NewState);
416 
417  DPRINT1("Setting state %u %x\n", PinWorkContext->NewState, Status);
418  if (NT_SUCCESS(Status))
419  {
420  // store new state
421  PinWorkContext->Pin->m_State = PinWorkContext->NewState;
422 
423  if (PinWorkContext->Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING && PinWorkContext->Pin->m_State == KSSTATE_STOP)
424  {
425  /* FIXME complete pending irps with successful state */
426  PinWorkContext->Pin->m_IrpQueue->CancelBuffers();
427  }
428  //HACK
429  //PinWorkContext->Pin->m_IrpQueue->CancelBuffers();
430  }
431 
432  // store result
433  PinWorkContext->Irp->IoStatus.Information = sizeof(KSSTATE);
434  PinWorkContext->Irp->IoStatus.Status = Status;
435 
436  // complete irp
437  IoCompleteRequest(PinWorkContext->Irp, IO_NO_INCREMENT);
438 
439  // free work item
440  IoFreeWorkItem(PinWorkContext->WorkItem);
441 
442  // free work context
443  FreeItem(PinWorkContext, TAG_PORTCLASS);
444 
445 }
KSPIN_INTERFACE Interface
Definition: ks.h:2630
#define TAG_PORTCLASS
Definition: private.hpp:24
LONG NTSTATUS
Definition: precomp.h:26
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
ULONG Id
Definition: dmksctrl.h:77
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PMINIPORTWAVECYCLICSTREAM m_Stream
Status
Definition: gdiplustypes.h:24
KSSTATE
Definition: ks.h:1244
#define DPRINT1
Definition: precomp.h:8
PKSPIN_CONNECT m_ConnectDetails
#define IO_NO_INCREMENT
Definition: iotypes.h:565

◆ PinWaveCyclicAddEndOfStreamEvent

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

Definition at line 235 of file pin_wavecyclic.cpp.

239 {
243 
244  // get sub device descriptor
245  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
246 
247  // sanity check
249  PC_ASSERT(Descriptor->PortPin);
251 
252  // cast to pin impl
253  Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
254 
255  // get extra size
256  Entry = (PENDOFSTREAM_EVENT_CONTEXT)(EventEntry + 1);
257 
258  // not a looped event
259  Entry->bLoopedStreaming = FALSE;
260 
261  // insert item
262  (void)ExInterlockedInsertTailList(&Pin->m_EventList, &EventEntry->ListEntry, &Pin->m_EventListLock);
263 
264  // done
265  return STATUS_SUCCESS;
266 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define PC_ASSERT(exp)
Definition: usbehci.h:17
struct _Entry Entry
Definition: kefuncs.h:640
_In_ PIRP Irp
Definition: csq.h:116
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
return STATUS_SUCCESS
Definition: btrfs.c:2777
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
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

◆ PinWaveCyclicAddLoopedStreamEvent

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

Definition at line 270 of file pin_wavecyclic.cpp.

274 {
279 
280  // get sub device descriptor
281  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSEVENT_ITEM_IRP_STORAGE(Irp);
282 
283  // sanity check
285  PC_ASSERT(Descriptor->PortPin);
287 
288  // cast to pin impl
289  Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
290 
291  // cast to looped event
293 
294  // get extra size
295  Entry = (PLOOPEDSTREAMING_EVENT_CONTEXT)(EventEntry + 1);
296 
297  Entry->bLoopedStreaming = TRUE;
298  Entry->Position = Data->Position;
299 
300  DPRINT1("Added event\n");
301 
302  // insert item
303  (void)ExInterlockedInsertTailList(&Pin->m_EventList, &EventEntry->ListEntry, &Pin->m_EventListLock);
304 
305  // done
306  return STATUS_SUCCESS;
307 }
#define TRUE
Definition: types.h:120
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define PC_ASSERT(exp)
Definition: usbehci.h:17
struct _Entry Entry
Definition: kefuncs.h:640
_In_ PIRP Irp
Definition: csq.h:116
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
struct LOOPEDSTREAMING_EVENT_CONTEXT * PLOOPEDSTREAMING_EVENT_CONTEXT
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define DPRINT1
Definition: precomp.h:8
return STATUS_SUCCESS
Definition: btrfs.c:2777
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
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

◆ PinWaveCyclicAllocatorFraming

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

Definition at line 311 of file pin_wavecyclic.cpp.

315 {
318 
319  // get sub device descriptor
320  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSEVENT_ITEM_IRP_STORAGE(Irp);
321 
322  // sanity check
324  PC_ASSERT(Descriptor->PortPin);
326 
327  // cast to pin impl
328  Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
329 
330 
331  if (Request->Flags & KSPROPERTY_TYPE_GET)
332  {
333  // copy pin framing
334  RtlMoveMemory(Data, &Pin->m_AllocatorFraming, sizeof(KSALLOCATOR_FRAMING));
335 
336  Irp->IoStatus.Information = sizeof(KSALLOCATOR_FRAMING);
337  return STATUS_SUCCESS;
338  }
339 
340  // not supported
341  return STATUS_NOT_SUPPORTED;
342 }
#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:2777
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

◆ PinWaveCyclicAudioPosition

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

Definition at line 346 of file pin_wavecyclic.cpp.

350 {
354 
355  // get sub device descriptor
356  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
357 
358  // sanity check
360  PC_ASSERT(Descriptor->PortPin);
362 
363  // cast to pin impl
364  Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
365 
366  //sanity check
367  PC_ASSERT(Pin->m_Stream);
368 
369  if (Request->Flags & KSPROPERTY_TYPE_GET)
370  {
371  // FIXME non multithreading-safe
372  // copy audio position
373 
375 
376  if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_STREAMING)
377  {
378  RtlMoveMemory(Data, &Pin->m_Position, sizeof(KSAUDIO_POSITION));
379  DPRINT("Play %lu Record %lu\n", Pin->m_Position.PlayOffset, Pin->m_Position.WriteOffset);
380  }
381  else if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING)
382  {
383  Position->PlayOffset = Pin->m_Position.PlayOffset;
384  Position->WriteOffset = (ULONGLONG)Pin->m_IrpQueue->GetCurrentIrpOffset();
385  DPRINT("Play %lu Write %lu\n", Position->PlayOffset, Position->WriteOffset);
386  }
387 
388  Irp->IoStatus.Information = sizeof(KSAUDIO_POSITION);
389  return STATUS_SUCCESS;
390  }
391 
392  // not supported
393  return STATUS_NOT_SUPPORTED;
394 }
#define PC_ASSERT(exp)
Definition: usbehci.h:17
_In_ PIRP Irp
Definition: csq.h:116
static COORD Position
Definition: mouse.c:34
#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
uint64_t ULONGLONG
Definition: typedefs.h:65
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
return STATUS_SUCCESS
Definition: btrfs.c:2777
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
struct KSAUDIO_POSITION * PKSAUDIO_POSITION
#define PC_ASSERT_IRQL(x)
Definition: private.hpp:30
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

◆ PinWaveCyclicDataFormat

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

Definition at line 522 of file pin_wavecyclic.cpp.

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

◆ PinWaveCyclicState

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

Definition at line 450 of file pin_wavecyclic.cpp.

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

Member Data Documentation

◆ IMP_IPortPinWaveCyclic

CPortPinWaveCyclic::IMP_IPortPinWaveCyclic

Definition at line 49 of file pin_wavecyclic.cpp.

◆ IMP_IServiceSink

CPortPinWaveCyclic::IMP_IServiceSink

Definition at line 50 of file pin_wavecyclic.cpp.

◆ m_AllocatorFraming

KSALLOCATOR_FRAMING CPortPinWaveCyclic::m_AllocatorFraming
protected

Definition at line 91 of file pin_wavecyclic.cpp.

◆ m_Capture

BOOL CPortPinWaveCyclic::m_Capture
protected

Definition at line 86 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_CommonBuffer

PVOID CPortPinWaveCyclic::m_CommonBuffer
protected

Definition at line 79 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_CommonBufferOffset

ULONG CPortPinWaveCyclic::m_CommonBufferOffset
protected

Definition at line 81 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_CommonBufferSize

ULONG CPortPinWaveCyclic::m_CommonBufferSize
protected

Definition at line 80 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 99 of file pin_wavecyclic.cpp.

◆ m_Descriptor

PSUBDEVICE_DESCRIPTOR CPortPinWaveCyclic::m_Descriptor
protected

Definition at line 92 of file pin_wavecyclic.cpp.

◆ m_DmaChannel

PDMACHANNEL CPortPinWaveCyclic::m_DmaChannel
protected

Definition at line 73 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_EventList

LIST_ENTRY CPortPinWaveCyclic::m_EventList
protected

Definition at line 95 of file pin_wavecyclic.cpp.

Referenced by GeneratePositionEvents().

◆ m_EventListLock

KSPIN_LOCK CPortPinWaveCyclic::m_EventListLock
protected

Definition at line 94 of file pin_wavecyclic.cpp.

Referenced by GeneratePositionEvents().

◆ m_Filter

IPortFilterWaveCyclic* CPortPinWaveCyclic::m_Filter
protected

Definition at line 69 of file pin_wavecyclic.cpp.

◆ m_Format

PKSDATAFORMAT CPortPinWaveCyclic::m_Format
protected

Definition at line 76 of file pin_wavecyclic.cpp.

◆ m_FrameSize

ULONG CPortPinWaveCyclic::m_FrameSize
protected

Definition at line 85 of file pin_wavecyclic.cpp.

◆ m_IrpQueue

IIrpQueue* CPortPinWaveCyclic::m_IrpQueue
protected

◆ m_KsPinDescriptor

KSPIN_DESCRIPTOR* CPortPinWaveCyclic::m_KsPinDescriptor
protected

Definition at line 70 of file pin_wavecyclic.cpp.

◆ m_Miniport

PMINIPORTWAVECYCLIC CPortPinWaveCyclic::m_Miniport
protected

Definition at line 71 of file pin_wavecyclic.cpp.

◆ m_Port

IPortWaveCyclic* CPortPinWaveCyclic::m_Port
protected

Definition at line 68 of file pin_wavecyclic.cpp.

◆ m_Position

KSAUDIO_POSITION CPortPinWaveCyclic::m_Position
protected

Definition at line 90 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_Ref

LONG CPortPinWaveCyclic::m_Ref
protected

Definition at line 101 of file pin_wavecyclic.cpp.

Referenced by STDMETHODIMP_().

◆ m_ResetState

KSRESET CPortPinWaveCyclic::m_ResetState
protected

Definition at line 97 of file pin_wavecyclic.cpp.

◆ m_ServiceGroup

PSERVICEGROUP CPortPinWaveCyclic::m_ServiceGroup
protected

Definition at line 72 of file pin_wavecyclic.cpp.

◆ m_State

KSSTATE CPortPinWaveCyclic::m_State
protected

Definition at line 75 of file pin_wavecyclic.cpp.

Referenced by PinSetStateWorkerRoutine().

◆ m_StopCount

ULONG CPortPinWaveCyclic::m_StopCount
protected

Definition at line 89 of file pin_wavecyclic.cpp.

◆ m_Stream

PMINIPORTWAVECYCLICSTREAM CPortPinWaveCyclic::m_Stream
protected

◆ m_TotalPackets

ULONG CPortPinWaveCyclic::m_TotalPackets
protected

Definition at line 88 of file pin_wavecyclic.cpp.


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