RFR: 8267819: CoInitialize/CoUninitialize should be called on same thread

Alexander Matveev almatvee at openjdk.java.net
Wed Jun 2 22:00:43 UTC 2021


On Wed, 2 Jun 2021 14:29:41 GMT, Ambarish Rapte <arapte at openjdk.org> wrote:

>> JDK-8264737 introduced new code for audio device removal/arrival notifications which calls CoInitialize/CoUninitialize on separate threads. CoInitialize/CoUninitialize should be called on same thread, since initialization is per thread. Doing it on separate thread will result in unloading COM libraries on that thread and if it uses COM libraries it might not work correctly. Fixed by calling it on same thread in same way it is done in dshowwrapper.
>
> modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-good/sys/directsound/gstdirectsoundnotify.cpp line 57:
> 
>> 55:   bool bResult = false;
>> 56: 
>> 57:   if (FAILED(CoInitialize(NULL))) {
> 
> As per the [`CoUninitialize` doc](https://docs.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-couninitialize#remarks), `CoUninitialize` should also be called if `CoInitialize` returns S_FALSE. 
> Can you please check.

It will be called. S_FALSE is not a failure and defined as 1. FAILED macro returns true if error code < 0.

-------------

PR: https://git.openjdk.java.net/jfx/pull/521


More information about the openjfx-dev mailing list