[vlc-devel] [RFC-PATCH 04/12] core: introduce input_Decoder{Set, Get}PrerollEnd

Filip Roséen filip at videolabs.io
Wed May 11 18:56:49 CEST 2016


These two functions will simply set and get the i_preroll_end
data-member inside the private section of a decoder.

There are two main reasons for adding them:

  1. The decoders preroll-end value must be reachable from the es-out
     that recieves ES_OUT_SET_NEXT_DISPLAY_TIME.

  2. There are multiple cases in the source code where we have to lock
     the owners lock, read the value, and then immediately unlock the
     mutex. Having helpers will shorten such cases.

This patch includes usage of the function within DecoderProcessFlush.

--

TODO: Instead of locking/unlocking the mutex each time we are interested
in reading/writing the value, we should use an atomic variable.
---
 src/input/decoder.c | 25 ++++++++++++++++++++++---
 src/input/decoder.h | 17 +++++++++++++++++
 2 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index b20bc35..66b3725 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1399,9 +1399,7 @@ static void DecoderProcessFlush( decoder_t *p_dec )
         }
     }
 
-    vlc_mutex_lock( &p_owner->lock );
-    p_owner->i_preroll_end = INT64_MIN;
-    vlc_mutex_unlock( &p_owner->lock );
+    input_DecoderSetPrerollEnd( p_dec, VLC_TS_INVALID );
 }
 
 /**
@@ -2225,3 +2223,24 @@ void input_DecoderGetObjects( decoder_t *p_dec,
         *pp_aout = p_owner->p_aout ? vlc_object_hold( p_owner->p_aout ) : NULL;
     vlc_mutex_unlock( &p_owner->lock );
 }
+
+void input_DecoderSetPrerollEnd( decoder_t *p_dec, mtime_t i_preroll_end )
+{
+    decoder_owner_sys_t * p_owner = p_dec->p_owner;
+
+    vlc_mutex_lock( &p_owner->lock );
+    /**/ p_owner->i_preroll_end = i_preroll_end;
+    vlc_mutex_unlock( &p_owner->lock );
+}
+
+mtime_t input_DecoderGetPrerollEnd( decoder_t * p_dec )
+{
+    decoder_owner_sys_t * p_owner = p_dec->p_owner;
+    mtime_t i_preroll_end;
+
+    vlc_mutex_lock( &p_owner->lock );
+    /**/ i_preroll_end = p_owner->i_preroll_end;
+    vlc_mutex_unlock( &p_owner->lock );
+
+    return i_preroll_end;
+}
diff --git a/src/input/decoder.h b/src/input/decoder.h
index 226ecde..5569264 100644
--- a/src/input/decoder.h
+++ b/src/input/decoder.h
@@ -108,4 +108,21 @@ size_t input_DecoderGetFifoSize( decoder_t *p_dec );
  */
 void input_DecoderGetObjects( decoder_t *, vout_thread_t **, audio_output_t ** );
 
+/**
+ * This function returns the current preroll timestamp associated with a decoer
+ *
+ * @param pointer to the decoder
+ * @return the preroll VLC timestamp associated with the decoder.
+ */
+mtime_t input_DecoderGetPrerollEnd( decoder_t * );
+
+/**
+ * This function will set the preroll timestamp associated with a decoder
+ *
+ * @param pointer to the decoder
+ * @param the desired vlc timestamp
+ */
+void input_DecoderSetPrerollEnd( decoder_t *, mtime_t );
+
+
 #endif
-- 
2.8.2



More information about the vlc-devel mailing list