]> git.sesse.net Git - vlc/blobdiff - src/audio_output/common.c
GLX: remove MIT-SHM support infrastructure
[vlc] / src / audio_output / common.c
index 62b11e8cc84b61eccfaa21765be03cb965966af9..116e51e96528c5962645f66de580128706305205 100644 (file)
@@ -114,6 +114,56 @@ static void aout_Destructor( vlc_object_t * p_this )
     vlc_mutex_destroy( &p_aout->output_fifo_lock );
 }
 
+/* Lock ordering rules:
+ *
+ *            Mixer Input IFIFO OFIFO (< Inner lock)
+ * Mixer       No!   Yes   Yes   Yes
+ * Input       No!   No!   Yes   Yes
+ * In FIFOs    No!   No!   No!   Yes
+ * Out FIFOs   No!   No!   No!   No!
+ * (^ Outer lock)
+ */
+#ifdef AOUT_DEBUG
+/* Lock debugging */
+static __thread unsigned aout_locks = 0;
+
+void aout_lock (unsigned i)
+{
+    unsigned allowed;
+    switch (i)
+    {
+        case MIXER_LOCK:
+            allowed = 0;
+            break;
+        case INPUT_LOCK:
+            allowed = MIXER_LOCK;
+            break;
+        case INPUT_FIFO_LOCK:
+            allowed = MIXER_LOCK|INPUT_LOCK;
+            break;
+        case OUTPUT_FIFO_LOCK:
+            allowed = MIXER_LOCK|INPUT_LOCK|INPUT_FIFO_LOCK;
+            break;
+        default:
+            abort ();
+    }
+
+    if (aout_locks & ~allowed)
+    {
+        fprintf (stderr, "Illegal audio lock transition (%x -> %x)\n",
+                 aout_locks, aout_locks|i);
+        vlc_backtrace ();
+        abort ();
+    }
+    aout_locks |= i;
+}
+
+void aout_unlock (unsigned i)
+{
+    assert (aout_locks & i);
+    aout_locks &= ~i;
+}
+#endif
 
 /*
  * Formats management (internal and external)