#include "private.hpp"
-class CPortPinWaveRT : public IPortPinWaveRT,
- public IServiceSink //hack
+class CPortPinWaveRT : public IPortPinWaveRT
{
public:
STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
return m_Ref;
}
IMP_IPortPinWaveRT;
- IMP_IServiceSink; //HACK
CPortPinWaveRT(IUnknown *OuterUnknown){}
virtual ~CPortPinWaveRT(){}
PMINIPORTWAVERT m_Miniport;
PMINIPORTWAVERTSTREAM m_Stream;
PPORTWAVERTSTREAM m_PortStream;
- PSERVICEGROUP m_ServiceGroup;
KSSTATE m_State;
PKSDATAFORMAT m_Format;
KSPIN_CONNECT * m_ConnectDetails;
NTSTATUS NTAPI HandleKsProperty(IN PIRP Irp);
NTSTATUS NTAPI HandleKsStream(IN PIRP Irp);
VOID NTAPI SetStreamState(IN KSSTATE State);
- VOID UpdateCommonBuffer(ULONG Position);
- VOID UpdateCommonBufferOverlap(ULONG Position);
friend VOID NTAPI SetStreamWorkerRoutine(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context);
friend VOID NTAPI CloseStreamRoutine(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context);
}SETSTREAM_CONTEXT, *PSETSTREAM_CONTEXT;
-VOID
-CPortPinWaveRT::UpdateCommonBuffer(
- ULONG Position)
-{
- ULONG BufferLength;
- ULONG BytesToCopy;
- ULONG BufferSize;
- PUCHAR Buffer;
- NTSTATUS Status;
-
- BufferLength = Position - m_CommonBufferOffset;
- while(BufferLength)
- {
- Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize);
- if (!NT_SUCCESS(Status))
- return;
-
- BytesToCopy = min(BufferLength, BufferSize);
-
- if (m_Capture)
- {
- RtlMoveMemory(Buffer, (PUCHAR)m_CommonBuffer + m_CommonBufferOffset, BytesToCopy);
- }
- else
- {
- RtlMoveMemory((PUCHAR)m_CommonBuffer + m_CommonBufferOffset, Buffer, BytesToCopy);
- }
-
- m_IrpQueue->UpdateMapping(BytesToCopy);
- m_CommonBufferOffset += BytesToCopy;
-
- BufferLength = Position - m_CommonBufferOffset;
- }
-}
-
-VOID
-CPortPinWaveRT::UpdateCommonBufferOverlap(
- ULONG Position)
-{
- ULONG BufferLength;
- ULONG BytesToCopy;
- ULONG BufferSize;
- PUCHAR Buffer;
- NTSTATUS Status;
-
-
- BufferLength = m_CommonBufferSize - m_CommonBufferOffset;
- while(BufferLength)
- {
- Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize);
- if (!NT_SUCCESS(Status))
- return;
-
- BytesToCopy = min(BufferLength, BufferSize);
-
- if (m_Capture)
- {
- RtlMoveMemory(Buffer, (PUCHAR)m_CommonBuffer + m_CommonBufferOffset, BytesToCopy);
- }
- else
- {
- RtlMoveMemory((PUCHAR)m_CommonBuffer + m_CommonBufferOffset, Buffer, BytesToCopy);
- }
-
- m_IrpQueue->UpdateMapping(BytesToCopy);
- m_CommonBufferOffset += BytesToCopy;
-
- BufferLength = m_CommonBufferSize - m_CommonBufferOffset;
- }
- m_CommonBufferOffset = 0;
- UpdateCommonBuffer(Position);
-}
-
-
-
//==================================================================================================================================
NTSTATUS
NTAPI
{
DPRINT("IServiceSink_fnQueryInterface entered\n");
- if (IsEqualGUIDAligned(refiid, IID_IServiceSink))
- {
- *Output = PVOID(PSERVICEGROUP(this));
- PUNKNOWN(*Output)->AddRef();
- return STATUS_SUCCESS;
- }
-
if (IsEqualGUIDAligned(refiid, IID_IIrpTarget) ||
IsEqualGUIDAligned(refiid, IID_IUnknown))
{
return STATUS_UNSUCCESSFUL;
}
-VOID
-NTAPI
-CPortPinWaveRT::RequestService()
-{
- KSAUDIO_POSITION Position;
- NTSTATUS Status;
- PUCHAR Buffer;
- ULONG BufferSize;
-
- PC_ASSERT_IRQL(DISPATCH_LEVEL);
-
- Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize);
- if (!NT_SUCCESS(Status))
- {
- SetStreamState(KSSTATE_STOP);
- return;
- }
-
- Status = m_Stream->GetPosition(&Position);
- DPRINT("PlayOffset %lu WriteOffset %lu Buffer %p BufferSize %u CommonBufferSize %u\n", Position.PlayOffset, Position.WriteOffset, Buffer, BufferSize, m_CommonBufferSize);
-
- if (Position.PlayOffset < m_CommonBufferOffset)
- {
- UpdateCommonBufferOverlap(Position.PlayOffset);
- }
- else if (Position.PlayOffset >= m_CommonBufferOffset)
- {
- UpdateCommonBuffer(Position.PlayOffset);
- }
-}
-
VOID
NTAPI
SetStreamWorkerRoutine(
{
// reset start stream
This->m_IrpQueue->CancelBuffers(); //FIX function name
- This->m_ServiceGroup->CancelDelayedService();
DPRINT1("Stopping PreCompleted %u PostCompleted %u\n", This->m_PreCompleted, This->m_PostCompleted);
}
if (This->m_State == KSSTATE_RUN)
{
// start the notification timer
- This->m_ServiceGroup->RequestDelayedService(This->m_Delay);
}
}
}
{
NTSTATUS Status;
PKSDATAFORMAT DataFormat;
- BOOL Capture;
+ BOOLEAN Capture;
KSRTAUDIO_HWLATENCY Latency;
Port->AddRef();
goto cleanup;
}
- Status = PcNewServiceGroup(&m_ServiceGroup, NULL);
- if (!NT_SUCCESS(Status))
- {
- goto cleanup;
- }
-
- m_ServiceGroup->AddMember(PSERVICESINK(this));
- m_ServiceGroup->SupportDelayedService();
-
if (KsPinDescriptor->Communication == KSPIN_COMMUNICATION_SINK && KsPinDescriptor->DataFlow == KSPIN_DATAFLOW_IN)
{
Capture = FALSE;