Author: janderwald
Date: Sat Oct 23 20:20:18 2010
New Revision: 49244
URL:
http://svn.reactos.org/svn/reactos?rev=49244&view=rev
Log:
[PORTCLS]
- Fix multiple bugs in round buffer implementation
- Should result in less audio glitches, especially when playing audio files with low
sample rates. Please report any regressions!
Modified:
trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp
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 23 20:20:18 2010
@@ -686,6 +686,7 @@
ULONG BufferLength;
ULONG BytesToCopy;
ULONG BufferSize;
+ ULONG Gap;
PUCHAR Buffer;
NTSTATUS Status;
@@ -696,7 +697,18 @@
{
Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize);
if (!NT_SUCCESS(Status))
- return;
+ {
+ Gap = Position - m_CommonBufferOffset;
+ if (Gap > m_FrameSize)
+ {
+ // insert silence samples
+ DPRINT1("Inserting Silence Buffer Offset %lu GapLength %lu\n",
m_CommonBufferOffset, BufferLength);
+ m_Stream->Silence((PUCHAR)m_CommonBuffer + m_CommonBufferOffset,
BufferLength);
+
+ m_CommonBufferOffset += BufferLength;
+ break;
+ }
+ }
BytesToCopy = min(BufferLength, BufferSize);
@@ -712,7 +724,7 @@
m_IrpQueue->UpdateMapping(BytesToCopy);
m_CommonBufferOffset += BytesToCopy;
- BufferLength = Position - m_CommonBufferOffset;
+ BufferLength -= BytesToCopy;
m_Position.PlayOffset += BytesToCopy;
if (m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING)
@@ -744,7 +756,18 @@
{
Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize);
if (!NT_SUCCESS(Status))
- return;
+ {
+ Gap = m_CommonBufferSize - m_CommonBufferOffset + Position;
+ if (Gap > m_FrameSize)
+ {
+ // insert silence samples
+ DPRINT1("Overlap Inserting Silence Buffer Size %lu Offset %lu Gap
%lu Position %lu\n", m_CommonBufferSize, m_CommonBufferOffset, Gap, Position);
+ m_Stream->Silence((PUCHAR)m_CommonBuffer + m_CommonBufferOffset,
BufferLength);
+
+ m_CommonBufferOffset += BufferLength;
+ }
+ break;
+ }
BytesToCopy = min(BufferLength, BufferSize);
@@ -765,7 +788,7 @@
m_CommonBufferOffset += BytesToCopy;
m_Position.PlayOffset += BytesToCopy;
- BufferLength = m_CommonBufferSize - m_CommonBufferOffset;
+ BufferLength -=BytesToCopy;
if (m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING)
{
@@ -1192,7 +1215,6 @@
#endif
DPRINT1("CPortPinWaveCyclic::Init Status %x PinId %u Capture %u\n", Status,
ConnectDetails->PinId, Capture);
- DPRINT1("Bits %u Samples %u Channels %u Tag %u FrameSize %u\n",
((PKSDATAFORMAT_WAVEFORMATEX)(DataFormat))->WaveFormatEx.wBitsPerSample,
((PKSDATAFORMAT_WAVEFORMATEX)(DataFormat))->WaveFormatEx.nSamplesPerSec,
((PKSDATAFORMAT_WAVEFORMATEX)(DataFormat))->WaveFormatEx.nChannels,
((PKSDATAFORMAT_WAVEFORMATEX)(DataFormat))->WaveFormatEx.wFormatTag, m_FrameSize);
if (!NT_SUCCESS(Status))
return Status;
@@ -1268,6 +1290,7 @@
PC_ASSERT(NT_SUCCESS(Status));
PC_ASSERT(m_FrameSize);
+ DPRINT1("Bits %u Samples %u Channels %u Tag %u FrameSize %u CommonBufferSize
%lu\n", ((PKSDATAFORMAT_WAVEFORMATEX)(DataFormat))->WaveFormatEx.wBitsPerSample,
((PKSDATAFORMAT_WAVEFORMATEX)(DataFormat))->WaveFormatEx.nSamplesPerSec,
((PKSDATAFORMAT_WAVEFORMATEX)(DataFormat))->WaveFormatEx.nChannels,
((PKSDATAFORMAT_WAVEFORMATEX)(DataFormat))->WaveFormatEx.wFormatTag, m_FrameSize,
m_CommonBufferSize);
/* set up allocator framing */