ReactOS  0.4.14-dev-49-gfb4591c
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 54 of file pin_wavecyclic.cpp.

54 {}

◆ ~CPortPinWaveCyclic()

virtual CPortPinWaveCyclic::~CPortPinWaveCyclic ( )
inlinevirtual

Definition at line 55 of file pin_wavecyclic.cpp.

55 {}

Member Function Documentation

◆ GeneratePositionEvents()

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

Definition at line 640 of file pin_wavecyclic.cpp.

643 {
645  PKSEVENT_ENTRY EventEntry;
647 
648  // acquire event lock
650 
651  // point to first entry
653 
654  while(Entry != &m_EventList)
655  {
656  // get event entry
657  EventEntry = (PKSEVENT_ENTRY)CONTAINING_RECORD(Entry, KSEVENT_ENTRY, ListEntry);
658 
659  // get event entry context
660  Context = (PLOOPEDSTREAMING_EVENT_CONTEXT)(EventEntry + 1);
661 
662  if (Context->bLoopedStreaming != FALSE)
663  {
664  if (NewOffset > OldOffset)
665  {
666  /* buffer progress no overlap */
667  if (OldOffset < Context->Position && Context->Position <= NewOffset)
668  {
669  /* when someone eventually fixes sprintf... */
670  DPRINT("Generating event at OldOffset %I64u\n", OldOffset);
671  DPRINT("Context->Position %I64u\n", Context->Position);
672  DPRINT("NewOffset %I64u\n", NewOffset);
673  /* generate event */
674  KsGenerateEvent(EventEntry);
675  }
676  }
677  else
678  {
679  /* buffer wrap-arround */
680  if (OldOffset < Context->Position || NewOffset > Context->Position)
681  {
682  /* when someone eventually fixes sprintf... */
683  DPRINT("Generating event at OldOffset %I64u\n", OldOffset);
684  DPRINT("Context->Position %I64u\n", Context->Position);
685  DPRINT("NewOffset %I64u\n", NewOffset);
686  /* generate event */
687  KsGenerateEvent(EventEntry);
688  }
689  }
690  }
691 
692  // move to next entry
693  Entry = Entry->Flink;
694  }
695 
696  // release lock
698 }
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:2101
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:1024
struct _KSEVENT_ENTRY * PKSEVENT_ENTRY
Definition: ks.h:2101
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  if (P)
31  return P;
32  }
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define P(row, col)
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_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 199 of file pin_wavecyclic.cpp.

202 {
203  DPRINT("IServiceSink_fnQueryInterface entered\n");
204 
205  if (IsEqualGUIDAligned(refiid, IID_IIrpTarget) ||
207  {
208  *Output = PVOID(PUNKNOWN((IIrpTarget*)this));
209  PUNKNOWN(*Output)->AddRef();
210  return STATUS_SUCCESS;
211  }
212 
213  if (IsEqualGUIDAligned(refiid, IID_IServiceSink))
214  {
215  *Output = PVOID(PUNKNOWN(PSERVICESINK(this)));
216  PUNKNOWN(*Output)->AddRef();
217  return STATUS_SUCCESS;
218  }
219 
220  return STATUS_UNSUCCESSFUL;
221 }
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:2966

◆ STDMETHODIMP_() [1/2]

CPortPinWaveCyclic::STDMETHODIMP_ ( ULONG  )
inline

Definition at line 36 of file pin_wavecyclic.cpp.

37  {
39  return m_Ref;
40  }
#define InterlockedIncrement
Definition: armddk.h:53

◆ STDMETHODIMP_() [2/2]

CPortPinWaveCyclic::STDMETHODIMP_ ( ULONG  )
inline

Definition at line 41 of file pin_wavecyclic.cpp.

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

◆ UpdateCommonBuffer()

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

Definition at line 701 of file pin_wavecyclic.cpp.

704 {
708  ULONG Gap;
709  PUCHAR Buffer;
711 
713  BufferLength = min(BufferLength, MaxTransferCount);
714 
715  while(BufferLength)
716  {
717  Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize);
718  if (!NT_SUCCESS(Status))
719  {
721  if (Gap > BufferLength)
722  {
723  // insert silence samples
724  DPRINT("Inserting Silence Buffer Offset %lu GapLength %lu\n", m_CommonBufferOffset, BufferLength);
726 
728  }
729  break;
730  }
731 
733 
734  if (m_Capture)
735  {
737  }
738  else
739  {
741  }
742 
743  m_IrpQueue->UpdateMapping(BytesToCopy);
745 
748 
750  {
752  {
753  // normalize position
755  }
756  }
757  }
758 }
KSPIN_INTERFACE Interface
Definition: ks.h:2601
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 761 of file pin_wavecyclic.cpp.

764 {
765  ULONG BufferLength, Length, Gap;
768  PUCHAR Buffer;
770 
771 
773  BufferLength = Length = min(BufferLength, MaxTransferCount);
774  while(BufferLength)
775  {
776  Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize);
777  if (!NT_SUCCESS(Status))
778  {
780  if (Gap > BufferLength)
781  {
782  // insert silence samples
783  DPRINT("Overlap Inserting Silence Buffer Size %lu Offset %lu Gap %lu Position %lu\n", m_CommonBufferSize, m_CommonBufferOffset, Gap, Position);
785 
787  }
788  break;
789  }
790 
792 
793  if (m_Capture)
794  {
795  m_DmaChannel->CopyFrom(Buffer,
797  BytesToCopy);
798  }
799  else
800  {
802  Buffer,
803  BytesToCopy);
804  }
805 
806  m_IrpQueue->UpdateMapping(BytesToCopy);
809 
811 
813  {
815  {
816  // normalize position
818  }
819  }
820  }
821 
822  if (Gap == Length)
823  {
825 
826  MaxTransferCount -= Length;
827 
828  if (MaxTransferCount)
829  {
830  UpdateCommonBuffer(Position, MaxTransferCount);
831  }
832  }
833 }
KSPIN_INTERFACE Interface
Definition: ks.h:2601
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 410 of file pin_wavecyclic.cpp.

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

◆ PinWaveCyclicAddEndOfStreamEvent

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

Definition at line 238 of file pin_wavecyclic.cpp.

242 {
246 
247  // get sub device descriptor
248  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
249 
250  // sanity check
252  PC_ASSERT(Descriptor->PortPin);
254 
255  // cast to pin impl
256  Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
257 
258  // get extra size
259  Entry = (PENDOFSTREAM_EVENT_CONTEXT)(EventEntry + 1);
260 
261  // not a looped event
262  Entry->bLoopedStreaming = FALSE;
263 
264  // insert item
265  (void)ExInterlockedInsertTailList(&Pin->m_EventList, &EventEntry->ListEntry, &Pin->m_EventListLock);
266 
267  // done
268  return STATUS_SUCCESS;
269 }
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:2966
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 273 of file pin_wavecyclic.cpp.

277 {
282 
283  // get sub device descriptor
284  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSEVENT_ITEM_IRP_STORAGE(Irp);
285 
286  // sanity check
288  PC_ASSERT(Descriptor->PortPin);
290 
291  // cast to pin impl
292  Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
293 
294  // cast to looped event
296 
297  // get extra size
298  Entry = (PLOOPEDSTREAMING_EVENT_CONTEXT)(EventEntry + 1);
299 
300  Entry->bLoopedStreaming = TRUE;
301  Entry->Position = Data->Position;
302 
303  DPRINT1("Added event\n");
304 
305  // insert item
306  (void)ExInterlockedInsertTailList(&Pin->m_EventList, &EventEntry->ListEntry, &Pin->m_EventListLock);
307 
308  // done
309  return STATUS_SUCCESS;
310 }
#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:2966
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 314 of file pin_wavecyclic.cpp.

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

◆ PinWaveCyclicAudioPosition

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

Definition at line 349 of file pin_wavecyclic.cpp.

353 {
357 
358  // get sub device descriptor
359  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
360 
361  // sanity check
363  PC_ASSERT(Descriptor->PortPin);
365 
366  // cast to pin impl
367  Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
368 
369  //sanity check
370  PC_ASSERT(Pin->m_Stream);
371 
372  if (Request->Flags & KSPROPERTY_TYPE_GET)
373  {
374  // FIXME non multithreading-safe
375  // copy audio position
376 
378 
379  if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_STREAMING)
380  {
381  RtlMoveMemory(Data, &Pin->m_Position, sizeof(KSAUDIO_POSITION));
382  DPRINT("Play %lu Record %lu\n", Pin->m_Position.PlayOffset, Pin->m_Position.WriteOffset);
383  }
384  else if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING)
385  {
386  Position->PlayOffset = Pin->m_Position.PlayOffset;
387  Position->WriteOffset = (ULONGLONG)Pin->m_IrpQueue->GetCurrentIrpOffset();
388  DPRINT("Play %lu Write %lu\n", Position->PlayOffset, Position->WriteOffset);
389  }
390 
391  Irp->IoStatus.Information = sizeof(KSAUDIO_POSITION);
392  return STATUS_SUCCESS;
393  }
394 
395  // not supported
396  return STATUS_NOT_SUPPORTED;
397 }
#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:2966
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 525 of file pin_wavecyclic.cpp.

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

◆ PinWaveCyclicState

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

Definition at line 453 of file pin_wavecyclic.cpp.

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

◆ IMP_IServiceSink

CPortPinWaveCyclic::IMP_IServiceSink

Definition at line 53 of file pin_wavecyclic.cpp.

◆ m_AllocatorFraming

KSALLOCATOR_FRAMING CPortPinWaveCyclic::m_AllocatorFraming
protected

Definition at line 94 of file pin_wavecyclic.cpp.

◆ m_Capture

BOOL CPortPinWaveCyclic::m_Capture
protected

Definition at line 89 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_CommonBuffer

PVOID CPortPinWaveCyclic::m_CommonBuffer
protected

Definition at line 82 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_CommonBufferOffset

ULONG CPortPinWaveCyclic::m_CommonBufferOffset
protected

Definition at line 84 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_CommonBufferSize

ULONG CPortPinWaveCyclic::m_CommonBufferSize
protected

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

◆ m_Descriptor

PSUBDEVICE_DESCRIPTOR CPortPinWaveCyclic::m_Descriptor
protected

Definition at line 95 of file pin_wavecyclic.cpp.

◆ m_DmaChannel

PDMACHANNEL CPortPinWaveCyclic::m_DmaChannel
protected

Definition at line 76 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_EventList

LIST_ENTRY CPortPinWaveCyclic::m_EventList
protected

Definition at line 98 of file pin_wavecyclic.cpp.

Referenced by GeneratePositionEvents().

◆ m_EventListLock

KSPIN_LOCK CPortPinWaveCyclic::m_EventListLock
protected

Definition at line 97 of file pin_wavecyclic.cpp.

Referenced by GeneratePositionEvents().

◆ m_Filter

IPortFilterWaveCyclic* CPortPinWaveCyclic::m_Filter
protected

Definition at line 72 of file pin_wavecyclic.cpp.

◆ m_Format

PKSDATAFORMAT CPortPinWaveCyclic::m_Format
protected

Definition at line 79 of file pin_wavecyclic.cpp.

◆ m_FrameSize

ULONG CPortPinWaveCyclic::m_FrameSize
protected

Definition at line 88 of file pin_wavecyclic.cpp.

◆ m_IrpQueue

IIrpQueue* CPortPinWaveCyclic::m_IrpQueue
protected

◆ m_KsPinDescriptor

KSPIN_DESCRIPTOR* CPortPinWaveCyclic::m_KsPinDescriptor
protected

Definition at line 73 of file pin_wavecyclic.cpp.

◆ m_Miniport

PMINIPORTWAVECYCLIC CPortPinWaveCyclic::m_Miniport
protected

Definition at line 74 of file pin_wavecyclic.cpp.

◆ m_Port

IPortWaveCyclic* CPortPinWaveCyclic::m_Port
protected

Definition at line 71 of file pin_wavecyclic.cpp.

◆ m_Position

KSAUDIO_POSITION CPortPinWaveCyclic::m_Position
protected

Definition at line 93 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_Ref

LONG CPortPinWaveCyclic::m_Ref
protected

Definition at line 104 of file pin_wavecyclic.cpp.

Referenced by STDMETHODIMP_().

◆ m_ResetState

KSRESET CPortPinWaveCyclic::m_ResetState
protected

Definition at line 100 of file pin_wavecyclic.cpp.

◆ m_ServiceGroup

PSERVICEGROUP CPortPinWaveCyclic::m_ServiceGroup
protected

Definition at line 75 of file pin_wavecyclic.cpp.

◆ m_State

KSSTATE CPortPinWaveCyclic::m_State
protected

Definition at line 78 of file pin_wavecyclic.cpp.

Referenced by PinSetStateWorkerRoutine().

◆ m_StopCount

ULONG CPortPinWaveCyclic::m_StopCount
protected

Definition at line 92 of file pin_wavecyclic.cpp.

◆ m_Stream

PMINIPORTWAVECYCLICSTREAM CPortPinWaveCyclic::m_Stream
protected

◆ m_TotalPackets

ULONG CPortPinWaveCyclic::m_TotalPackets
protected

Definition at line 91 of file pin_wavecyclic.cpp.


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