[vlc-devel] commit: Added a input "cache" variable and INPUT_EVENT_CACHE event. ( Laurent Aimar )

git version control git at videolan.org
Thu Dec 4 23:10:44 CET 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Thu Dec  4 22:54:29 2008 +0100| [2d98c228d68921314ced40ce15aef4d14dc6a7dc] | committer: Laurent Aimar 

Added a input "cache" variable and INPUT_EVENT_CACHE event.

They will allow interfaces to display the current buffering status.

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

 include/vlc_input.h |    4 ++++
 src/input/es_out.c  |    7 +++++--
 src/input/event.c   |   10 ++++++++++
 src/input/event.h   |    1 +
 src/input/input.c   |    1 +
 src/input/var.c     |    3 +++
 6 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index 9bee572..85e0de1 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -444,6 +444,7 @@ struct input_thread_t
  *  - "teletext-es" to get the index of spu track that is teletext -1 if no teletext)
  *  - "signal-quality"
  *  - "signal-strength"
+ *  - "cache" (level of data cached [0 .. 1])
  *
  * The read-write variables are:
  *  - state (\see input_state_e)
@@ -561,6 +562,9 @@ typedef enum input_event_type_e
     /* "bookmark" has changed */
     INPUT_EVENT_BOOKMARK,
 
+    /* cache" has changed */
+    INPUT_EVENT_CACHE,
+
 } input_event_type_e;
 
 /** @}*/
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 03bd35f..2c676f9 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -626,10 +626,13 @@ static void EsOutDecodersStopBuffering( es_out_t *out, bool b_forced )
 
     if( i_stream_duration <= i_buffering_duration && !b_forced )
     {
-        msg_Dbg( p_sys->p_input, "Buffering %d%%",
-                 (int)(100 * i_stream_duration / i_buffering_duration ) );
+        const double f_level = (double)i_stream_duration / i_buffering_duration;
+        input_SendEventCache( p_sys->p_input, f_level );
+
+        msg_Dbg( p_sys->p_input, "Buffering %d%%", (int)(100 * f_level) );
         return;
     }
+    input_SendEventCache( p_sys->p_input, 1.0 );
 
     msg_Dbg( p_sys->p_input, "Stream buffering done (%d ms in %d ms)",
               (int)(i_stream_duration/1000), (int)(i_system_duration/1000) );
diff --git a/src/input/event.c b/src/input/event.c
index 4e5aeb5..e33bd4a 100644
--- a/src/input/event.c
+++ b/src/input/event.c
@@ -156,6 +156,16 @@ void input_SendEventState( input_thread_t *p_input, int i_state )
     vlc_event_send( &p_input->p->event_manager, &event );
 }
 
+void input_SendEventCache( input_thread_t *p_input, double f_level )
+{
+    vlc_value_t val;
+
+    val.f_float = f_level;
+	var_Change( p_input, "cache", VLC_VAR_SETVALUE, &val, NULL );
+
+    Trigger( p_input, INPUT_EVENT_CACHE );
+}
+
 /* FIXME: review them because vlc_event_send might be
  * moved inside input_item* functions.
  */
diff --git a/src/input/event.h b/src/input/event.h
index e86199a..a86a75f 100644
--- a/src/input/event.h
+++ b/src/input/event.h
@@ -43,6 +43,7 @@ void input_SendEventTitle( input_thread_t *p_input, int i_title );
 void input_SendEventSeekpoint( input_thread_t *p_input, int i_title, int i_seekpoint );
 void input_SendEventSignal( input_thread_t *p_input, double f_quality, double f_strength );
 void input_SendEventState( input_thread_t *p_input, int i_state );
+void input_SendEventCache( input_thread_t *p_input, double f_level );
 
 /* TODO rename Item* */
 void input_SendEventMeta( input_thread_t *p_input );
diff --git a/src/input/input.c b/src/input/input.c
index adbd75d..3848cd5 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1178,6 +1178,7 @@ static int Init( input_thread_t * p_input )
 
     /* */
     input_ChangeState( p_input, OPENING_S );
+    input_SendEventCache( p_input, 0.0 );
 
     /* */
     if( InputSourceInit( p_input, &p_input->p->input,
diff --git a/src/input/var.c b/src/input/var.c
index 0d0c12b..35b638e 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -485,6 +485,9 @@ void input_ConfigVarInit ( input_thread_t *p_input )
     var_Create( p_input, "signal-strength", VLC_VAR_FLOAT );
     var_SetFloat( p_input, "signal-strength", -1 );
 
+    var_Create( p_input, "cache", VLC_VAR_FLOAT );
+    var_SetFloat( p_input, "cache", 0.0 );
+
     /* */
     var_Create( p_input, "access-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
     var_Create( p_input, "access", VLC_VAR_STRING | VLC_VAR_DOINHERIT );




More information about the vlc-devel mailing list