Jinoh Kang (@iamahuman) commented about dlls/windows.media.speech/recognizer.c:
{
IAudioClient_Stop(impl->audio_client);
TRACE("session worker paused.\n");
}
else if (old_paused > paused)
{
IAudioClient_Start(impl->audio_client);
TRACE("session worker resumed.\n");
}
}
else if (status == 1) /* audio_buf_event signaled */
{
UINT32 frames_available = 0, tmp_buf_offset = 0;
while (IAudioCaptureClient_GetBuffer(impl->capture_client, &audio_buf, &frames_available, &flags, NULL, NULL) == S_OK
&& tmp_buf_offset < tmp_buf_size)
A call to `GetBuffer` must always be paired with `ReleaseBuffer`. If `tmp_buf_offset < tmp_buf_size` is false, the loop will terminate and the corresponding `ReleaseBuffer` will never be called.
```suggestion:-1+0 while (tmp_buf_offset < tmp_buf_size && IAudioCaptureClient_GetBuffer(impl->capture_client, &audio_buf, &frames_available, &flags, NULL, NULL) == S_OK) ```
From [Microsoft documentation][ReleaseBuffer]:
Between each [GetBuffer] call and its corresponding <b>ReleaseBuffer</b> call, the client must either read the entire data packet or none of it. If the client reads the entire packet following the <b>GetBuffer</b> call, then it should call <b>ReleaseBuffer</b> with <i>NumFramesRead</i> set to the total number of frames in the data packet. In this case, the next call to <b>GetBuffer</b> will produce a new data packet. If the client reads none of the data from the packet following the call to <b>GetBuffer</b>, then it should call <b>ReleaseBuffer</b> with <i>NumFramesRead</i> set to 0. In this case, the next <b>GetBuffer</b> call will produce the same data packet as in the previous <b>GetBuffer</b> call.
[ReleaseBuffer]: https://learn.microsoft.com/en-us/windows/win32/api/audioclient/nf-audioclie... [GetBuffer]: https://learn.microsoft.com/en-us/windows/desktop/api/audioclient/nf-audiocl...