<html><head></head><body>Is the lock still used for anything?<br><br><div class="gmail_quote">Le 10 juin 2020 16:32:22 GMT+03:00, "Hugo Beauzée-Luyssen" <hugo@beauzee.fr> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail"><hr> lib/core.c            | 17 +++--------------<br> lib/libvlc_internal.h |  3 ++-<br> 2 files changed, 5 insertions(+), 15 deletions(-)<br><br>diff --git a/lib/core.c b/lib/core.c<br>index 56b985f597..8a998e3095 100644<br>--- a/lib/core.c<br>+++ b/lib/core.c<br>@@ -60,7 +60,7 @@ libvlc_instance_t * libvlc_new( int argc, const char *const *argv )<br>     }<br> <br>     p_new->p_libvlc_int = p_libvlc_int;<br>-    p_new->ref_count = 1;<br>+    vlc_atomic_rc_init( &p_new->ref_count );<br>     p_new->p_callback_list = NULL;<br>     vlc_mutex_init(&p_new->instance_lock);<br>     return p_new;<br>@@ -74,24 +74,13 @@ error:<br> void libvlc_retain( libvlc_instance_t *p_instance )<br> {<br>     assert( p_instance != NULL );<br>-    assert( p_instance->ref_count < UINT_MAX );<br> <br>-    vlc_mutex_lock( &p_instance->instance_lock );<br>-    p_instance->ref_count++;<br>-    vlc_mutex_unlock( &p_instance->instance_lock );<br>+    vlc_atomic_rc_inc( &p_instance->ref_count );<br> }<br> <br> void libvlc_release( libvlc_instance_t *p_instance )<br> {<br>-    vlc_mutex_t *lock = &p_instance->instance_lock;<br>-    int refs;<br>-<br>-    vlc_mutex_lock( lock );<br>-    assert( p_instance->ref_count > 0 );<br>-    refs = --p_instance->ref_count;<br>-    vlc_mutex_unlock( lock );<br>-<br>-    if( refs == 0 )<br>+    if(vlc_atomic_rc_dec( &p_instance->ref_count ))<br>     {<br>         libvlc_Quit( p_instance->p_libvlc_int );<br>         libvlc_InternalCleanup( p_instance->p_libvlc_int );<br>diff --git a/lib/libvlc_internal.h b/lib/libvlc_internal.h<br>index 5c1107b84f..6c8ff49a81 100644<br>--- a/lib/libvlc_internal.h<br>+++ b/lib/libvlc_internal.h<br>@@ -33,6 +33,7 @@<br> #include <vlc/libvlc_picture.h><br> #include <vlc/libvlc_media.h><br> #include <vlc/libvlc_events.h><br>+#include <vlc_atomic.h><br> <br> #include <vlc_common.h><br> <br>@@ -60,7 +61,7 @@ VLC_API void libvlc_SetExitHandler( libvlc_int_t *, void (*) (void *), void * );<br> struct libvlc_instance_t<br> {<br>     libvlc_int_t *p_libvlc_int;<br>-    unsigned      ref_count;<br>+    vlc_atomic_rc_t ref_count;<br>     vlc_mutex_t   instance_lock;<br>     struct libvlc_callback_entry_list_t *p_callback_list;<br>     struct</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>