]> git.sesse.net Git - vlc/commitdiff
Added a input "cache" variable and INPUT_EVENT_CACHE event.
authorLaurent Aimar <fenrir@videolan.org>
Thu, 4 Dec 2008 21:54:29 +0000 (22:54 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Thu, 4 Dec 2008 21:56:11 +0000 (22:56 +0100)
They will allow interfaces to display the current buffering status.

include/vlc_input.h
src/input/es_out.c
src/input/event.c
src/input/event.h
src/input/input.c
src/input/var.c

index 9bee57233e2f935b294d5ab030f98c95bf9ecf0a..85e0de14ab59f364106cb555f9cfaa929b6f932d 100644 (file)
@@ -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;
 
 /** @}*/
index 03bd35fdcef23769945cb2557893eecfdbca256e..2c676f98480e6445df8719c814515e8b3ab468f0 100644 (file)
@@ -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) );
index 4e5aeb596b160aa5ae13bf327c76c55184658fb7..e33bd4a5f4c8446a56d6fa4188cdc64cbbb66202 100644 (file)
@@ -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.
  */
index e86199acf0dcc3d26b7443fb7fee8b8ecb0905ef..a86a75fab92dd3a523a6fdc14c64a926da48470a 100644 (file)
@@ -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 );
index adbd75de0735369312566d96653e66b10ea2890c..3848cd57de860463776bc5d4a0a47b154921178b 100644 (file)
@@ -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,
index 0d0c12b8ba7352d421e9c0cea0c9ef6c6a070b34..35b638ece72f3d1c095b01c78b88fb79a92c1fff 100644 (file)
@@ -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 );