]> git.sesse.net Git - vlc/blobdiff - lib/error.c
demux: ts: only interpolate PCR on missing PCR
[vlc] / lib / error.c
index f942f4d0e28db220b3e9416a85b09b0e23f798af..a86c95b9e736f4443ad2d82f9851931c5b665606 100644 (file)
@@ -30,6 +30,22 @@ static const char oom[] = "Out of memory";
 /* TODO: use only one thread-specific key for whole libvlc */
 static vlc_threadvar_t context;
 
+static char *get_error (void)
+{
+    return vlc_threadvar_get (context);
+}
+
+static void free_msg (void *msg)
+{
+    if (msg != oom)
+        free (msg);
+}
+
+static void free_error (void)
+{
+    free_msg (get_error ());
+}
+
 static vlc_mutex_t lock = VLC_STATIC_MUTEX;
 static uintptr_t refs = 0;
 
@@ -37,7 +53,7 @@ void libvlc_threads_init (void)
 {
     vlc_mutex_lock (&lock);
     if (refs++ == 0)
-        vlc_threadvar_create (&context, free);
+        vlc_threadvar_create (&context, free_msg);
     vlc_mutex_unlock (&lock);
 }
 
@@ -46,22 +62,13 @@ void libvlc_threads_deinit (void)
     vlc_mutex_lock (&lock);
     assert (refs > 0);
     if (--refs == 0)
+    {
+        free_error ();
         vlc_threadvar_delete (&context);
+    }
     vlc_mutex_unlock (&lock);
 }
 
-static char *get_error (void)
-{
-    return vlc_threadvar_get (context);
-}
-
-static void free_error (void)
-{
-    char *msg = get_error ();
-    if (msg != oom)
-        free (msg);
-}
-
 /**
  * Gets a human-readable error message for the last LibVLC error in the calling
  * thread. The resulting string is valid until another error occurs (at least