diff options
| author | Andre Weissflog <floooh@gmail.com> | 2020-09-19 19:19:44 +0200 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2020-09-19 19:19:44 +0200 |
| commit | 7c439f371010b271a9523ff210aef6a1fe4a7902 (patch) | |
| tree | 86a333cfa5afeedb681649e1c430d21716c62423 /sokol_audio.h | |
| parent | 342821c8452fff509107fe4ddc6318335208e3ea (diff) | |
sokol_audio.h win32: ignore CoInitializeEx return value (fixes #381)
Diffstat (limited to 'sokol_audio.h')
| -rw-r--r-- | sokol_audio.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sokol_audio.h b/sokol_audio.h index dd6d2d63..d016720a 100644 --- a/sokol_audio.h +++ b/sokol_audio.h @@ -1187,11 +1187,12 @@ _SOKOL_PRIVATE void _saudio_wasapi_release(void) { } _SOKOL_PRIVATE bool _saudio_backend_init(void) { - REFERENCE_TIME dur; - if (FAILED(CoInitializeEx(0, COINIT_MULTITHREADED))) { - SOKOL_LOG("sokol_audio wasapi: CoInitializeEx failed"); - return false; - } + /* CoInitializeEx could have been called elsewhere already, in which + case the function returns with S_FALSE (thus it doesn't make much + sense to check the result) + */ + CoInitializeEx(0, COINIT_MULTITHREADED); + _saudio.backend.thread.buffer_end_event = CreateEvent(0, FALSE, FALSE, 0); if (0 == _saudio.backend.thread.buffer_end_event) { SOKOL_LOG("sokol_audio wasapi: failed to create buffer_end_event"); @@ -1228,8 +1229,7 @@ _SOKOL_PRIVATE bool _saudio_backend_init(void) { fmt.wBitsPerSample = 16; fmt.nBlockAlign = (fmt.nChannels * fmt.wBitsPerSample) / 8; fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nBlockAlign; - dur = (REFERENCE_TIME) - (((double)_saudio.buffer_frames) / (((double)_saudio.sample_rate) * (1.0/10000000.0))); + REFERENCE_TIME dur = (REFERENCE_TIME) (((double)_saudio.buffer_frames) / (((double)_saudio.sample_rate) * (1.0/10000000.0))); if (FAILED(IAudioClient_Initialize(_saudio.backend.audio_client, AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK|AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM|AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY, |