[PORTCLS]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Sat, 23 Oct 2010 18:42:59 +0000 (18:42 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Sat, 23 Oct 2010 18:42:59 +0000 (18:42 +0000)
- Remove silence buffer hack
- Stub DRM Property Handler
- Before stopping the audio pin, fill the dma buffer with silence samples
- create a subdevice descriptor for instantiated pins too

svn path=/trunk/; revision=49242

reactos/drivers/wdm/audio/backpln/portcls/guids.cpp
reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp
reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp
reactos/drivers/wdm/audio/backpln/portcls/pin_dmus.cpp
reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp
reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp
reactos/drivers/wdm/audio/backpln/portcls/pin_wavert.cpp
reactos/drivers/wdm/audio/backpln/portcls/private.hpp

index 457868d..34fed48 100644 (file)
@@ -79,6 +79,7 @@ const GUID KSPROPSETID_Topology                = {0x720D4AC0L, 0x7533, 0x11D0, {
 const GUID KSPROPSETID_Pin                     = {0x8C134960L, 0x51AD, 0x11CF, {0x87, 0x8A, 0x94, 0xF8, 0x01, 0xC1, 0x00, 0x00}};
 const GUID KSPROPSETID_Connection              = {0x1D58C920L, 0xAC9B, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
 const GUID KSPROPTYPESETID_General             = {0x97E99BA0L, 0xBDEA, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
+const GUID KSPROPSETID_DrmAudioStream          = {0x2f2c8ddd,  0x4198, 0x4fac, {0xba, 0x29, 0x61, 0xbb, 0x05, 0xb7, 0xde, 0x06}};
 
 const GUID KSEVENTSETID_LoopedStreaming        = {0x4682B940L, 0xC6EF, 0x11D0, {0x96, 0xD8, 0x00, 0xAA, 0x00, 0x51, 0xE5, 0x1D}};
 const GUID KSEVENTSETID_Connection             = {0x7f4bcbe0L, 0x9ea5, 0x11cf, {0xa5, 0xd6, 0x28, 0xdb, 0x04, 0xc1, 0x00, 0x00}};
index 6caebb9..248bcbe 100644 (file)
@@ -321,8 +321,7 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown)
     STDMETHOD_(NTSTATUS, Init)(THIS_
         IN KSPIN_CONNECT *ConnectDetails,
         IN ULONG FrameSize,
-        IN ULONG Alignment,
-        IN PVOID SilenceBuffer) PURE;
+        IN ULONG Alignment) PURE;
 
     STDMETHOD_(NTSTATUS, AddMapping)(THIS_
         IN PIRP Irp,
@@ -363,8 +362,7 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown)
     STDMETHODIMP_(NTSTATUS) Init(THIS_                 \
         IN KSPIN_CONNECT *ConnectDetails,              \
         IN ULONG FrameSize,                            \
-        IN ULONG Alignment,                            \
-        IN PVOID SilenceBuffer);                       \
+        IN ULONG Alignment);                           \
                                                        \
     STDMETHODIMP_(NTSTATUS) AddMapping(THIS_           \
         IN PIRP Irp,                                   \
index aa6f392..a19a6da 100644 (file)
@@ -43,7 +43,6 @@ protected:
     LIST_ENTRY m_IrpList;
     LIST_ENTRY m_FreeIrpList;
     PIRP m_Irp;
-    PVOID m_SilenceBuffer;
 
     ULONG m_OutOfMapping;
     ULONG m_MaxFrameSize;
@@ -84,12 +83,10 @@ NTAPI
 CIrpQueue::Init(
     IN KSPIN_CONNECT *ConnectDetails,
     IN ULONG FrameSize,
-    IN ULONG Alignment,
-    IN PVOID SilenceBuffer)
+    IN ULONG Alignment)
 {
     m_ConnectDetails = ConnectDetails;
     m_MaxFrameSize = FrameSize;
-    m_SilenceBuffer = SilenceBuffer;
     m_Alignment = Alignment;
 
     InitializeListHead(&m_IrpList);
@@ -259,22 +256,13 @@ CIrpQueue::GetMapping(
         m_CurrentOffset = Offset = 0;
     }
 
-    if (!Irp && m_SilenceBuffer && m_MaxFrameSize)
-    {
-        DPRINT("NoIrp\n");
-        // no irp available, use silence buffer
-        *Buffer = (PUCHAR)m_SilenceBuffer;
-        *BufferSize = m_MaxFrameSize;
-        return STATUS_SUCCESS;
-    }
-
     if (!Irp)
     {
         // no irp buffer available
+        DPRINT("NoIrp\n");
         return STATUS_UNSUCCESSFUL;
     }
 
-
     // get stream header
     StreamHeader = (PKSSTREAM_HEADER)Irp->Tail.Overlay.DriverContext[2];
 
index 4bcad8c..5a616f3 100644 (file)
@@ -604,7 +604,7 @@ CPortPinDMus::Init(
         }
     }
 
-    Status = m_IrpQueue->Init(ConnectDetails, 0, 0, NULL);
+    Status = m_IrpQueue->Init(ConnectDetails, 0, 0);
     if (!NT_SUCCESS(Status))
     {
         DPRINT("IrpQueue_Init failed with %x\n", Status);
index e615413..b3c0037 100644 (file)
@@ -73,7 +73,7 @@ protected:
     ULONG m_StopCount;
     KSAUDIO_POSITION m_Position;
     KSALLOCATOR_FRAMING m_AllocatorFraming;
-    SUBDEVICE_DESCRIPTOR m_Descriptor;
+    PSUBDEVICE_DESCRIPTOR m_Descriptor;
 
     KSPIN_LOCK m_EventListLock;
     LIST_ENTRY m_EventList;
@@ -105,10 +105,12 @@ NTSTATUS NTAPI PinWaveCyclicAudioPosition(IN PIRP Irp, IN PKSIDENTIFIER Request,
 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);
+NTSTATUS NTAPI PinWaveCyclicDRMHandler(IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data);
 
 
 DEFINE_KSPROPERTY_CONNECTIONSET(PinWaveCyclicConnectionSet, PinWaveCyclicState, PinWaveCyclicDataFormat, PinWaveCyclicAllocatorFraming);
 DEFINE_KSPROPERTY_AUDIOSET(PinWaveCyclicAudioSet, PinWaveCyclicAudioPosition);
+DEFINE_KSPROPERTY_DRMSET(PinWaveCyclicDRMSet, PinWaveCyclicDRMHandler);
 
 KSEVENT_ITEM PinWaveCyclicConnectionEventSet =
 {
@@ -146,6 +148,13 @@ KSPROPERTY_SET PinWaveCyclicPropertySet[] =
         (const KSPROPERTY_ITEM*)&PinWaveCyclicAudioSet,
         0,
         NULL
+    },
+    {
+        &KSPROPSETID_DrmAudioStream,
+        sizeof(PinWaveCyclicDRMSet) / sizeof(KSPROPERTY_ITEM),
+        (const KSPROPERTY_ITEM*)&PinWaveCyclicDRMSet,
+        0,
+        NULL
     }
 };
 
@@ -192,6 +201,19 @@ CPortPinWaveCyclic::QueryInterface(
     return STATUS_UNSUCCESSFUL;
 }
 
+NTSTATUS
+NTAPI
+PinWaveCyclicDRMHandler(
+    IN PIRP Irp,
+    IN PKSIDENTIFIER Request,
+    IN OUT PVOID Data)
+{
+    DPRINT1("PinWaveCyclicDRMHandler\n");
+    ASSERT(0);
+    return STATUS_INVALID_PARAMETER;
+}
+
+
 NTSTATUS
 NTAPI
 PinWaveCyclicAddEndOfStreamEvent(
@@ -448,12 +470,14 @@ PinWaveCyclicState(
             {
                 // FIXME
                 // complete with successful state
+                Pin->m_Stream->Silence(Pin->m_CommonBuffer, Pin->m_CommonBufferSize);
                 Pin->m_IrpQueue->CancelBuffers();
                 Pin->m_Position.PlayOffset = 0;
                 Pin->m_Position.WriteOffset = 0;
             }
             else if (Pin->m_State == KSSTATE_STOP)
             {
+                Pin->m_Stream->Silence(Pin->m_CommonBuffer, Pin->m_CommonBufferSize);
                 Pin->m_IrpQueue->CancelBuffers();
                 Pin->m_Position.PlayOffset = 0;
                 Pin->m_Position.WriteOffset = 0;
@@ -751,7 +775,6 @@ CPortPinWaveCyclic::UpdateCommonBufferOverlap(
                 m_Position.PlayOffset = m_Position.PlayOffset % m_Position.WriteOffset;
             }
         }
-
     }
 
     if (Gap == Length)
@@ -773,22 +796,13 @@ CPortPinWaveCyclic::RequestService()
 {
     ULONG Position;
     NTSTATUS Status;
-    PUCHAR Buffer;
-    ULONG BufferSize;
     ULONGLONG OldOffset, NewOffset;
 
     PC_ASSERT_IRQL(DISPATCH_LEVEL);
 
     if (m_State == KSSTATE_RUN)
     {
-        Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize);
-        if (!NT_SUCCESS(Status))
-        {
-            return;
-        }
-
         Status = m_Stream->GetPosition(&Position);
-        DPRINT("Position %u Buffer %p BufferSize %u ActiveIrpOffset %u Capture %u\n", Position, Buffer, m_CommonBufferSize, BufferSize, m_Capture);
 
         OldOffset = m_Position.PlayOffset;
 
@@ -841,7 +855,7 @@ CPortPinWaveCyclic::DeviceIoControl(
     if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KS_PROPERTY)
     {
         /* handle property with subdevice descriptor */
-        Status = PcHandlePropertyWithTable(Irp,  m_Descriptor.FilterPropertySetCount, m_Descriptor.FilterPropertySet, &m_Descriptor);
+        Status = PcHandlePropertyWithTable(Irp,  m_Descriptor->FilterPropertySetCount, m_Descriptor->FilterPropertySet, m_Descriptor);
 
         if (Status == STATUS_NOT_FOUND)
         {
@@ -854,11 +868,11 @@ CPortPinWaveCyclic::DeviceIoControl(
     }
     else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KS_ENABLE_EVENT)
     {
-        Status = PcHandleEnableEventWithTable(Irp, &m_Descriptor);
+        Status = PcHandleEnableEventWithTable(Irp, m_Descriptor);
     }
     else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KS_DISABLE_EVENT)
     {
-        Status = PcHandleDisableEventWithTable(Irp, &m_Descriptor);
+        Status = PcHandleDisableEventWithTable(Irp, m_Descriptor);
     }
     else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KS_RESET_STATE)
     {
@@ -1120,7 +1134,6 @@ CPortPinWaveCyclic::Init(
     PKSDATAFORMAT DataFormat;
     PDEVICE_OBJECT DeviceObject;
     BOOLEAN Capture;
-    PVOID SilenceBuffer;
     PSUBDEVICE_DESCRIPTOR SubDeviceDescriptor = NULL;
     //IDrmAudioStream * DrmAudio = NULL;
 
@@ -1203,18 +1216,26 @@ CPortPinWaveCyclic::Init(
     InitializeListHead(&m_EventList);
     KeInitializeSpinLock(&m_EventListLock);
 
-    /* set up subdevice descriptor */
-    RtlZeroMemory(&m_Descriptor, sizeof(SUBDEVICE_DESCRIPTOR));
-    m_Descriptor.FilterPropertySet = PinWaveCyclicPropertySet;
-    m_Descriptor.FilterPropertySetCount = sizeof(PinWaveCyclicPropertySet) / sizeof(KSPROPERTY_SET);
-    m_Descriptor.UnknownStream = (PUNKNOWN)m_Stream;
-    m_Descriptor.DeviceDescriptor = SubDeviceDescriptor->DeviceDescriptor;
-    m_Descriptor.UnknownMiniport = SubDeviceDescriptor->UnknownMiniport;
-    m_Descriptor.PortPin = (PVOID)this;
-    m_Descriptor.EventSetCount = sizeof(PinWaveCyclicEventSet) / sizeof(KSEVENT_SET);
-    m_Descriptor.EventSet = PinWaveCyclicEventSet;
-    m_Descriptor.EventList = &m_EventList;
-    m_Descriptor.EventListLock = &m_EventListLock;
+    Status = PcCreateSubdeviceDescriptor(&m_Descriptor,
+                                         SubDeviceDescriptor->InterfaceCount,
+                                         SubDeviceDescriptor->Interfaces,
+                                         0, /* FIXME KSINTERFACE_STANDARD with KSINTERFACE_STANDARD_STREAMING / KSINTERFACE_STANDARD_LOOPED_STREAMING */
+                                         NULL,
+                                         sizeof(PinWaveCyclicPropertySet) / sizeof(KSPROPERTY_SET),
+                                         PinWaveCyclicPropertySet,
+                                         0,
+                                         0,
+                                         0,
+                                         NULL,
+                                         sizeof(PinWaveCyclicEventSet) / sizeof(KSEVENT_SET),
+                                         PinWaveCyclicEventSet,
+                                         SubDeviceDescriptor->DeviceDescriptor);
+
+    m_Descriptor->UnknownStream = (PUNKNOWN)m_Stream;
+    m_Descriptor->UnknownMiniport = SubDeviceDescriptor->UnknownMiniport;
+    m_Descriptor->PortPin = (PVOID)this;
+    m_Descriptor->EventList = &m_EventList;
+    m_Descriptor->EventListLock = &m_EventListLock;
 
     // initialize reset state
     m_ResetState = KSRESET_END;
@@ -1247,9 +1268,6 @@ CPortPinWaveCyclic::Init(
     PC_ASSERT(NT_SUCCESS(Status));
     PC_ASSERT(m_FrameSize);
 
-    SilenceBuffer = AllocateItem(NonPagedPool, m_FrameSize, TAG_PORTCLASS);
-    if (!SilenceBuffer)
-        return STATUS_INSUFFICIENT_RESOURCES;
 
 
     /* set up allocator framing */
@@ -1260,10 +1278,9 @@ CPortPinWaveCyclic::Init(
     m_AllocatorFraming.Reserved = 0;
     m_AllocatorFraming.FrameSize = m_FrameSize;
 
-    m_Stream->Silence(SilenceBuffer, m_FrameSize);
     m_Stream->Silence(m_CommonBuffer, m_CommonBufferSize);
 
-    Status = m_IrpQueue->Init(ConnectDetails, m_FrameSize, 0, SilenceBuffer);
+    Status = m_IrpQueue->Init(ConnectDetails, m_FrameSize, 0);
     if (!NT_SUCCESS(Status))
     {
        m_IrpQueue->Release();
@@ -1282,9 +1299,6 @@ CPortPinWaveCyclic::Init(
     m_Port = Port;
     m_Filter = Filter;
 
-    //DPRINT("Setting state to acquire %x\n", m_Stream->SetState(KSSTATE_ACQUIRE));
-    //DPRINT("Setting state to pause %x\n", m_Stream->SetState(KSSTATE_PAUSE));
-
     return STATUS_SUCCESS;
 }
 
index a2b89a4..9a1cc75 100644 (file)
@@ -919,7 +919,7 @@ CPortPinWavePci::Init(
     }
 
     // initialize irp queue
-    Status = m_IrpQueue->Init(ConnectDetails, m_AllocatorFraming.FrameSize, m_AllocatorFraming.FileAlignment, NULL);
+    Status = m_IrpQueue->Init(ConnectDetails, m_AllocatorFraming.FrameSize, m_AllocatorFraming.FileAlignment);
     if (!NT_SUCCESS(Status))
     {
         // this should never happen
index 7c3d036..fd6be3c 100644 (file)
@@ -587,7 +587,7 @@ CPortPinWaveRT::Init(
         goto cleanup;
     }
 
-    Status = m_IrpQueue->Init(ConnectDetails, 0, 0, NULL);
+    Status = m_IrpQueue->Init(ConnectDetails, 0, 0);
     if (!NT_SUCCESS(Status))
     {
         goto cleanup;
index 17adc4c..e2e600b 100644 (file)
@@ -356,6 +356,22 @@ DEFINE_KSPROPERTY_TABLE(PinSet) {\
     DEFINE_KSPROPERTY_ITEM_AUDIO_POSITION(PropPositionHandler, PropPositionHandler)\
 }
 
+
+#define DEFINE_KSPROPERTY_ITEM_DRMAUDIOSTREAM_CONTENTID(SetHandler)\
+    DEFINE_KSPROPERTY_ITEM(\
+        KSPROPERTY_DRMAUDIOSTREAM_CONTENTID,\
+        NULL,\
+        sizeof(KSPROPERTY),\
+        sizeof(ULONG),\
+        (SetHandler),\
+        NULL, 0, NULL, NULL, 0)
+
+#define DEFINE_KSPROPERTY_DRMSET(PinSet,\
+    PropPositionHandler)\
+DEFINE_KSPROPERTY_TABLE(PinSet) {\
+    DEFINE_KSPROPERTY_ITEM_DRMAUDIOSTREAM_CONTENTID(PropPositionHandler)\
+}
+
 #define DEFINE_KSPROPERTY_PINPROPOSEDATAFORMAT(PinSet,\
     PropGeneral, PropInstances, PropIntersection)\
 DEFINE_KSPROPERTY_TABLE(PinSet) {\