I tested the solutions.
I'll take the second.

For info for those interested,
I followed the first solution with visualVM, we see a lot of thread
creation on java side and as thread creation is expensive...
3000 threads Java in 2 minutes of execution :)

thanks again

Le jeu. 24 mars 2022 à 20:54, Algarve Branqueira <[email protected]> a
écrit :

> Just for info for people who don't know JNI.
>
> When calling java code from c, it is mandatory to attach a java thread to
> the c thread. When we attach a java thread from the c thread, it creates a
> java thread and we specify a name for it.
>
> So your first solution which consists in attaching the thread at the
> beginning of the "wrapper_logger" method and detaching at the end of this
> method works but I have to monitor if it is not too expensive for the JVM.
> I've never been in this case, in general we attach to the creation of the
> thread and we detach at the end
>
> Otherwise your second solution is the most interesting if it is not
> possible to execute code at the end.
> the main thread is already attached because the caller is Java, then as
> you say, you have to put the messages of the ffmpeg worker threads in a
> global variable
>
> Any idea is good to take, a community is made to share ideas, a bad idea
> can lead to other good idea
>
> Thanks very much
>
> Le jeu. 24 mars 2022 à 20:32, Simon <[email protected]> a écrit :
>
>> Hi,
>>
>> Even if you aren't creating per-thread objects, java is when you register
>> the thread. Two options I can see are:
>> 1) tidy up before you return control - this would mean register the
>> thread with java only while in your logging callback and unregister before
>> returning.
>> 2) Only log to java from a single thread and get the other threads to
>> queue the log messages up in some global object.
>>
>> I expect my second option is actually the most practical. You can have a
>> thread then runs as long as any task is running and just pulls log messages
>> out of the queue and posts them to java.
>>
>> Hope that's helpful.
>>
>> Simon
>>
>> Sent from my Huawei Mobile_______________________________________________
>> Libav-user mailing list
>> [email protected]
>> https://ffmpeg.org/mailman/listinfo/libav-user
>>
>> To unsubscribe, visit link above, or email
>> [email protected] with subject "unsubscribe".
>>
>
_______________________________________________
Libav-user mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to