RFR: 8301846: Invalid TargetDataLine after screen lock when using JFileChooser or COM library [v3]

Alexey Ivanov aivanov at openjdk.org
Thu Jul 27 16:32:52 UTC 2023


On Thu, 27 Jul 2023 16:23:01 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> is it possible that our "::CoInitialize(NULL);" prevents the ::CoInitializeEx(NULL, COINIT_MULTITHREADED); in the lib later?
>
>> is it possible that our "::CoInitialize(NULL);" prevents the ::CoInitializeEx(NULL, COINIT_MULTITHREADED); in the lib later?
> 
> It is not only possible, it is explicitly stated. If the threading mode is different, the function fails with `RPC_E_CHANGED_MODE`.
> 
>> But if that code requare com my expectation would be that they call CoInitialize/CoUninitialize.
> 
> Exactly! Microsoft docs don't state COM needs be initialised for enumerating devices but it looks like it needs to be.
> 
>> This CoInitialize initially was added here [JDK-6950553](https://bugs.openjdk.org/browse/JDK-6950553) (check the stack trace)
> 
> It somewhat confirms, you can't access COM without initialising it.

> We can try reuse the "Filechooser.invokeCom" machinery, but I do not think I like it.

As things look now, I'm inclined to use a similar facility as `Filechooser.invokeCom` but separate and independent. I mean starting an executor service or a thread which initialises COM and handles enumeration requests. Or re-using that servicing thread that's already exists where COM initialisation was added by JDK-6950553.

I couldn't find an explicit statement whether DirectSound objects require STA or support MTA. If everything works with MTA, I prefer switching to `::CoInitializeEx(NULL, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE)`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14898#discussion_r1276539431



More information about the client-libs-dev mailing list