[vlc-commits] block_FifoShow: assume the FIFO is not empty

Rémi Denis-Courmont git at videolan.org
Thu May 7 19:06:50 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May  7 20:04:08 2015 +0300| [fec56da812ff920f39f628568a9a3d1c3a718bf3] | committer: Rémi Denis-Courmont

block_FifoShow: assume the FIFO is not empty

All existing call sites are in muxers and they all check that the FIFO
is not empty, and assume that it cannot be emptied asynchronously.

So simplify accordingly.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fec56da812ff920f39f628568a9a3d1c3a718bf3
---

 src/misc/fifo.c |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/misc/fifo.c b/src/misc/fifo.c
index b6cc0ca..d50d794 100644
--- a/src/misc/fifo.c
+++ b/src/misc/fifo.c
@@ -317,30 +317,24 @@ block_t *block_FifoGet(block_fifo_t *fifo)
 
 /**
  * Peeks the first block in the FIFO.
- * If necessary, wait until there is one block.
- * This function is (always) a cancellation point.
  *
  * @warning This function leaves the block in the FIFO.
  * You need to protect against concurrent threads who could dequeue the block.
  * Preferrably, there should be only one thread reading from the FIFO.
  *
+ * @warning This function is undefined if the FIFO is empty.
+ *
  * @return a valid block.
  */
 block_t *block_FifoShow( block_fifo_t *p_fifo )
 {
     block_t *b;
 
-    vlc_testcancel( );
-
     vlc_mutex_lock( &p_fifo->lock );
-    mutex_cleanup_push( &p_fifo->lock );
-
-    while( p_fifo->p_first == NULL )
-        vlc_cond_wait( &p_fifo->wait, &p_fifo->lock );
-
+    assert(p_fifo->p_first != NULL);
     b = p_fifo->p_first;
+    vlc_mutex_unlock( &p_fifo->lock );
 
-    vlc_cleanup_run ();
     return b;
 }
 



More information about the vlc-commits mailing list