Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
d1d186ee
Commit
d1d186ee
authored
May 18, 2022
by
Bernhard Kölbl
Committed by
Alexandre Julliard
Jan 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windows.media.speech: Store recorded audio in a temporary ringbuffer.
Signed-off-by:
Bernhard Kölbl
<
besentv@gmail.com
>
parent
74129bd8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
3 deletions
+31
-3
recognizer.c
dlls/windows.media.speech/recognizer.c
+31
-3
No files found.
dlls/windows.media.speech/recognizer.c
View file @
d1d186ee
...
...
@@ -192,9 +192,10 @@ static DWORD CALLBACK session_worker_thread_cb( void *args )
ISpeechContinuousRecognitionSession
*
iface
=
args
;
struct
session
*
impl
=
impl_from_ISpeechContinuousRecognitionSession
(
iface
);
BOOLEAN
running
=
TRUE
,
paused
=
FALSE
;
UINT32
frame_count
,
tmp_buf_size
;
BYTE
*
audio_buf
,
*
tmp_buf
;
DWORD
flags
,
status
;
HANDLE
events
[
2
];
BYTE
*
audio_buf
;
HRESULT
hr
;
SetThreadDescription
(
GetCurrentThread
(),
L"wine_speech_recognition_session_worker"
);
...
...
@@ -202,6 +203,16 @@ static DWORD CALLBACK session_worker_thread_cb( void *args )
if
(
FAILED
(
hr
=
IAudioClient_Start
(
impl
->
audio_client
)))
goto
error
;
if
(
FAILED
(
hr
=
IAudioClient_GetBufferSize
(
impl
->
audio_client
,
&
frame_count
)))
goto
error
;
tmp_buf_size
=
sizeof
(
*
tmp_buf
)
*
frame_count
*
impl
->
capture_wfx
.
nBlockAlign
;
if
(
!
(
tmp_buf
=
malloc
(
tmp_buf_size
)))
{
ERR
(
"Memory allocation failed.
\n
"
);
return
1
;
}
while
(
running
)
{
BOOLEAN
old_paused
=
paused
;
...
...
@@ -232,13 +243,28 @@ static DWORD CALLBACK session_worker_thread_cb( void *args )
}
else
if
(
status
==
1
)
/* audio_buf_event signaled */
{
SIZE_T
packet_size
=
0
,
tmp_buf_offset
=
0
;
UINT32
frames_available
=
0
;
while
(
IAudioCaptureClient_GetBuffer
(
impl
->
capture_client
,
&
audio_buf
,
&
frames_available
,
&
flags
,
NULL
,
NULL
)
==
S_OK
)
while
(
tmp_buf_offset
<
tmp_buf_size
&&
IAudioCaptureClient_GetBuffer
(
impl
->
capture_client
,
&
audio_buf
,
&
frames_available
,
&
flags
,
NULL
,
NULL
)
==
S_OK
)
{
/* TODO: Send mic data to recognizer and handle results. */
packet_size
=
frames_available
*
impl
->
capture_wfx
.
nBlockAlign
;
if
(
tmp_buf_offset
+
packet_size
>
tmp_buf_size
)
{
/* Defer processing until the next iteration of the worker loop. */
IAudioCaptureClient_ReleaseBuffer
(
impl
->
capture_client
,
0
);
SetEvent
(
impl
->
audio_buf_event
);
break
;
}
memcpy
(
tmp_buf
+
tmp_buf_offset
,
audio_buf
,
packet_size
);
tmp_buf_offset
+=
packet_size
;
IAudioCaptureClient_ReleaseBuffer
(
impl
->
capture_client
,
frames_available
);
}
/* TODO: Send mic data to recognizer and handle results. */
}
else
{
...
...
@@ -253,6 +279,8 @@ static DWORD CALLBACK session_worker_thread_cb( void *args )
if
(
FAILED
(
hr
=
IAudioClient_Reset
(
impl
->
audio_client
)))
ERR
(
"IAudioClient_Reset failed with %#lx.
\n
"
,
hr
);
free
(
tmp_buf
);
return
0
;
error:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment