From: Bernhard Kölbl besentv@gmail.com
Signed-off-by: Bernhard Kölbl besentv@gmail.com --- dlls/windows.media.speech/recognizer.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/dlls/windows.media.speech/recognizer.c b/dlls/windows.media.speech/recognizer.c index 98f999d1276..5112bca7d1c 100644 --- a/dlls/windows.media.speech/recognizer.c +++ b/dlls/windows.media.speech/recognizer.c @@ -190,15 +190,17 @@ static DWORD CALLBACK session_worker_thread_cb( void *args ) { ISpeechContinuousRecognitionSession *iface = args; struct session *impl = impl_from_ISpeechContinuousRecognitionSession(iface); - UINT32 frame_count, frames_available; + UINT32 frame_count, frames_available, tmp_buf_offset = 0; BOOLEAN running = TRUE, paused = FALSE; + BYTE *audio_buf, *tmp_buf; DWORD flags, status; HANDLE events[2]; - BYTE *audio_buf;
IAudioClient_Start(impl->audio_client); IAudioClient_GetBufferSize(impl->audio_client, &frame_count);
+ tmp_buf = malloc(sizeof(*tmp_buf) * frame_count * 2); /* multiplied with 2 because our audio frames have 16bit depth. */ + while (running) { BOOLEAN old_paused = paused; @@ -228,11 +230,17 @@ static DWORD CALLBACK session_worker_thread_cb( void *args ) } else if (status == 1) /* audio_buf_event signaled */ { - while (IAudioCaptureClient_GetBuffer(impl->capture_client, &audio_buf, &frames_available, &flags, NULL, NULL) == S_OK) + while (IAudioCaptureClient_GetBuffer(impl->capture_client, &audio_buf, &frames_available, &flags, NULL, NULL) == S_OK && tmp_buf_offset < (frame_count * 2)) { - /* TODO: Send mic data to recognizer and handle results. */ + 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; } else { @@ -242,6 +250,7 @@ static DWORD CALLBACK session_worker_thread_cb( void *args ) }
IAudioClient_Stop(impl->audio_client); + free(tmp_buf);
return 0; }