Jinoh Kang (@iamahuman) commented about dlls/windows.media.speech/recognizer.c:
TRACE("session worker resumed.\n");
}
}
else if (status == 1) /* audio_buf_event signaled */
{
while (IAudioCaptureClient_GetBuffer(impl->capture_client, &audio_buf, &frames_available, &flags, NULL, NULL) == S_OK && tmp_buf_offset < (frame_count * 2))
{
memcpy(tmp_buf + tmp_buf_offset, audio_buf, frames_available * 2);
tmp_buf_offset += (frames_available * 2); /* multiplied with 2 because our audio frames have 16bit depth. */
IAudioCaptureClient_ReleaseBuffer(impl->capture_client, frames_available);
}
/* TODO: Send mic data to recognizer and handle results. */
tmp_buf_offset = 0;
Why not move this before the `while` loop, to make clear that `tmp_buf_offset` is `0` at the start of the loop? Alternatively, you can declare `tmp_buf_offset` inside the `else if`.