Commit 2d98c228 authored by Laurent Aimar's avatar Laurent Aimar

Added a input "cache" variable and INPUT_EVENT_CACHE event.

They will allow interfaces to display the current buffering status.
parent b062d2a6
......@@ -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;
/** @}*/
......
......@@ -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) );
......
......@@ -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.
*/
......
......@@ -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 );
......
......@@ -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,
......
......@@ -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 );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment