From fe8f67d3da3c2aca256737d9414af1a3f70a15a0 Mon Sep 17 00:00:00 2001 From: David Reid Date: Fri, 1 Mar 2019 17:51:21 +1000 Subject: [PATCH] DirectSound: Capture bug fix. This fixes a bug where the wrong position is being retrieved for the capture device. --- mini_al.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mini_al.h b/mini_al.h index fc431604..18462feb 100644 --- a/mini_al.h +++ b/mini_al.h @@ -9213,7 +9213,7 @@ mal_result mal_device_get_current_frame__dsound(mal_device* pDevice, mal_device_ } *pCurrentPos = (mal_uint32)dwCurrentPosition / mal_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); } else { - if (FAILED(mal_IDirectSoundCaptureBuffer_GetCurrentPosition((mal_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, &dwCurrentPosition, NULL))) { + if (FAILED(mal_IDirectSoundCaptureBuffer_GetCurrentPosition((mal_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, NULL, &dwCurrentPosition))) { return MAL_ERROR; } *pCurrentPos = (mal_uint32)dwCurrentPosition / mal_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); @@ -9439,6 +9439,8 @@ mal_result mal_device_read__dsound(mal_device* pDevice, void* pPCMFrames, mal_ui break; /* Failed to get the current frame. */ } + //printf("TRACE: Capture Position: %d\n", (int)currentPos); + mal_uint32 periodSizeInFrames = pDevice->capture.internalBufferSizeInFrames / pDevice->capture.internalPeriods; if ((currentPos - (pDevice->dsound.iNextPeriodCapture * periodSizeInFrames)) >= periodSizeInFrames) { break; /* There's enough room. */