On Mon Jan 16 16:20:41 2023 +0000, Jinoh Kang wrote:
This changes the `recognizer_state` regardless of whether the thread creation succeeds or not.
if ((impl->worker_thread = CreateThread(NULL, 0, session_worker_thread_cb, impl, 0, NULL))) { impl->worker_running = TRUE; impl->recognizer_state = SpeechRecognizerState_Capturing; } else { hr = HRESULT_FROM_WIN32(GetLastError()); }
However, in general this function should be improved in a direction that reduces nested `if`s. You can also replace `invalid_state = TRUE` with `hr = COR_E_INVALIDOPERATION`. Nested `if`s can be replaced by successive `if (SUCCEEDED(hr) [&& ...] )` statements.
Yeah, the function developed in an ugly direction.