hidclass.sys: When processing reads fill all the buffers.
Signed-off-by: Aric Stewart <aric@codeweavers.com> Signed-off-by: Sebastian Lackner <sebastian@fds-team.de> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
65089c395d
commit
68ecd3b76a
|
@ -127,7 +127,7 @@ NTSTATUS RingBuffer_SetSize(struct ReportRingBuffer *ring, UINT size)
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void RingBuffer_Read(struct ReportRingBuffer *ring, UINT index, void *output, UINT *size)
|
||||
void RingBuffer_ReadNew(struct ReportRingBuffer *ring, UINT index, void *output, UINT *size)
|
||||
{
|
||||
void *ret = NULL;
|
||||
|
||||
|
@ -155,6 +155,40 @@ void RingBuffer_Read(struct ReportRingBuffer *ring, UINT index, void *output, UI
|
|||
}
|
||||
}
|
||||
|
||||
void RingBuffer_Read(struct ReportRingBuffer *ring, UINT index, void *output, UINT *size)
|
||||
{
|
||||
int pointer;
|
||||
void *ret = NULL;
|
||||
|
||||
EnterCriticalSection(&ring->lock);
|
||||
if (index >= ring->pointer_alloc || ring->pointers[index] == POINTER_UNUSED
|
||||
|| ring->end == ring->start)
|
||||
{
|
||||
LeaveCriticalSection(&ring->lock);
|
||||
*size = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
pointer = ring->pointers[index];
|
||||
|
||||
if (pointer == ring->end)
|
||||
pointer--;
|
||||
|
||||
if (pointer < 0)
|
||||
pointer = ring->size - 1;
|
||||
|
||||
ret = &ring->buffer[pointer * ring->buffer_size];
|
||||
memcpy(output, ret, ring->buffer_size);
|
||||
if (pointer == ring->pointers[index])
|
||||
{
|
||||
ring->pointers[index]++;
|
||||
if (ring->pointers[index] == ring->size)
|
||||
ring->pointers[index] = 0;
|
||||
}
|
||||
LeaveCriticalSection(&ring->lock);
|
||||
*size = ring->buffer_size;
|
||||
}
|
||||
|
||||
UINT RingBuffer_AddPointer(struct ReportRingBuffer *ring)
|
||||
{
|
||||
UINT idx;
|
||||
|
|
|
@ -663,7 +663,7 @@ NTSTATUS WINAPI HID_Device_read(DEVICE_OBJECT *device, IRP *irp)
|
|||
ptr = PtrToUlong( irp->Tail.Overlay.OriginalFileObject->FsContext );
|
||||
|
||||
irp->IoStatus.Information = 0;
|
||||
RingBuffer_Read(ext->ring_buffer, ptr, packet, &buffer_size);
|
||||
RingBuffer_ReadNew(ext->ring_buffer, ptr, packet, &buffer_size);
|
||||
|
||||
if (buffer_size)
|
||||
{
|
||||
|
|
|
@ -62,7 +62,8 @@ typedef struct _BASE_DEVICE_EXTENSION {
|
|||
void RingBuffer_Write(struct ReportRingBuffer *buffer, void *data) DECLSPEC_HIDDEN;
|
||||
UINT RingBuffer_AddPointer(struct ReportRingBuffer *buffer) DECLSPEC_HIDDEN;
|
||||
void RingBuffer_RemovePointer(struct ReportRingBuffer *ring, UINT index) DECLSPEC_HIDDEN;
|
||||
void RingBuffer_Read(struct ReportRingBuffer *buffer, UINT index, void *output, UINT *size) DECLSPEC_HIDDEN;
|
||||
void RingBuffer_Read(struct ReportRingBuffer *ring, UINT index, void *output, UINT *size) DECLSPEC_HIDDEN;
|
||||
void RingBuffer_ReadNew(struct ReportRingBuffer *buffer, UINT index, void *output, UINT *size) DECLSPEC_HIDDEN;
|
||||
UINT RingBuffer_GetBufferSize(struct ReportRingBuffer *buffer) DECLSPEC_HIDDEN;
|
||||
UINT RingBuffer_GetSize(struct ReportRingBuffer *buffer) DECLSPEC_HIDDEN;
|
||||
void RingBuffer_Destroy(struct ReportRingBuffer *buffer) DECLSPEC_HIDDEN;
|
||||
|
|
Loading…
Reference in New Issue