]> git.sesse.net Git - vlc/blobdiff - lib/error.c
demux: ts: only interpolate PCR on missing PCR
[vlc] / lib / error.c
index e3f7051ee88441defd139b0f7399b87b5cb6b31e..a86c95b9e736f4443ad2d82f9851931c5b665606 100644 (file)
@@ -3,19 +3,19 @@
  *****************************************************************************
  * Copyright (C) 2009 RĂ©mi Denis-Courmont
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #include "libvlc_internal.h"
@@ -30,46 +30,43 @@ 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 char *get_error (void)
 {
-    static vlc_mutex_t lock = VLC_STATIC_MUTEX;
-    static uintptr_t refs = 0;
-
-    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);
-    }
-    vlc_mutex_unlock (&lock);
+    return vlc_threadvar_get (context);
 }
 
-void libvlc_init_threads (void)
+static void free_msg (void *msg)
 {
-    libvlc_setup_threads (true);
+    if (msg != oom)
+        free (msg);
 }
 
-void libvlc_deinit_threads (void)
+static void free_error (void)
 {
-    libvlc_setup_threads (false);
+    free_msg (get_error ());
 }
 
-static char *get_error (void)
+static vlc_mutex_t lock = VLC_STATIC_MUTEX;
+static uintptr_t refs = 0;
+
+void libvlc_threads_init (void)
 {
-    return vlc_threadvar_get (context);
+    vlc_mutex_lock (&lock);
+    if (refs++ == 0)
+        vlc_threadvar_create (&context, free_msg);
+    vlc_mutex_unlock (&lock);
 }
 
-static void free_error (void)
+void libvlc_threads_deinit (void)
 {
-    char *msg = get_error ();
-    if (msg != oom)
-        free (msg);
+    vlc_mutex_lock (&lock);
+    assert (refs > 0);
+    if (--refs == 0)
+    {
+        free_error ();
+        vlc_threadvar_delete (&context);
+    }
+    vlc_mutex_unlock (&lock);
 }
 
 /**