[vlc-devel] commit: Cosmetics (K&R of picture_fifo). (Laurent Aimar )

git version control git at videolan.org
Mon Sep 7 20:16:58 CEST 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Mon Sep  7 19:39:53 2009 +0200| [237a788bd03e9c56d67266168afe0b82b438d323] | committer: Laurent Aimar 

Cosmetics (K&R of picture_fifo).

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

 include/vlc_picture_fifo.h |    6 +-
 src/misc/picture_fifo.c    |  137 +++++++++++++++++++++-----------------------
 2 files changed, 69 insertions(+), 74 deletions(-)

diff --git a/include/vlc_picture_fifo.h b/include/vlc_picture_fifo.h
index a881cea..440886e 100644
--- a/include/vlc_picture_fifo.h
+++ b/include/vlc_picture_fifo.h
@@ -73,16 +73,16 @@ VLC_EXPORT( void, picture_fifo_Push, ( picture_fifo_t *, picture_t * ) );
 
 /**
  * It release all picture inside the fifo that have a lower or equal date
- * if b_below or higher or equal to not b_below than the given one.
+ * if flush_before or higher or equal to if not flush_before than the given one.
  *
  * All pictures inside the fifo will be released by picture_Release.
  */
-VLC_EXPORT( void, picture_fifo_Flush, ( picture_fifo_t *, mtime_t i_date, bool b_below ) );
+VLC_EXPORT( void, picture_fifo_Flush, ( picture_fifo_t *, mtime_t date, bool flush_before ) );
 
 /**
  * It applies a delta on all the picture timestamp.
  */
-VLC_EXPORT( void, picture_fifo_OffsetDate, ( picture_fifo_t *, mtime_t i_delta ) );
+VLC_EXPORT( void, picture_fifo_OffsetDate, ( picture_fifo_t *, mtime_t delta ) );
 
 
 #endif /* VLC_PICTURE_FIFO_H */
diff --git a/src/misc/picture_fifo.c b/src/misc/picture_fifo.c
index 1e6fd6c..a050a4a 100644
--- a/src/misc/picture_fifo.c
+++ b/src/misc/picture_fifo.c
@@ -37,119 +37,114 @@
 /*****************************************************************************
  *
  *****************************************************************************/
-struct picture_fifo_t
-{
+struct picture_fifo_t {
     vlc_mutex_t lock;
-    picture_t *p_first;
-    picture_t **pp_last;
+    picture_t   *first;
+    picture_t   **last_ptr;
 };
 
-static void PictureFifoReset( picture_fifo_t *p_fifo )
+static void PictureFifoReset(picture_fifo_t *fifo)
 {
-    p_fifo->p_first = NULL;
-    p_fifo->pp_last = &p_fifo->p_first;
+    fifo->first    = NULL;
+    fifo->last_ptr = &fifo->first;
 }
-static void PictureFifoPush( picture_fifo_t *p_fifo, picture_t *p_picture )
+static void PictureFifoPush(picture_fifo_t *fifo, picture_t *picture)
 {
-    assert( !p_picture->p_next );
-    *p_fifo->pp_last = p_picture;
-    p_fifo->pp_last = &p_picture->p_next;
+    assert(!picture->p_next);
+    *fifo->last_ptr = picture;
+    fifo->last_ptr  = &picture->p_next;
 }
-static picture_t *PictureFifoPop( picture_fifo_t *p_fifo )
+static picture_t *PictureFifoPop(picture_fifo_t *fifo)
 {
-    picture_t *p_picture = p_fifo->p_first;
+    picture_t *picture = fifo->first;
 
-    if( p_picture )
-    {
-        p_fifo->p_first = p_picture->p_next;
-        if( !p_fifo->p_first )
-            p_fifo->pp_last = &p_fifo->p_first;
+    if (picture) {
+        fifo->first = picture->p_next;
+        if (!fifo->first)
+            fifo->last_ptr = &fifo->first;
     }
-    return p_picture;
+    return picture;
 }
 
 picture_fifo_t *picture_fifo_New(void)
 {
-    picture_fifo_t *p_fifo = malloc( sizeof(*p_fifo) );
-    if( !p_fifo )
+    picture_fifo_t *fifo = malloc(sizeof(*fifo));
+    if (!fifo)
         return NULL;
 
-    vlc_mutex_init( &p_fifo->lock );
-    PictureFifoReset( p_fifo );
-    return p_fifo;
+    vlc_mutex_init(&fifo->lock);
+    PictureFifoReset(fifo);
+    return fifo;
 }
 
-void picture_fifo_Push( picture_fifo_t *p_fifo, picture_t *p_picture )
+void picture_fifo_Push(picture_fifo_t *fifo, picture_t *picture)
 {
-    vlc_mutex_lock( &p_fifo->lock );
-    PictureFifoPush( p_fifo, p_picture );
-    vlc_mutex_unlock( &p_fifo->lock );
+    vlc_mutex_lock(&fifo->lock);
+    PictureFifoPush(fifo, picture);
+    vlc_mutex_unlock(&fifo->lock);
 }
-picture_t *picture_fifo_Pop( picture_fifo_t *p_fifo )
+picture_t *picture_fifo_Pop(picture_fifo_t *fifo)
 {
-    vlc_mutex_lock( &p_fifo->lock );
-    picture_t *p_picture = PictureFifoPop( p_fifo );
-    vlc_mutex_unlock( &p_fifo->lock );
+    vlc_mutex_lock(&fifo->lock);
+    picture_t *picture = PictureFifoPop(fifo);
+    vlc_mutex_unlock(&fifo->lock);
 
-    return p_picture;
+    return picture;
 }
-picture_t *picture_fifo_Peek( picture_fifo_t *p_fifo )
+picture_t *picture_fifo_Peek(picture_fifo_t *fifo)
 {
-    vlc_mutex_lock( &p_fifo->lock );
-    picture_t *p_picture = p_fifo->p_first;
-    if( p_picture )
-        picture_Hold( p_picture );
-    vlc_mutex_unlock( &p_fifo->lock );
+    vlc_mutex_lock(&fifo->lock);
+    picture_t *picture = fifo->first;
+    if (picture)
+        picture_Hold(picture);
+    vlc_mutex_unlock(&fifo->lock);
 
-    return p_picture;
+    return picture;
 }
-void picture_fifo_Flush( picture_fifo_t *p_fifo, mtime_t i_date, bool b_below )
+void picture_fifo_Flush(picture_fifo_t *fifo, mtime_t date, bool flush_before)
 {
-    picture_t *p_picture;
+    picture_t *picture;
 
-    vlc_mutex_lock( &p_fifo->lock );
+    vlc_mutex_lock(&fifo->lock);
 
-    p_picture = p_fifo->p_first;
-    PictureFifoReset( p_fifo );
+    picture = fifo->first;
+    PictureFifoReset(fifo);
 
     picture_fifo_t tmp;
-    PictureFifoReset( &tmp );
+    PictureFifoReset(&tmp);
 
-    while( p_picture )
-    {
-        picture_t *p_next = p_picture->p_next;
+    while (picture) {
+        picture_t *next = picture->p_next;
 
-        p_picture->p_next = NULL;
-        if( (  b_below && p_picture->date <= i_date ) ||
-            ( !b_below && p_picture->date >= i_date ) )
-            PictureFifoPush( &tmp, p_picture );
+        picture->p_next = NULL;
+        if (( flush_before && picture->date <= date) ||
+            (!flush_before && picture->date >= date))
+            PictureFifoPush(&tmp, picture);
         else
-            PictureFifoPush( p_fifo, p_picture );
-        p_picture = p_next;
+            PictureFifoPush(fifo, picture);
+        picture = next;
     }
-    vlc_mutex_unlock( &p_fifo->lock );
+    vlc_mutex_unlock(&fifo->lock);
 
-    for( ;; )
-    {
-        picture_t *p_picture = PictureFifoPop( &tmp );
-        if( !p_picture )
+    for (;;) {
+        picture_t *picture = PictureFifoPop(&tmp);
+        if (!picture)
             break;
-        picture_Release( p_picture );
+        picture_Release(picture);
     }
 }
-void picture_fifo_OffsetDate( picture_fifo_t *p_fifo, mtime_t i_delta )
+void picture_fifo_OffsetDate(picture_fifo_t *fifo, mtime_t delta)
 {
-    vlc_mutex_lock( &p_fifo->lock );
-    for( picture_t *p_picture = p_fifo->p_first; p_picture != NULL; )
-    {
-        p_picture->date += i_delta;
-        p_picture = p_picture->p_next;
+    vlc_mutex_lock(&fifo->lock);
+    for (picture_t *picture = fifo->first; picture != NULL;) {
+        picture->date += delta;
+        picture = picture->p_next;
     }
-    vlc_mutex_unlock( &p_fifo->lock );
+    vlc_mutex_unlock(&fifo->lock);
 }
-void picture_fifo_Delete( picture_fifo_t *p_fifo )
+void picture_fifo_Delete(picture_fifo_t *fifo)
 {
-    picture_fifo_Flush( p_fifo, INT64_MAX, true );
-    vlc_mutex_destroy( &p_fifo->lock );
+    picture_fifo_Flush(fifo, INT64_MAX, true);
+    vlc_mutex_destroy(&fifo->lock);
 }
 




More information about the vlc-devel mailing list