[vlc-commits] omxil: factorize OMX_FIFO init/destroy

Thomas Guillem git at videolan.org
Sun Jun 29 22:37:41 CEST 2014


vlc | branch: master | Thomas Guillem <guillem at archos.com> | Thu Jun 26 14:05:58 2014 +0200| [60bcd55e7a7b548e4369be91e6f826ffbaca2480] | committer: Martin Storsjö

omxil: factorize OMX_FIFO init/destroy

Signed-off-by: Martin Storsjö <martin at martin.st>

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

 modules/codec/omxil/omxil.c       |   17 +++++------------
 modules/codec/omxil/omxil.h       |   24 +++++++++++++-----------
 modules/codec/omxil/omxil_utils.h |   10 ++++++++++
 3 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index ea3d7e2..f7c52f8 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -854,17 +854,11 @@ static int OpenGeneric( vlc_object_t *p_this, bool b_encode )
     }
     p_sys->b_enc = b_encode;
     InitOmxEventQueue(&p_sys->event_queue);
-    vlc_mutex_init (&p_sys->in.fifo.lock);
-    vlc_cond_init (&p_sys->in.fifo.wait);
-    p_sys->in.fifo.offset = offsetof(OMX_BUFFERHEADERTYPE, pOutputPortPrivate) / sizeof(void *);
-    p_sys->in.fifo.pp_last = &p_sys->in.fifo.p_first;
+    OMX_FIFO_INIT (&p_sys->in.fifo, pOutputPortPrivate );
     p_sys->in.b_direct = false;
     p_sys->in.b_flushed = true;
     p_sys->in.p_fmt = &p_dec->fmt_in;
-    vlc_mutex_init (&p_sys->out.fifo.lock);
-    vlc_cond_init (&p_sys->out.fifo.wait);
-    p_sys->out.fifo.offset = offsetof(OMX_BUFFERHEADERTYPE, pInputPortPrivate) / sizeof(void *);
-    p_sys->out.fifo.pp_last = &p_sys->out.fifo.p_first;
+    OMX_FIFO_INIT (&p_sys->out.fifo, pInputPortPrivate );
     p_sys->out.b_direct = false;
     p_sys->out.b_flushed = true;
     p_sys->out.p_fmt = &p_dec->fmt_out;
@@ -1645,10 +1639,9 @@ static void CloseGeneric( vlc_object_t *p_this )
     DeinitOmxCore();
 
     DeinitOmxEventQueue(&p_sys->event_queue);
-    vlc_mutex_destroy (&p_sys->in.fifo.lock);
-    vlc_cond_destroy (&p_sys->in.fifo.wait);
-    vlc_mutex_destroy (&p_sys->out.fifo.lock);
-    vlc_cond_destroy (&p_sys->out.fifo.wait);
+
+    OMX_FIFO_DESTROY( &p_sys->in.fifo );
+    OMX_FIFO_DESTROY( &p_sys->out.fifo );
 
     free( p_sys );
 }
diff --git a/modules/codec/omxil/omxil.h b/modules/codec/omxil/omxil.h
index 1d6ea76..6cb7abf 100644
--- a/modules/codec/omxil/omxil.h
+++ b/modules/codec/omxil/omxil.h
@@ -39,6 +39,18 @@
 /*****************************************************************************
  * decoder_sys_t : omxil decoder descriptor
  *****************************************************************************/
+typedef struct OmxFifo
+{
+    vlc_mutex_t lock;
+    vlc_cond_t  wait;
+
+    OMX_BUFFERHEADERTYPE *p_first;
+    OMX_BUFFERHEADERTYPE **pp_last;
+
+    int offset;
+
+} OmxFifo;
+
 typedef struct OmxPort
 {
     bool b_valid;
@@ -54,17 +66,7 @@ typedef struct OmxPort
     unsigned int i_buffers;
     OMX_BUFFERHEADERTYPE **pp_buffers;
 
-    struct fifo_t
-    {
-      vlc_mutex_t         lock;
-      vlc_cond_t          wait;
-
-      OMX_BUFFERHEADERTYPE *p_first;
-      OMX_BUFFERHEADERTYPE **pp_last;
-
-      int offset;
-
-    } fifo;
+    OmxFifo fifo;
 
     OmxFormatParam format_param;
 
diff --git a/modules/codec/omxil/omxil_utils.h b/modules/codec/omxil/omxil_utils.h
index 943e836..a1d564b 100644
--- a/modules/codec/omxil/omxil_utils.h
+++ b/modules/codec/omxil/omxil_utils.h
@@ -80,6 +80,16 @@ static inline OMX_TICKS ToOmxTicks(int64_t value)
 /*****************************************************************************
  * OMX buffer FIFO macros
  *****************************************************************************/
+#define OMX_FIFO_INIT(p_fifo, next) \
+    do { vlc_mutex_init( &(p_fifo)->lock ); \
+         vlc_cond_init( &(p_fifo)->wait ); \
+         (p_fifo)->offset = offsetof(OMX_BUFFERHEADERTYPE, next) / sizeof(void *); \
+         (p_fifo)->pp_last = &(p_fifo)->p_first; } while(0)
+
+#define OMX_FIFO_DESTROY(p_fifo) \
+    do { vlc_mutex_destroy( &(p_fifo)->lock ); \
+         vlc_cond_destroy (&(p_fifo)->wait); } while(0)
+
 #define OMX_FIFO_PEEK(p_fifo, p_buffer) \
          p_buffer = (p_fifo)->p_first;
 



More information about the vlc-commits mailing list