mirror of
https://github.com/reactos/reactos.git
synced 2025-04-30 02:58:48 +00:00
- Rewrite writing to common buffer to fix stuttering sound
svn path=/trunk/; revision=39902
This commit is contained in:
parent
0da1e6e5e9
commit
4dd44cb8cd
1 changed files with 69 additions and 48 deletions
|
@ -92,6 +92,73 @@ IServiceSink_fnRelease(
|
|||
return This->ref;
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
UpdateCommonBuffer(
|
||||
IPortPinWaveCyclicImpl * This,
|
||||
ULONG Position)
|
||||
{
|
||||
ULONG BufferLength;
|
||||
ULONG BytesToCopy;
|
||||
ULONG BufferSize;
|
||||
PUCHAR Buffer;
|
||||
NTSTATUS Status;
|
||||
|
||||
BufferLength = Position - This->CommonBufferOffset;
|
||||
while(BufferLength)
|
||||
{
|
||||
Status = This->IrpQueue->lpVtbl->GetMapping(This->IrpQueue, &Buffer, &BufferSize);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return;
|
||||
|
||||
BytesToCopy = min(BufferLength, BufferSize);
|
||||
This->DmaChannel->lpVtbl->CopyTo(This->DmaChannel,
|
||||
(PUCHAR)This->CommonBuffer + This->CommonBufferOffset,
|
||||
Buffer,
|
||||
BytesToCopy);
|
||||
|
||||
This->IrpQueue->lpVtbl->UpdateMapping(This->IrpQueue, BytesToCopy);
|
||||
This->CommonBufferOffset += BytesToCopy;
|
||||
|
||||
BufferLength = Position - This->CommonBufferOffset;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
UpdateCommonBufferOverlap(
|
||||
IPortPinWaveCyclicImpl * This,
|
||||
ULONG Position)
|
||||
{
|
||||
ULONG BufferLength;
|
||||
ULONG BytesToCopy;
|
||||
ULONG BufferSize;
|
||||
PUCHAR Buffer;
|
||||
NTSTATUS Status;
|
||||
|
||||
BufferLength = This->CommonBufferSize - This->CommonBufferOffset;
|
||||
while(BufferLength)
|
||||
{
|
||||
Status = This->IrpQueue->lpVtbl->GetMapping(This->IrpQueue, &Buffer, &BufferSize);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return;
|
||||
|
||||
BytesToCopy = min(BufferLength, BufferSize);
|
||||
This->DmaChannel->lpVtbl->CopyTo(This->DmaChannel,
|
||||
(PUCHAR)This->CommonBuffer + This->CommonBufferOffset,
|
||||
Buffer,
|
||||
BytesToCopy);
|
||||
|
||||
This->IrpQueue->lpVtbl->UpdateMapping(This->IrpQueue, BytesToCopy);
|
||||
This->CommonBufferOffset += BytesToCopy;
|
||||
|
||||
BufferLength = This->CommonBufferSize - This->CommonBufferOffset;
|
||||
}
|
||||
This->CommonBufferOffset = 0;
|
||||
UpdateCommonBuffer(This, Position);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
VOID
|
||||
NTAPI
|
||||
|
@ -99,7 +166,6 @@ IServiceSink_fnRequestService(
|
|||
IServiceSink* iface)
|
||||
{
|
||||
ULONG Position;
|
||||
ULONG BufferLength, BytesToCopy;
|
||||
NTSTATUS Status;
|
||||
PUCHAR Buffer;
|
||||
ULONG BufferSize;
|
||||
|
@ -134,57 +200,12 @@ IServiceSink_fnRequestService(
|
|||
|
||||
if (Position < This->CommonBufferOffset)
|
||||
{
|
||||
BufferLength = This->CommonBufferSize - This->CommonBufferOffset;
|
||||
|
||||
BytesToCopy = min(BufferLength, BufferSize);
|
||||
|
||||
DPRINT("Copying %u\n", BytesToCopy);
|
||||
|
||||
if (BytesToCopy)
|
||||
{
|
||||
This->DmaChannel->lpVtbl->CopyTo(This->DmaChannel, (PUCHAR)This->CommonBuffer + This->CommonBufferOffset, Buffer, BytesToCopy);
|
||||
This->IrpQueue->lpVtbl->UpdateMapping(This->IrpQueue, BytesToCopy);
|
||||
This->CommonBufferOffset = 0;
|
||||
}
|
||||
|
||||
|
||||
Status = This->IrpQueue->lpVtbl->GetMapping(This->IrpQueue, &Buffer, &BufferSize);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("IServiceSink_fnRequestService> Waiting for mapping\n");
|
||||
This->ServiceGroup->lpVtbl->RequestDelayedService(This->ServiceGroup, -10000000L);
|
||||
This->RetryCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
BytesToCopy = min(Position, BufferSize);
|
||||
|
||||
DPRINT("Copying %u\n", BytesToCopy);
|
||||
|
||||
if (BytesToCopy)
|
||||
{
|
||||
This->DmaChannel->lpVtbl->CopyTo(This->DmaChannel, (PUCHAR)(PUCHAR)This->CommonBuffer, Buffer, BytesToCopy);
|
||||
This->IrpQueue->lpVtbl->UpdateMapping(This->IrpQueue, BytesToCopy);
|
||||
This->CommonBufferOffset = Position;
|
||||
}
|
||||
|
||||
UpdateCommonBufferOverlap(This, Position);
|
||||
}
|
||||
else if (Position >= This->CommonBufferOffset)
|
||||
{
|
||||
BufferLength = Position - This->CommonBufferOffset;
|
||||
|
||||
BytesToCopy = min(BufferLength, BufferSize);
|
||||
DPRINT("Copying %u\n", BytesToCopy);
|
||||
|
||||
This->DmaChannel->lpVtbl->CopyTo(This->DmaChannel,
|
||||
(PUCHAR)This->CommonBuffer + This->CommonBufferOffset,
|
||||
Buffer,
|
||||
BytesToCopy);
|
||||
|
||||
This->IrpQueue->lpVtbl->UpdateMapping(This->IrpQueue, BytesToCopy);
|
||||
This->CommonBufferOffset = Position;
|
||||
UpdateCommonBuffer(This, Position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static IServiceSinkVtbl vt_IServiceSink =
|
||||
|
|
Loading…
Reference in a new issue