[vlc-devel] [PATCH v2 7/7] aout: assert that aout_DrainedReport is called correctly

Thomas Guillem thomas at gllm.fr
Wed Mar 13 09:55:55 CET 2019


---
 src/audio_output/aout_internal.h | 3 +++
 src/audio_output/dec.c           | 3 +++
 src/audio_output/output.c        | 3 +++
 3 files changed, 9 insertions(+)

diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index ba492cbd8a..5e37e70f72 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -85,6 +85,9 @@ typedef struct
     atomic_uint buffers_played;
     atomic_uchar restart;
 
+#ifndef NDEBUG
+    atomic_uint report_count;
+#endif
     vlc_sem_t report_sem;
     bool drained;
 } aout_owner_t;
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index a35c16763f..1ae5f15e25 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -534,6 +534,8 @@ void aout_DecFlush(audio_output_t *aout)
 void aout_Drained(audio_output_t *aout)
 {
     aout_owner_t *owner = aout_owner (aout);
+
+    assert(atomic_fetch_add(&owner->report_count, 1) == 0);
     vlc_sem_post(&owner->report_sem);
 }
 
@@ -553,6 +555,7 @@ void aout_DecDrain(audio_output_t *aout)
     {
         aout->drain(aout);
         vlc_sem_wait(&owner->report_sem);
+        assert(atomic_fetch_sub(&owner->report_count, 1) == 1);
     }
     else
     {
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index db1e41404a..6bb54a2012 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -244,6 +244,9 @@ audio_output_t *aout_New (vlc_object_t *parent)
     vlc_mutex_init (&owner->dev.lock);
     vlc_mutex_init (&owner->vp.lock);
     vlc_sem_init(&owner->report_sem, 0);
+#ifndef NDEBUG
+    atomic_init(&owner->report_count, 0);
+#endif
     vlc_viewpoint_init (&owner->vp.value);
     atomic_init (&owner->vp.update, false);
 
-- 
2.20.1



More information about the vlc-devel mailing list