Author: janderwald
Date: Sat Oct 31 09:26:26 2009
New Revision: 43868
URL:
http://svn.reactos.org/svn/reactos?rev=43868&view=rev
Log:
- Implement looped streaming (needed for dsound bringup)
- Implement GetPosition handler for looped streaming, WIP
Modified:
trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp
trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp
trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp
trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp
trunk/reactos/drivers/wdm/audio/backpln/portcls/undoc.cpp
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp [iso-8859-1]
(original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp [iso-8859-1] Sat Oct 31
09:26:26 2009
@@ -322,9 +322,8 @@
IN PVOID SilenceBuffer) PURE;
STDMETHOD_(NTSTATUS, AddMapping)(THIS_
- IN PUCHAR Buffer,
- IN ULONG BufferSize,
- IN PIRP Irp) PURE;
+ IN PIRP Irp,
+ OUT PULONG Data) PURE;
STDMETHOD_(NTSTATUS, GetMapping)(THIS_
OUT PUCHAR * Buffer,
@@ -372,9 +371,8 @@
IN PVOID SilenceBuffer); \
\
STDMETHODIMP_(NTSTATUS) AddMapping(THIS_ \
- IN PUCHAR Buffer, \
- IN ULONG BufferSize, \
- IN PIRP Irp); \
+ IN PIRP Irp, \
+ OUT PULONG Data); \
\
STDMETHODIMP_(NTSTATUS) GetMapping(THIS_ \
OUT PUCHAR * Buffer, \
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp [iso-8859-1] Sat Oct 31
09:26:26 2009
@@ -39,7 +39,7 @@
LONG m_NumMappings;
ULONG m_NumDataAvailable;
BOOL m_StartStream;
- KSPIN_CONNECT * m_ConnectDetails;
+ PKSPIN_CONNECT m_ConnectDetails;
PKSDATAFORMAT_WAVEFORMATEX m_DataFormat;
KSPIN_LOCK m_IrpListLock;
@@ -110,9 +110,8 @@
NTSTATUS
NTAPI
CIrpQueue::AddMapping(
- IN PUCHAR Buffer,
- IN ULONG BufferSize,
- IN PIRP Irp)
+ IN PIRP Irp,
+ OUT PULONG Data)
{
PKSSTREAM_HEADER Header;
NTSTATUS Status = STATUS_SUCCESS;
@@ -124,8 +123,6 @@
// get current irp stack location
IoStack = IoGetCurrentIrpStackLocation(Irp);
-
- PC_ASSERT(!Buffer);
if (!Irp->MdlAddress)
{
@@ -172,8 +169,8 @@
NumData = 0;
// prepare all headers
- for(Index = 0; Index < NumHeaders; Index++)
- {
+ for(Index = 0; Index < NumHeaders; Index++)
+ {
// sanity checks
PC_ASSERT(Header);
PC_ASSERT(Mdl);
@@ -181,17 +178,17 @@
Header->Data = MmGetSystemAddressForMdlSafe(Mdl, NormalPagePriority);
if (!Header->Data)
- {
+ {
// insufficient resources
ExFreePool(Irp->AssociatedIrp.SystemBuffer);
Irp->AssociatedIrp.SystemBuffer = NULL;
- // complete and forget request
+ // complete and forget request
Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_INSUFFICIENT_RESOURCES;
- }
+ }
// increment num mappings
InterlockedIncrement(&m_NumMappings);
@@ -207,10 +204,10 @@
// move to next mdl
Mdl = Mdl->Next;
- }
+ }
DPRINT("StreamHeaders %u NumData %u FrameSize %u NumDataAvailable %u\n",
NumHeaders, NumData, m_MaxFrameSize, m_NumDataAvailable);
-
+ *Data = NumData;
// mark irp as pending
IoMarkIrpPending(Irp);
@@ -330,7 +327,7 @@
if (m_CurrentOffset >= Size)
{
if (STREAMHEADER_INDEX(m_Irp) + 1 < STREAMHEADER_COUNT(m_Irp))
- {
+ {
// the irp has at least one more stream header
m_Irp->Tail.Overlay.DriverContext[OFFSET_HEADERINDEX] =
UlongToPtr(STREAMHEADER_INDEX(m_Irp) + 1);
@@ -345,7 +342,7 @@
// done
return;
- }
+ }
// irp has been processed completly
@@ -354,7 +351,7 @@
// loop all stream headers
for(Index = 0; Index < STREAMHEADER_COUNT(m_Irp); Index++)
- {
+ {
PC_ASSERT(StreamHeader);
// add size of buffer
@@ -369,19 +366,29 @@
// get next stream header
StreamHeader = (PKSSTREAM_HEADER)((ULONG_PTR)StreamHeader +
StreamHeader->Size);
- }
+ }
+
+ if (m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING)
+ {
+ // looped streaming repeat the buffers untill
+ // the caller decides to stop the streams
+
+ // reset stream header index
+ m_Irp->Tail.Overlay.DriverContext[OFFSET_HEADERINDEX] = UlongToPtr(0);
+ // re-insert irp
+ KsAddIrpToCancelableQueue(&m_IrpList, &m_IrpListLock, m_Irp,
KsListEntryTail, NULL);
+ // clear current irp
+ m_Irp = NULL;
+ // reset offset
+ m_CurrentOffset = 0;
+ // increment available data
+ InterlockedExchangeAdd((PLONG)&m_NumDataAvailable, NumData);
+ // done
+ return;
+ }
m_Irp->IoStatus.Status = STATUS_SUCCESS;
m_Irp->IoStatus.Information = NumData;
-
-#if 0
- PC_ASSERT_IRQL(DISPATCH_LEVEL);
- MmUnlockPages(m_Irp->MdlAddress);
- IoFreeMdl(m_Irp->MdlAddress);
- m_Irp->MdlAddress = NULL;
- ExFreePool(m_Irp->AssociatedIrp.SystemBuffer);
- m_Irp->AssociatedIrp.SystemBuffer = NULL;
-#endif
// complete the request
IoCompleteRequest(m_Irp, IO_SOUND_INCREMENT);
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp [iso-8859-1]
(original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp [iso-8859-1] Sat
Oct 31 09:26:26 2009
@@ -59,7 +59,7 @@
PMINIPORTWAVECYCLICSTREAM m_Stream;
KSSTATE m_State;
PKSDATAFORMAT m_Format;
- KSPIN_CONNECT * m_ConnectDetails;
+ PKSPIN_CONNECT m_ConnectDetails;
PVOID m_CommonBuffer;
ULONG m_CommonBufferSize;
@@ -187,6 +187,7 @@
{
CPortPinWaveCyclic *Pin;
PSUBDEVICE_DESCRIPTOR Descriptor;
+ PKSAUDIO_POSITION Position;
// get sub device descriptor
Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
@@ -206,9 +207,21 @@
{
// FIXME non multithreading-safe
// copy audio position
- RtlMoveMemory(Data, &Pin->m_Position, sizeof(KSAUDIO_POSITION));
-
- DPRINT("Play %lu Record %lu\n", Pin->m_Position.PlayOffset,
Pin->m_Position.WriteOffset);
+
+ Position = (PKSAUDIO_POSITION)Data;
+
+ if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_STREAMING)
+ {
+ RtlMoveMemory(Data, &Pin->m_Position, sizeof(KSAUDIO_POSITION));
+ DPRINT("Play %lu Record %lu\n", Pin->m_Position.PlayOffset,
Pin->m_Position.WriteOffset);
+ }
+ else if (Pin->m_ConnectDetails->Interface.Id ==
KSINTERFACE_STANDARD_LOOPED_STREAMING)
+ {
+ Position->PlayOffset = Pin->m_Position.PlayOffset %
Pin->m_Position.WriteOffset;
+ Position->WriteOffset = Pin->m_IrpQueue->NumData();
+ }
+
+
Irp->IoStatus.Information = sizeof(KSAUDIO_POSITION);
return STATUS_SUCCESS;
}
@@ -584,25 +597,21 @@
IN PIRP Irp)
{
NTSTATUS Status;
+ ULONG Data = 0;
InterlockedIncrement((PLONG)&m_TotalPackets);
DPRINT("IPortPinWaveCyclic_HandleKsStream entered Total %u State %x MinData
%u\n", m_TotalPackets, m_State, m_IrpQueue->NumData());
- Status = m_IrpQueue->AddMapping(NULL, 0, Irp);
+ Status = m_IrpQueue->AddMapping(Irp, &Data);
if (NT_SUCCESS(Status))
{
-
- PKSSTREAM_HEADER Header = (PKSSTREAM_HEADER)Irp->AssociatedIrp.SystemBuffer;
- PC_ASSERT(Header);
-
if (m_Capture)
- m_Position.WriteOffset += Header->FrameExtent;
+ m_Position.WriteOffset += Data;
else
- m_Position.WriteOffset += Header->DataUsed;
+ m_Position.WriteOffset += Data;
return STATUS_PENDING;
-
}
return Status;
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp [iso-8859-1]
(original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp [iso-8859-1] Sat Oct
31 09:26:26 2009
@@ -665,22 +665,19 @@
IN PIRP Irp)
{
NTSTATUS Status;
+ ULONG Data = 0;
InterlockedIncrement((PLONG)&m_TotalPackets);
DPRINT("IPortPinWaveCyclic_HandleKsStream entered Total %u State %x MinData
%u\n", m_TotalPackets, m_State, m_IrpQueue->NumData());
- Status = m_IrpQueue->AddMapping(NULL, 0, Irp);
+ Status = m_IrpQueue->AddMapping(Irp, &Data);
if (NT_SUCCESS(Status))
{
-
- PKSSTREAM_HEADER Header = (PKSSTREAM_HEADER)Irp->AssociatedIrp.SystemBuffer;
- PC_ASSERT(Header);
-
if (m_Capture)
- m_Position.WriteOffset += Header->FrameExtent;
+ m_Position.WriteOffset += Data;
else
- m_Position.WriteOffset += Header->DataUsed;
+ m_Position.WriteOffset += Data;
return STATUS_PENDING;
}
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/undoc.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/undoc.cpp [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/undoc.cpp [iso-8859-1] Sat Oct 31
09:26:26 2009
@@ -7,6 +7,22 @@
*/
#include "private.hpp"
+
+
+KSPIN_INTERFACE PinInterfaces[] =
+{
+ {
+ {STATIC_KSINTERFACESETID_Standard},
+ KSINTERFACE_STANDARD_STREAMING,
+ 0
+ },
+ {
+ {STATIC_KSINTERFACESETID_Standard},
+ KSINTERFACE_STANDARD_LOOPED_STREAMING,
+ 0
+ }
+};
+
NTSTATUS
NTAPI
@@ -450,6 +466,9 @@
{
RtlMoveMemory(&Descriptor->Factory.KsPinDescriptor[Index],
&SrcDescriptor->KsPinDescriptor, sizeof(KSPIN_DESCRIPTOR));
+ Descriptor->Factory.KsPinDescriptor[Index].Interfaces = PinInterfaces;
+ Descriptor->Factory.KsPinDescriptor[Index].InterfacesCount =
sizeof(PinInterfaces) / sizeof(KSPIN_INTERFACE);
+
DPRINT("Index %u DataRangeCount %u\n", Index,
SrcDescriptor->KsPinDescriptor.DataRangesCount);
Descriptor->Factory.Instances[Index].CurrentPinInstanceCount = 0;