[vlc-devel] [PATCH 2/4] fifo: inline trivial functions

RĂ©mi Denis-Courmont remi at remlab.net
Sat Apr 11 20:41:04 CEST 2020


---
 include/vlc_block.h | 66 ++++++++++++++++++++++++++++++++++-----------
 src/libvlccore.sym  |  3 ---
 src/misc/fifo.c     | 39 ---------------------------
 3 files changed, 50 insertions(+), 58 deletions(-)

diff --git a/include/vlc_block.h b/include/vlc_block.h
index 5817350ea0..2c98499db0 100644
--- a/include/vlc_block.h
+++ b/include/vlc_block.h
@@ -457,19 +457,6 @@ VLC_API block_fifo_t *block_FifoNew(void) VLC_USED VLC_MALLOC;
  */
 VLC_API void block_FifoRelease(block_fifo_t *);
 
-/**
- * Clears all blocks in a FIFO.
- */
-VLC_API void block_FifoEmpty(block_fifo_t *);
-
-/**
- * Immediately queue one block at the end of a FIFO.
- *
- * @param fifo queue
- * @param block head of a block list to queue (may be NULL)
- */
-VLC_API void block_FifoPut(block_fifo_t *fifo, block_t *block);
-
 /**
  * Dequeue the first block from the FIFO. If necessary, wait until there is
  * one block in the queue. This function is (always) cancellation point.
@@ -491,9 +478,6 @@ VLC_API block_t *block_FifoGet(block_fifo_t *) VLC_USED;
  */
 VLC_API block_t *block_FifoShow(block_fifo_t *);
 
-size_t block_FifoSize(block_fifo_t *) VLC_USED VLC_DEPRECATED;
-VLC_API size_t block_FifoCount(block_fifo_t *) VLC_USED VLC_DEPRECATED;
-
 typedef struct block_fifo_t vlc_fifo_t;
 
 /**
@@ -629,6 +613,56 @@ static inline void vlc_fifo_Cleanup(void *fifo)
 }
 #define vlc_fifo_CleanupPush(fifo) vlc_cleanup_push(vlc_fifo_Cleanup, fifo)
 
+/**
+ * Clears all blocks in a FIFO.
+ */
+static inline void block_FifoEmpty(block_fifo_t *fifo)
+{
+    block_t *block;
+
+    vlc_fifo_Lock(fifo);
+    block = vlc_fifo_DequeueAllUnlocked(fifo);
+    vlc_fifo_Unlock(fifo);
+    block_ChainRelease(block);
+}
+
+/**
+ * Immediately queue one block at the end of a FIFO.
+ *
+ * @param fifo queue
+ * @param block head of a block list to queue (may be NULL)
+ */
+static inline void block_FifoPut(block_fifo_t *fifo, block_t *block)
+{
+    vlc_fifo_Lock(fifo);
+    vlc_fifo_QueueUnlocked(fifo, block);
+    vlc_fifo_Unlock(fifo);
+}
+
+/* FIXME: not (really) thread-safe */
+VLC_USED VLC_DEPRECATED
+static inline size_t block_FifoSize (block_fifo_t *fifo)
+{
+    size_t size;
+
+    vlc_fifo_Lock(fifo);
+    size = vlc_fifo_GetBytes(fifo);
+    vlc_fifo_Unlock(fifo);
+    return size;
+}
+
+/* FIXME: not (really) thread-safe */
+VLC_USED VLC_DEPRECATED
+static inline size_t block_FifoCount (block_fifo_t *fifo)
+{
+    size_t depth;
+
+    vlc_fifo_Lock(fifo);
+    depth = vlc_fifo_GetCount(fifo);
+    vlc_fifo_Unlock(fifo);
+    return depth;
+}
+
 /** @} */
 
 /** @} */
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index cc8098edd9..895285ac01 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -31,11 +31,8 @@ aout_FiltersAdjustResampling
 aout_Hold
 aout_Release
 block_Alloc
-block_FifoCount
-block_FifoEmpty
 block_FifoGet
 block_FifoNew
-block_FifoPut
 block_FifoRelease
 block_FifoShow
 block_File
diff --git a/src/misc/fifo.c b/src/misc/fifo.c
index 564c83f64f..522d52d167 100644
--- a/src/misc/fifo.c
+++ b/src/misc/fifo.c
@@ -159,23 +159,6 @@ void block_FifoRelease( block_fifo_t *p_fifo )
     free( p_fifo );
 }
 
-void block_FifoEmpty(block_fifo_t *fifo)
-{
-    block_t *block;
-
-    vlc_fifo_Lock(fifo);
-    block = vlc_fifo_DequeueAllUnlocked(fifo);
-    vlc_fifo_Unlock(fifo);
-    block_ChainRelease(block);
-}
-
-void block_FifoPut(block_fifo_t *fifo, block_t *block)
-{
-    vlc_fifo_Lock(fifo);
-    vlc_fifo_QueueUnlocked(fifo, block);
-    vlc_fifo_Unlock(fifo);
-}
-
 block_t *block_FifoGet(block_fifo_t *fifo)
 {
     block_t *block;
@@ -206,25 +189,3 @@ block_t *block_FifoShow( block_fifo_t *p_fifo )
 
     return b;
 }
-
-/* FIXME: not (really) thread-safe */
-size_t block_FifoSize (block_fifo_t *fifo)
-{
-    size_t size;
-
-    vlc_fifo_Lock(fifo);
-    size = vlc_fifo_GetBytes(fifo);
-    vlc_fifo_Unlock(fifo);
-    return size;
-}
-
-/* FIXME: not (really) thread-safe */
-size_t block_FifoCount (block_fifo_t *fifo)
-{
-    size_t depth;
-
-    vlc_fifo_Lock(fifo);
-    depth = vlc_fifo_GetCount(fifo);
-    vlc_fifo_Unlock(fifo);
-    return depth;
-}
-- 
2.26.0



More information about the vlc-devel mailing list