- Fix various bugs such as wrong function definitions, using of uninitialized variables
[reactos.git] / reactos / drivers / wdm / audio / backpln / portcls / pin_wavert.cpp
index 3e6eb97..22ae5a6 100644 (file)
@@ -8,8 +8,7 @@
 
 #include "private.hpp"
 
-class CPortPinWaveRT : public IPortPinWaveRT,
-                       public IServiceSink //hack
+class CPortPinWaveRT : public IPortPinWaveRT
 {
 public:
     STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
@@ -31,7 +30,6 @@ public:
         return m_Ref;
     }
     IMP_IPortPinWaveRT;
-    IMP_IServiceSink; //HACK
     CPortPinWaveRT(IUnknown *OuterUnknown){}
     virtual ~CPortPinWaveRT(){}
 
@@ -43,7 +41,6 @@ protected:
     PMINIPORTWAVERT m_Miniport;
     PMINIPORTWAVERTSTREAM m_Stream;
     PPORTWAVERTSTREAM m_PortStream;
-    PSERVICEGROUP m_ServiceGroup;
     KSSTATE m_State;
     PKSDATAFORMAT m_Format;
     KSPIN_CONNECT * m_ConnectDetails;
@@ -70,8 +67,6 @@ protected:
     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);
 
@@ -86,81 +81,6 @@ typedef struct
 }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
@@ -170,13 +90,6 @@ CPortPinWaveRT::QueryInterface(
 {
     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))
     {
@@ -187,37 +100,6 @@ CPortPinWaveRT::QueryInterface(
     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(
@@ -248,14 +130,12 @@ 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);
         }
     }
 }
@@ -766,7 +646,7 @@ CPortPinWaveRT::Init(
 {
     NTSTATUS Status;
     PKSDATAFORMAT DataFormat;
-    BOOL Capture;
+    BOOLEAN Capture;
     KSRTAUDIO_HWLATENCY Latency;
 
     Port->AddRef();
@@ -806,15 +686,6 @@ CPortPinWaveRT::Init(
         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;