Variable simplification

This commit is contained in:
libretroadmin 2024-09-10 06:25:00 +02:00
parent 3c23b2d04a
commit c961e79a0c

View File

@ -179,17 +179,15 @@ static ssize_t wasapi_write(void *wh, const void *data, size_t size)
size_t write_avail = FIFO_WRITE_AVAIL(w->buffer); size_t write_avail = FIFO_WRITE_AVAIL(w->buffer);
if (!write_avail) if (!write_avail)
{ {
size_t _size;
UINT32 frame_count; UINT32 frame_count;
BYTE *dest = NULL; BYTE *dest = NULL;
if (WaitForSingleObject(w->write_event, 0) != WAIT_OBJECT_0) if (WaitForSingleObject(w->write_event, 0) != WAIT_OBJECT_0)
return 0; return 0;
_size = w->engine_buffer_size; frame_count = w->engine_buffer_size / w->frame_size;
frame_count = _size / w->frame_size;
if (FAILED(_IAudioRenderClient_GetBuffer( if (FAILED(_IAudioRenderClient_GetBuffer(
w->renderer, frame_count, &dest))) w->renderer, frame_count, &dest)))
return -1; return -1;
fifo_read(w->buffer, dest, _size); fifo_read(w->buffer, dest, w->engine_buffer_size);
if (FAILED(_IAudioRenderClient_ReleaseBuffer( if (FAILED(_IAudioRenderClient_ReleaseBuffer(
w->renderer, frame_count, 0))) w->renderer, frame_count, 0)))
return -1; return -1;
@ -208,19 +206,16 @@ static ssize_t wasapi_write(void *wh, const void *data, size_t size)
size_t write_avail = FIFO_WRITE_AVAIL(w->buffer); size_t write_avail = FIFO_WRITE_AVAIL(w->buffer);
if (!write_avail) if (!write_avail)
{ {
size_t _size;
UINT32 frame_count;
BYTE *dest = NULL; BYTE *dest = NULL;
if (WaitForSingleObject(w->write_event, WASAPI_TIMEOUT) != WAIT_OBJECT_0) if (WaitForSingleObject(w->write_event, WASAPI_TIMEOUT) != WAIT_OBJECT_0)
ir = 1; ir = 1;
else else
{ {
_size = w->engine_buffer_size; UINT32 frame_count = w->engine_buffer_size / w->frame_size;
frame_count = _size / w->frame_size;
if (FAILED(_IAudioRenderClient_GetBuffer( if (FAILED(_IAudioRenderClient_GetBuffer(
w->renderer, frame_count, &dest))) w->renderer, frame_count, &dest)))
return -1; return -1;
fifo_read(w->buffer, dest, _size); fifo_read(w->buffer, dest, w->engine_buffer_size);
if (FAILED(_IAudioRenderClient_ReleaseBuffer( if (FAILED(_IAudioRenderClient_ReleaseBuffer(
w->renderer, frame_count, 0))) w->renderer, frame_count, 0)))
return -1; return -1;