X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=lib%2Ferror.c;h=f942f4d0e28db220b3e9416a85b09b0e23f798af;hb=439a6cf0b81ae925dad94444affb915c32590be8;hp=ef2ecdc74e2ee0fc171f0297015f27b55a95017d;hpb=36ab287e77e9df059f261ed1cfb13fc4674182ec;p=vlc diff --git a/lib/error.c b/lib/error.c index ef2ecdc74e..f942f4d0e2 100644 --- a/lib/error.c +++ b/lib/error.c @@ -30,34 +30,24 @@ static const char oom[] = "Out of memory"; /* TODO: use only one thread-specific key for whole libvlc */ static vlc_threadvar_t context; -static void libvlc_setup_threads (bool init) -{ - static vlc_mutex_t lock = VLC_STATIC_MUTEX; - static uintptr_t refs = 0; +static vlc_mutex_t lock = VLC_STATIC_MUTEX; +static uintptr_t refs = 0; +void libvlc_threads_init (void) +{ vlc_mutex_lock (&lock); - if (init) - { - if (refs++ == 0) - vlc_threadvar_create (&context, free); - } - else - { - assert (refs > 0); - if (--refs == 0) - vlc_threadvar_delete (&context); - } + if (refs++ == 0) + vlc_threadvar_create (&context, free); vlc_mutex_unlock (&lock); } -void libvlc_init_threads (void) +void libvlc_threads_deinit (void) { - libvlc_setup_threads (true); -} - -void libvlc_deinit_threads (void) -{ - libvlc_setup_threads (false); + vlc_mutex_lock (&lock); + assert (refs > 0); + if (--refs == 0) + vlc_threadvar_delete (&context); + vlc_mutex_unlock (&lock); } static char *get_error (void)