ReactOS 0.4.16-dev-197-g92996da
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 14 of file pin_wavecyclic.cpp.

Constructor & Destructor Documentation

◆ CPortPinWaveCyclic()

CPortPinWaveCyclic::CPortPinWaveCyclic ( IUnknown OuterUnknown)
inline

Definition at line 31 of file pin_wavecyclic.cpp.

31 :
32 m_Port(nullptr),
33 m_Filter(nullptr),
34 m_KsPinDescriptor(nullptr),
35 m_Miniport(nullptr),
36 m_ServiceGroup(nullptr),
37 m_DmaChannel(nullptr),
38 m_Stream(nullptr),
40 m_Format(nullptr),
41 m_ConnectDetails(nullptr),
42 m_CommonBuffer(nullptr),
45 m_IrpQueue(nullptr),
46 m_FrameSize(0),
49 m_StopCount(0),
50 m_Position({0}),
51 m_AllocatorFraming({{0}}),
52 m_Descriptor(nullptr),
54 m_EventList({nullptr}),
56 m_Delay(0)
57 {
58 }
KSPIN_LOCK m_EventListLock
PMINIPORTWAVECYCLICSTREAM m_Stream
PSUBDEVICE_DESCRIPTOR m_Descriptor
PSERVICEGROUP m_ServiceGroup
PKSDATAFORMAT m_Format
IPortWaveCyclic * m_Port
PDMACHANNEL m_DmaChannel
PKSPIN_CONNECT m_ConnectDetails
PMINIPORTWAVECYCLIC m_Miniport
IIrpQueue * m_IrpQueue
KSPIN_DESCRIPTOR * m_KsPinDescriptor
KSAUDIO_POSITION m_Position
KSALLOCATOR_FRAMING m_AllocatorFraming
IPortFilterWaveCyclic * m_Filter
#define FALSE
Definition: types.h:117
@ KSRESET_BEGIN
Definition: ks.h:1227
@ KSSTATE_STOP
Definition: ks.h:1215

◆ ~CPortPinWaveCyclic()

virtual CPortPinWaveCyclic::~CPortPinWaveCyclic ( )
inlinevirtual

Definition at line 59 of file pin_wavecyclic.cpp.

59{}

Member Function Documentation

◆ GeneratePositionEvents()

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

Definition at line 631 of file pin_wavecyclic.cpp.

634{
636 PKSEVENT_ENTRY EventEntry;
638
639 // acquire event lock
641
642 // point to first entry
644
645 while(Entry != &m_EventList)
646 {
647 // get event entry
648 EventEntry = (PKSEVENT_ENTRY)CONTAINING_RECORD(Entry, KSEVENT_ENTRY, ListEntry);
649
650 // get event entry context
651 Context = (PLOOPEDSTREAMING_EVENT_CONTEXT)(EventEntry + 1);
652
653 if (Context->bLoopedStreaming != FALSE)
654 {
655 if (NewOffset > OldOffset)
656 {
657 /* buffer progress no overlap */
658 if (OldOffset < Context->Position && Context->Position <= NewOffset)
659 {
660 /* when someone eventually fixes sprintf... */
661 DPRINT("Generating event at OldOffset %I64u\n", OldOffset);
662 DPRINT("Context->Position %I64u\n", Context->Position);
663 DPRINT("NewOffset %I64u\n", NewOffset);
664 /* generate event */
665 KsGenerateEvent(EventEntry);
666 }
667 }
668 else
669 {
670 /* buffer wrap-arround */
671 if (OldOffset < Context->Position || NewOffset > Context->Position)
672 {
673 /* when someone eventually fixes sprintf... */
674 DPRINT("Generating event at OldOffset %I64u\n", OldOffset);
675 DPRINT("Context->Position %I64u\n", Context->Position);
676 DPRINT("NewOffset %I64u\n", NewOffset);
677 /* generate event */
678 KsGenerateEvent(EventEntry);
679 }
680 }
681 }
682
683 // move to next entry
684 Entry = Entry->Flink;
685 }
686
687 // release lock
689}
KSDDKAPI NTSTATUS NTAPI KsGenerateEvent(IN PKSEVENT_ENTRY EntryEvent)
Definition: event.c:608
struct _KSEVENT_ENTRY * PKSEVENT_ENTRY
Definition: ks.h:2101
struct _KSEVENT_ENTRY KSEVENT_ENTRY
Definition: ks.h:2101
struct LOOPEDSTREAMING_EVENT_CONTEXT * PLOOPEDSTREAMING_EVENT_CONTEXT
#define KeAcquireSpinLockAtDpcLevel(SpinLock)
Definition: ke.h:125
#define KeReleaseSpinLockFromDpcLevel(SpinLock)
Definition: ke.h:135
#define DPRINT
Definition: sndvol32.h:73
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
static COORD Position
Definition: mouse.c:34
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

◆ operator new()

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

Definition at line 19 of file pin_wavecyclic.cpp.

23 {
25 }
#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:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

◆ QueryInterface()

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

Definition at line 195 of file pin_wavecyclic.cpp.

198{
199 DPRINT("IServiceSink_fnQueryInterface entered\n");
200
201 if (IsEqualGUIDAligned(refiid, IID_IIrpTarget) ||
203 {
204 *Output = PVOID(PUNKNOWN((IIrpTarget*)this));
205 PUNKNOWN(*Output)->AddRef();
206 return STATUS_SUCCESS;
207 }
208
209 if (IsEqualGUIDAligned(refiid, IID_IServiceSink))
210 {
212 PUNKNOWN(*Output)->AddRef();
213 return STATUS_SUCCESS;
214 }
215
216 return STATUS_UNSUCCESSFUL;
217}
const GUID IID_IUnknown
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
ULONG AddRef()
IServiceSink * PSERVICESINK
Definition: portcls.h:569
@ Output
Definition: arc.h:85
#define STATUS_SUCCESS
Definition: shellext.h:65
void * PVOID
Definition: typedefs.h:50
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235

◆ UpdateCommonBuffer()

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

Definition at line 692 of file pin_wavecyclic.cpp.

695{
699 ULONG Gap;
702
704 BufferLength = min(BufferLength, MaxTransferCount);
705
706 while(BufferLength)
707 {
708 Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize);
709 if (!NT_SUCCESS(Status))
710 {
712 if (Gap > BufferLength)
713 {
714 // insert silence samples
715 DPRINT("Inserting Silence Buffer Offset %lu GapLength %lu\n", m_CommonBufferOffset, BufferLength);
717
719 }
720 break;
721 }
722
724
725 if (m_Capture)
726 {
728 }
729 else
730 {
732 }
733
734 m_IrpQueue->UpdateMapping(BytesToCopy);
736
739
741 {
743 {
744 // normalize position
746 }
747 }
748 }
749}
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define BufferSize
Definition: mmc.h:75
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
@ KSINTERFACE_STANDARD_LOOPED_STREAMING
Definition: ks.h:284
#define min(a, b)
Definition: monoChain.cc:55
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3168
DWORDLONG WriteOffset
Definition: ksmedia.h:1251
DWORDLONG PlayOffset
Definition: ksmedia.h:1250
ULONG Id
Definition: dmksctrl.h:77
KSPIN_INTERFACE Interface
Definition: ks.h:2601
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by UpdateCommonBufferOverlap().

◆ UpdateCommonBufferOverlap()

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

Definition at line 752 of file pin_wavecyclic.cpp.

755{
761
763 BufferLength = Length = min(BufferLength, MaxTransferCount);
764 while(BufferLength)
765 {
766 Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize);
767 if (!NT_SUCCESS(Status))
768 {
770 if (Gap > BufferLength)
771 {
772 // insert silence samples
773 DPRINT("Overlap Inserting Silence Buffer Size %lu Offset %lu Gap %lu Position %lu\n", m_CommonBufferSize, m_CommonBufferOffset, Gap, Position);
775
777 }
778 break;
779 }
780
782
783 if (m_Capture)
784 {
785 m_DmaChannel->CopyFrom(Buffer,
788 }
789 else
790 {
792 Buffer,
794 }
795
796 m_IrpQueue->UpdateMapping(BytesToCopy);
799
801
803 {
805 {
806 // normalize position
808 }
809 }
810 }
811
812 if (Gap == Length)
813 {
815
816 MaxTransferCount -= Length;
817
818 if (MaxTransferCount)
819 {
820 UpdateCommonBuffer(Position, MaxTransferCount);
821 }
822 }
823}
VOID UpdateCommonBuffer(ULONG Position, ULONG MaxTransferCount)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102

Friends And Related Function Documentation

◆ PinSetStateWorkerRoutine

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

Definition at line 404 of file pin_wavecyclic.cpp.

407{
408 PSETPIN_CONTEXT PinWorkContext = (PSETPIN_CONTEXT)Context;
410
411 // try set stream
412 Status = PinWorkContext->Pin->m_Stream->SetState(PinWorkContext->NewState);
413
414 DPRINT1("Setting state %u %x\n", PinWorkContext->NewState, Status);
415 if (NT_SUCCESS(Status))
416 {
417 // store new state
418 PinWorkContext->Pin->m_State = PinWorkContext->NewState;
419
420 if (PinWorkContext->Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING && PinWorkContext->Pin->m_State == KSSTATE_STOP)
421 {
422 /* FIXME complete pending irps with successful state */
423 PinWorkContext->Pin->m_IrpQueue->CancelBuffers();
424 }
425 //HACK
426 //PinWorkContext->Pin->m_IrpQueue->CancelBuffers();
427 }
428
429 // store result
430 PinWorkContext->Irp->IoStatus.Information = sizeof(KSSTATE);
431 PinWorkContext->Irp->IoStatus.Status = Status;
432
433 // complete irp
434 IoCompleteRequest(PinWorkContext->Irp, IO_NO_INCREMENT);
435
436 // free work item
437 IoFreeWorkItem(PinWorkContext->WorkItem);
438
439 // free work context
440 FreeItem(PinWorkContext, TAG_PORTCLASS);
441
442}
#define DPRINT1
Definition: precomp.h:8
VOID NTAPI IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
Definition: iowork.c:64
KSSTATE
Definition: ks.h:1214
VOID FreeItem(IN PVOID Item)
Definition: misc.c:37
#define IoCompleteRequest
Definition: irp.c:1240
struct SETPIN_CONTEXT * PSETPIN_CONTEXT
#define TAG_PORTCLASS
Definition: private.hpp:24
CPortPinWaveCyclic * Pin
PIO_WORKITEM WorkItem
IO_STATUS_BLOCK IoStatus
#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 233 of file pin_wavecyclic.cpp.

237{
241
242 // get sub device descriptor
243 Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
244
245 // sanity check
247 PC_ASSERT(Descriptor->PortPin);
249
250 // cast to pin impl
251 Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
252
253 // get extra size
254 Entry = (PENDOFSTREAM_EVENT_CONTEXT)(EventEntry + 1);
255
256 // not a looped event
257 Entry->bLoopedStreaming = FALSE;
258
259 // insert item
260 (void)ExInterlockedInsertTailList(&Pin->m_EventList, &EventEntry->ListEntry, &Pin->m_EventListLock);
261
262 // done
263 return STATUS_SUCCESS;
264}
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
_In_ PIRP Irp
Definition: csq.h:116
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:428
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
#define PC_ASSERT_IRQL(x)
Definition: private.hpp:30
#define PC_ASSERT(exp)
Definition: private.hpp:26
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342

◆ PinWaveCyclicAddLoopedStreamEvent

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

Definition at line 268 of file pin_wavecyclic.cpp.

272{
277
278 // get sub device descriptor
279 Descriptor = (PSUBDEVICE_DESCRIPTOR)KSEVENT_ITEM_IRP_STORAGE(Irp);
280
281 // sanity check
283 PC_ASSERT(Descriptor->PortPin);
285
286 // cast to pin impl
287 Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
288
289 // cast to looped event
291
292 // get extra size
293 Entry = (PLOOPEDSTREAMING_EVENT_CONTEXT)(EventEntry + 1);
294
295 Entry->bLoopedStreaming = TRUE;
296 Entry->Position = Data->Position;
297
298 DPRINT1("Added event\n");
299
300 // insert item
301 (void)ExInterlockedInsertTailList(&Pin->m_EventList, &EventEntry->ListEntry, &Pin->m_EventListLock);
302
303 // done
304 return STATUS_SUCCESS;
305}
#define TRUE
Definition: types.h:120

◆ PinWaveCyclicAllocatorFraming

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

Definition at line 309 of file pin_wavecyclic.cpp.

313{
316
317 // get sub device descriptor
318 Descriptor = (PSUBDEVICE_DESCRIPTOR)KSEVENT_ITEM_IRP_STORAGE(Irp);
319
320 // sanity check
322 PC_ASSERT(Descriptor->PortPin);
324
325 // cast to pin impl
326 Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
327
329 {
330 // copy pin framing
331 RtlMoveMemory(Data, &Pin->m_AllocatorFraming, sizeof(KSALLOCATOR_FRAMING));
332
333 Irp->IoStatus.Information = sizeof(KSALLOCATOR_FRAMING);
334 return STATUS_SUCCESS;
335 }
336
337 // not supported
339}
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
if(dx< 0)
Definition: linetemp.h:194
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547

◆ PinWaveCyclicAudioPosition

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

Definition at line 343 of file pin_wavecyclic.cpp.

347{
351
352 // get sub device descriptor
353 Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
354
355 // sanity check
357 PC_ASSERT(Descriptor->PortPin);
359
360 // cast to pin impl
361 Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
362
363 //sanity check
364 PC_ASSERT(Pin->m_Stream);
365
366 if (Request->Flags & KSPROPERTY_TYPE_GET)
367 {
368 // FIXME non multithreading-safe
369 // copy audio position
370
372
373 if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_STREAMING)
374 {
375 RtlMoveMemory(Data, &Pin->m_Position, sizeof(KSAUDIO_POSITION));
376 DPRINT("Play %lu Record %lu\n", Pin->m_Position.PlayOffset, Pin->m_Position.WriteOffset);
377 }
378 else if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING)
379 {
380 Position->PlayOffset = Pin->m_Position.PlayOffset;
381 Position->WriteOffset = (ULONGLONG)Pin->m_IrpQueue->GetCurrentIrpOffset();
382 DPRINT("Play %lu Write %lu\n", Position->PlayOffset, Position->WriteOffset);
383 }
384
385 Irp->IoStatus.Information = sizeof(KSAUDIO_POSITION);
386 return STATUS_SUCCESS;
387 }
388
389 // not supported
391}
@ KSINTERFACE_STANDARD_STREAMING
Definition: ks.h:283
struct KSAUDIO_POSITION * PKSAUDIO_POSITION
uint64_t ULONGLONG
Definition: typedefs.h:67

◆ PinWaveCyclicDataFormat

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

Definition at line 518 of file pin_wavecyclic.cpp.

522{
526 PIO_STACK_LOCATION IoStack;
527
528 // get current irp stack location
530
531 // get sub device descriptor
532 Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
533
534 // sanity check
536 PC_ASSERT(Descriptor->PortPin);
537
538 // cast to pin impl
539 Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
540
541 //sanity check
542 PC_ASSERT(Pin->m_Stream);
543 PC_ASSERT(Pin->m_Format);
544
545 if (Request->Flags & KSPROPERTY_TYPE_SET)
546 {
547 // try to change data format
548 PKSDATAFORMAT NewDataFormat, DataFormat = (PKSDATAFORMAT)Irp->UserBuffer;
549 ULONG Size = min(Pin->m_Format->FormatSize, DataFormat->FormatSize);
550
551 if (RtlCompareMemory(DataFormat, Pin->m_Format, Size) == Size)
552 {
553 // format is identical
554 Irp->IoStatus.Information = DataFormat->FormatSize;
555 return STATUS_SUCCESS;
556 }
557
558 // new change request
559 PC_ASSERT(Pin->m_State != KSSTATE_RUN);
560 // FIXME queue a work item when Irql != PASSIVE_LEVEL
562
563 // allocate new data format
564 NewDataFormat = (PKSDATAFORMAT)AllocateItem(NonPagedPool, DataFormat->FormatSize, TAG_PORTCLASS);
565 if (!NewDataFormat)
566 {
567 // not enough memory
568 return STATUS_NO_MEMORY;
569 }
570
571 // copy new data format
572 RtlMoveMemory(NewDataFormat, DataFormat, DataFormat->FormatSize);
573
574 // set new format
575 Status = Pin->m_Stream->SetFormat(NewDataFormat);
576 if (NT_SUCCESS(Status))
577 {
578 // free old format
579 FreeItem(Pin->m_Format, TAG_PORTCLASS);
580
581 // store new format
582 Pin->m_Format = NewDataFormat;
583 Irp->IoStatus.Information = NewDataFormat->FormatSize;
584
585#if 0
586 PC_ASSERT(NewDataFormat->FormatSize == sizeof(KSDATAFORMAT_WAVEFORMATEX));
590
591 DPRINT("NewDataFormat: Channels %u Bits %u Samples %u\n", ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.nChannels,
592 ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.wBitsPerSample,
593 ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.nSamplesPerSec);
594#endif
595
596 }
597 else
598 {
599 // failed to set format
600 FreeItem(NewDataFormat, TAG_PORTCLASS);
601 }
602
603 // done
604 return Status;
605 }
606 else if (Request->Flags & KSPROPERTY_TYPE_GET)
607 {
608 // get current data format
609 PC_ASSERT(Pin->m_Format);
610
611 if (Pin->m_Format->FormatSize > IoStack->Parameters.DeviceIoControl.OutputBufferLength)
612 {
613 // buffer too small
614 Irp->IoStatus.Information = Pin->m_Format->FormatSize;
615 return STATUS_MORE_ENTRIES;
616 }
617 // copy data format
618 RtlMoveMemory(Data, Pin->m_Format, Pin->m_Format->FormatSize);
619 // store result size
620 Irp->IoStatus.Information = Pin->m_Format->FormatSize;
621
622 // done
623 return STATUS_SUCCESS;
624 }
625
626 // unsupported request
628}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
KSDATAFORMAT * PKSDATAFORMAT
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define NonPagedPool
Definition: env_spec_w32.h:307
@ KSSTATE_RUN
Definition: ks.h:1218
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:29
#define KSDATAFORMAT_SUBTYPE_PCM
Definition: ksmedia.h:1021
#define KSDATAFORMAT_TYPE_AUDIO
Definition: ksmedia.h:983
#define KSDATAFORMAT_SPECIFIER_WAVEFORMATEX
Definition: ksmedia.h:1031
struct _IO_STACK_LOCATION::@1575::@1576 DeviceIoControl
union _IO_STACK_LOCATION::@1575 Parameters
#define STATUS_MORE_ENTRIES
Definition: udferr_usr.h:124

◆ PinWaveCyclicState

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

Definition at line 446 of file pin_wavecyclic.cpp.

450{
455
456 // get sub device descriptor
457 Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
458
459 // sanity check
461 PC_ASSERT(Descriptor->PortPin);
463
464 // cast to pin impl
465 Pin = (CPortPinWaveCyclic*)Descriptor->PortPin;
466
467 //sanity check
468 PC_ASSERT(Pin->m_Stream);
469
470 if (Request->Flags & KSPROPERTY_TYPE_SET)
471 {
472 // try set stream
473 Status = Pin->m_Stream->SetState(*State);
474
475 DPRINT("Setting state %u %x\n", *State, Status);
476 if (NT_SUCCESS(Status))
477 {
478 // store new state
479 Pin->m_State = *State;
480
481 if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING && Pin->m_State == KSSTATE_STOP)
482 {
483 // FIXME
484 // complete with successful state
485 Pin->m_Stream->Silence(Pin->m_CommonBuffer, Pin->m_CommonBufferSize);
486 Pin->m_IrpQueue->CancelBuffers();
487 Pin->m_Position.PlayOffset = 0;
488 Pin->m_Position.WriteOffset = 0;
489 }
490 else if (Pin->m_State == KSSTATE_STOP)
491 {
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 // store result
498 Irp->IoStatus.Information = sizeof(KSSTATE);
499 }
500 return Status;
501 }
502 else if (Request->Flags & KSPROPERTY_TYPE_GET)
503 {
504 // get current stream state
505 *State = Pin->m_State;
506 // store result
507 Irp->IoStatus.Information = sizeof(KSSTATE);
508
509 return STATUS_SUCCESS;
510 }
511
512 // unsupported request
514}
enum KSSTATE * PKSSTATE

Member Data Documentation

◆ IMP_IPortPinWaveCyclic

CPortPinWaveCyclic::IMP_IPortPinWaveCyclic

Definition at line 29 of file pin_wavecyclic.cpp.

◆ IMP_IServiceSink

CPortPinWaveCyclic::IMP_IServiceSink

Definition at line 30 of file pin_wavecyclic.cpp.

◆ m_AllocatorFraming

KSALLOCATOR_FRAMING CPortPinWaveCyclic::m_AllocatorFraming
protected

Definition at line 98 of file pin_wavecyclic.cpp.

◆ m_Capture

BOOL CPortPinWaveCyclic::m_Capture
protected

Definition at line 93 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_CommonBuffer

PVOID CPortPinWaveCyclic::m_CommonBuffer
protected

Definition at line 86 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_CommonBufferOffset

ULONG CPortPinWaveCyclic::m_CommonBufferOffset
protected

Definition at line 88 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_CommonBufferSize

ULONG CPortPinWaveCyclic::m_CommonBufferSize
protected

Definition at line 87 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBufferOverlap().

◆ m_ConnectDetails

PKSPIN_CONNECT CPortPinWaveCyclic::m_ConnectDetails
protected

Definition at line 84 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_Delay

ULONG CPortPinWaveCyclic::m_Delay
protected

Definition at line 106 of file pin_wavecyclic.cpp.

◆ m_Descriptor

PSUBDEVICE_DESCRIPTOR CPortPinWaveCyclic::m_Descriptor
protected

Definition at line 99 of file pin_wavecyclic.cpp.

◆ m_DmaChannel

PDMACHANNEL CPortPinWaveCyclic::m_DmaChannel
protected

Definition at line 80 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_EventList

LIST_ENTRY CPortPinWaveCyclic::m_EventList
protected

Definition at line 102 of file pin_wavecyclic.cpp.

Referenced by GeneratePositionEvents().

◆ m_EventListLock

KSPIN_LOCK CPortPinWaveCyclic::m_EventListLock
protected

Definition at line 101 of file pin_wavecyclic.cpp.

Referenced by GeneratePositionEvents().

◆ m_Filter

IPortFilterWaveCyclic* CPortPinWaveCyclic::m_Filter
protected

Definition at line 76 of file pin_wavecyclic.cpp.

◆ m_Format

PKSDATAFORMAT CPortPinWaveCyclic::m_Format
protected

Definition at line 83 of file pin_wavecyclic.cpp.

◆ m_FrameSize

ULONG CPortPinWaveCyclic::m_FrameSize
protected

Definition at line 92 of file pin_wavecyclic.cpp.

◆ m_IrpQueue

IIrpQueue* CPortPinWaveCyclic::m_IrpQueue
protected

Definition at line 90 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_KsPinDescriptor

KSPIN_DESCRIPTOR* CPortPinWaveCyclic::m_KsPinDescriptor
protected

Definition at line 77 of file pin_wavecyclic.cpp.

◆ m_Miniport

PMINIPORTWAVECYCLIC CPortPinWaveCyclic::m_Miniport
protected

Definition at line 78 of file pin_wavecyclic.cpp.

◆ m_Port

IPortWaveCyclic* CPortPinWaveCyclic::m_Port
protected

Definition at line 75 of file pin_wavecyclic.cpp.

◆ m_Position

KSAUDIO_POSITION CPortPinWaveCyclic::m_Position
protected

Definition at line 97 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_ResetState

KSRESET CPortPinWaveCyclic::m_ResetState
protected

Definition at line 104 of file pin_wavecyclic.cpp.

◆ m_ServiceGroup

PSERVICEGROUP CPortPinWaveCyclic::m_ServiceGroup
protected

Definition at line 79 of file pin_wavecyclic.cpp.

◆ m_State

KSSTATE CPortPinWaveCyclic::m_State
protected

Definition at line 82 of file pin_wavecyclic.cpp.

◆ m_StopCount

ULONG CPortPinWaveCyclic::m_StopCount
protected

Definition at line 96 of file pin_wavecyclic.cpp.

◆ m_Stream

PMINIPORTWAVECYCLICSTREAM CPortPinWaveCyclic::m_Stream
protected

Definition at line 81 of file pin_wavecyclic.cpp.

Referenced by UpdateCommonBuffer(), and UpdateCommonBufferOverlap().

◆ m_TotalPackets

ULONG CPortPinWaveCyclic::m_TotalPackets
protected

Definition at line 95 of file pin_wavecyclic.cpp.


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