[vlc-devel] [PATCH V2 1/4] block: add vlc_block_discontinuity

Thomas Guillem thomas at gllm.fr
Fri Mar 1 12:41:50 CET 2019


A special block that will be used by audio filters.
---
 include/vlc_block.h | 11 +++++++++++
 src/libvlccore.sym  |  1 +
 src/misc/block.c    |  8 +++++++-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/include/vlc_block.h b/include/vlc_block.h
index 18e1e11514..f4afa0b542 100644
--- a/include/vlc_block.h
+++ b/include/vlc_block.h
@@ -40,6 +40,7 @@
  * Data block definition and functions
  */
 
+#include <assert.h>
 #include <sys/types.h>  /* for ssize_t */
 
 /****************************************************************************
@@ -130,6 +131,14 @@ struct block_t
     const struct vlc_block_callbacks *cbs;
 };
 
+/**
+ * Special block to signal a discontinuity
+ *
+ * This block needs a special handling: it should not be released or appended
+ * to a block chain.
+ */
+VLC_API block_t *vlc_block_discontinuity;
+
 /**
  * Initializes a custom block.
  *
@@ -329,6 +338,7 @@ static inline void block_Cleanup (void *block)
  ****************************************************************************/
 static inline void block_ChainAppend( block_t **pp_list, block_t *p_block )
 {
+    assert(p_block != vlc_block_discontinuity);
     if( *pp_list == NULL )
     {
         *pp_list = p_block;
@@ -344,6 +354,7 @@ static inline void block_ChainAppend( block_t **pp_list, block_t *p_block )
 
 static inline void block_ChainLastAppend( block_t ***ppp_last, block_t *p_block )
 {
+    assert(p_block != vlc_block_discontinuity);
     block_t *p_last = p_block;
 
     **ppp_last = p_block;
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index a861c988e5..45af83a0fe 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -28,6 +28,7 @@ aout_FiltersDrain
 aout_FiltersFlush
 aout_FiltersPlay
 aout_FiltersAdjustResampling
+vlc_block_discontinuity
 block_Alloc
 block_FifoCount
 block_FifoEmpty
diff --git a/src/misc/block.c b/src/misc/block.c
index 7d67138768..443757e967 100644
--- a/src/misc/block.c
+++ b/src/misc/block.c
@@ -26,7 +26,6 @@
 #endif
 
 #include <sys/stat.h>
-#include <assert.h>
 #include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -35,11 +34,18 @@
 #include <vlc_block.h>
 #include <vlc_fs.h>
 
+static block_t static_discontinuity_block =
+{
+    .i_flags = BLOCK_FLAG_DISCONTINUITY,
+};
+block_t *vlc_block_discontinuity = &static_discontinuity_block;
+
 #ifndef NDEBUG
 static void block_Check (block_t *block)
 {
     while (block != NULL)
     {
+        assert(block != vlc_block_discontinuity);
         unsigned char *start = block->p_start;
         unsigned char *end = block->p_start + block->i_size;
         unsigned char *bufstart = block->p_buffer;
-- 
2.20.1



More information about the vlc-devel mailing list