mirror of
https://github.com/reactos/reactos.git
synced 2025-07-23 01:23:45 +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;
|
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
|
static
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
|
@ -99,7 +166,6 @@ IServiceSink_fnRequestService(
|
||||||
IServiceSink* iface)
|
IServiceSink* iface)
|
||||||
{
|
{
|
||||||
ULONG Position;
|
ULONG Position;
|
||||||
ULONG BufferLength, BytesToCopy;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PUCHAR Buffer;
|
PUCHAR Buffer;
|
||||||
ULONG BufferSize;
|
ULONG BufferSize;
|
||||||
|
@ -134,57 +200,12 @@ IServiceSink_fnRequestService(
|
||||||
|
|
||||||
if (Position < This->CommonBufferOffset)
|
if (Position < This->CommonBufferOffset)
|
||||||
{
|
{
|
||||||
BufferLength = This->CommonBufferSize - This->CommonBufferOffset;
|
UpdateCommonBufferOverlap(This, Position);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (Position >= This->CommonBufferOffset)
|
else if (Position >= This->CommonBufferOffset)
|
||||||
{
|
{
|
||||||
BufferLength = Position - This->CommonBufferOffset;
|
UpdateCommonBuffer(This, Position);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static IServiceSinkVtbl vt_IServiceSink =
|
static IServiceSinkVtbl vt_IServiceSink =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue