Commit a77fa520 authored by Gildas Bazin's avatar Gildas Bazin

* src/input: update ES object vars when an ES is removed + some coding style changes.

parent bff75d2c
......@@ -245,7 +245,8 @@ void input_EsOutSetDelay( es_out_t *out, int i_cat, int64_t i_delay )
/*****************************************************************************
*
*****************************************************************************/
static void EsOutESVarUpdate( es_out_t *out, es_out_id_t *es )
static void EsOutESVarUpdate( es_out_t *out, es_out_id_t *es,
vlc_bool_t b_delete )
{
es_out_sys_t *p_sys = out->p_sys;
input_thread_t *p_input = p_sys->p_input;
......@@ -262,6 +263,14 @@ static void EsOutESVarUpdate( es_out_t *out, es_out_id_t *es )
else
return;
if( b_delete )
{
val.i_int = es->i_id;
var_Change( p_input, psz_var, VLC_VAR_DELCHOICE, &val, NULL );
var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );
return;
}
/* Get the number of ES already added */
var_Change( p_input, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
if( val.i_int == 0 )
......@@ -342,7 +351,7 @@ static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )
var_Change( p_input, "spu-es", VLC_VAR_CLEARCHOICES, NULL, NULL );
for( i = 0; i < p_sys->i_es; i++ )
{
EsOutESVarUpdate( out, p_sys->es[i] );
EsOutESVarUpdate( out, p_sys->es[i], VLC_FALSE );
EsOutSelect( out, p_sys->es[i], VLC_FALSE );
}
......@@ -448,7 +457,7 @@ static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt )
es->p_dec = NULL;
if( es->p_pgrm == p_sys->p_pgrm )
EsOutESVarUpdate( out, es );
EsOutESVarUpdate( out, es, VLC_FALSE );
#if 0
/* Add stream info */
......@@ -555,18 +564,22 @@ static void EsSelect( es_out_t *out, es_out_id_t *es )
if( es->fmt.i_cat == VIDEO_ES || es->fmt.i_cat == SPU_ES )
{
if( !var_GetBool( p_input, "video" ) || ( p_input->p_sout && !var_GetBool( p_input, "sout-video" ) ) )
if( !var_GetBool( p_input, "video" ) ||
( p_input->p_sout && !var_GetBool( p_input, "sout-video" ) ) )
{
msg_Dbg( p_input, "video is disabled, not selecting ES 0x%x", es->i_id );
msg_Dbg( p_input, "video is disabled, not selecting ES 0x%x",
es->i_id );
return;
}
}
else if( es->fmt.i_cat == AUDIO_ES )
{
var_Get( p_input, "audio", &val );
if( !var_GetBool( p_input, "audio" ) || ( p_input->p_sout && !var_GetBool( p_input, "sout-audio" ) ) )
if( !var_GetBool( p_input, "audio" ) ||
( p_input->p_sout && !var_GetBool( p_input, "sout-audio" ) ) )
{
msg_Dbg( p_input, "audio is disabled, not selecting ES 0x%x", es->i_id );
msg_Dbg( p_input, "audio is disabled, not selecting ES 0x%x",
es->i_id );
return;
}
}
......@@ -785,12 +798,16 @@ static void EsOutDel( es_out_t *out, es_out_id_t *es )
if( es->p_dec )
EsUnselect( out, es, es->p_pgrm == p_sys->p_pgrm );
if( es->p_pgrm == p_sys->p_pgrm )
EsOutESVarUpdate( out, es, VLC_TRUE );
TAB_REMOVE( p_sys->i_es, p_sys->es, es );
es->p_pgrm->i_es--;
if( es->p_pgrm->i_es == 0 )
{
msg_Err( p_sys->p_input, "Program doesn't have es anymore, clenaing TODO ?" );
msg_Err( p_sys->p_input, "Program doesn't contain anymore ES, "
"TODO cleaning ?" );
}
if( p_sys->p_es_audio == es ) p_sys->p_es_audio = NULL;
......@@ -885,7 +902,8 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
{
if( p_sys->es[i]->p_dec )
{
EsUnselect( out, p_sys->es[i], p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
EsUnselect( out, p_sys->es[i],
p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
}
}
for( i = 0; i < p_sys->i_es; i++ )
......@@ -917,24 +935,30 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
{
for( i = 0; i < p_sys->i_es; i++ )
{
if( p_sys->es[i]->p_dec && p_sys->es[i]->fmt.i_cat == AUDIO_ES )
EsUnselect( out, p_sys->es[i], p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
if( p_sys->es[i]->p_dec &&
p_sys->es[i]->fmt.i_cat == AUDIO_ES )
EsUnselect( out, p_sys->es[i],
p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
}
}
else if( es == (es_out_id_t*)((uint8_t*)NULL+VIDEO_ES) )
{
for( i = 0; i < p_sys->i_es; i++ )
{
if( p_sys->es[i]->p_dec && p_sys->es[i]->fmt.i_cat == VIDEO_ES )
EsUnselect( out, p_sys->es[i], p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
if( p_sys->es[i]->p_dec &&
p_sys->es[i]->fmt.i_cat == VIDEO_ES )
EsUnselect( out, p_sys->es[i],
p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
}
}
else if( es == (es_out_id_t*)((uint8_t*)NULL+SPU_ES) )
{
for( i = 0; i < p_sys->i_es; i++ )
{
if( p_sys->es[i]->p_dec && p_sys->es[i]->fmt.i_cat == SPU_ES )
EsUnselect( out, p_sys->es[i], p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
if( p_sys->es[i]->p_dec &&
p_sys->es[i]->fmt.i_cat == SPU_ES )
EsUnselect( out, p_sys->es[i],
p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
}
}
else
......@@ -980,7 +1004,8 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
i_pcr = (int64_t)va_arg( args, int64_t );
/* search program */
/* 11 is a vodoo trick to avoid non_pcr*9/100 to be null */
input_ClockSetPCR( p_sys->p_input, &p_pgrm->clock, (i_pcr + 11 ) * 9 / 100);
input_ClockSetPCR( p_sys->p_input, &p_pgrm->clock,
(i_pcr + 11 ) * 9 / 100);
return VLC_SUCCESS;
}
......
......@@ -47,8 +47,8 @@
#define STREAM_CACHE_SIZE (4*STREAM_CACHE_TRACK*1024*1024)
/* How many data we try to prebuffer */
#define STREAM_CACHE_PREBUFFER_SIZE (32767)
#define STREAM_CACHE_PREBUFFER_LENGTH (100*1000) /* Maximum time we take to pre-buffer */
/* Maximum time we take to pre-buffer */
#define STREAM_CACHE_PREBUFFER_LENGTH (100*1000)
/* Method1: Simple, for pf_block.
......@@ -106,7 +106,7 @@ struct stream_sys_t
/* Method 2: for pf_read */
struct
{
int i_offset; /* Buffer ofset in the current track */
int i_offset; /* Buffer offset in the current track */
int i_tk; /* Current track */
stream_track_t tk[STREAM_CACHE_TRACK];
......@@ -226,7 +226,8 @@ stream_t *stream_AccessNew( access_t *p_access )
p_sys->stream.i_tk = 0;
p_sys->stream.p_buffer = malloc( STREAM_CACHE_SIZE );
p_sys->stream.i_used = 0;
access2_Control( p_access, ACCESS_GET_MTU, &p_sys->stream.i_read_size );
access2_Control( p_access, ACCESS_GET_MTU,
&p_sys->stream.i_read_size );
if( p_sys->stream.i_read_size <= 0 )
p_sys->stream.i_read_size = STREAM_READ_ATONCE;
else if( p_sys->stream.i_read_size <= 256 )
......@@ -477,13 +478,16 @@ static int AStreamReadBlock( stream_t *s, void *p_read, int i_read )
while( i_data < i_read )
{
int i_current = p_sys->block.p_current->i_buffer - p_sys->block.i_offset;
int i_current =
p_sys->block.p_current->i_buffer - p_sys->block.i_offset;
int i_copy = __MIN( i_current, i_read - i_data);
/* Copy data */
if( p_data )
{
memcpy( p_data, &p_sys->block.p_current->p_buffer[p_sys->block.i_offset], i_copy );
memcpy( p_data,
&p_sys->block.p_current->p_buffer[p_sys->block.i_offset],
i_copy );
p_data += i_copy;
}
i_data += i_copy;
......@@ -536,7 +540,8 @@ static int AStreamPeekBlock( stream_t *s, uint8_t **pp_peek, int i_read )
}
/* Fill enough data */
while( p_sys->block.i_size - (p_sys->i_pos - p_sys->block.i_start) < i_read )
while( p_sys->block.i_size - (p_sys->i_pos - p_sys->block.i_start)
< i_read )
{
block_t **pp_last = p_sys->block.pp_last;
......@@ -785,8 +790,7 @@ static int AStreamReadStream( stream_t *s, void *p_read, int i_read )
uint8_t *p_data = (uint8_t *)p_read;
int i_data = 0;
if( tk->i_start >= tk->i_end )
return 0; /* EOF */
if( tk->i_start >= tk->i_end ) return 0; /* EOF */
#if 0
msg_Dbg( s, "AStreamReadStream: %d pos="I64Fd" tk=%d start="I64Fd
......@@ -1015,7 +1019,8 @@ static int AStreamRefillStream( stream_t *s )
stream_track_t *tk = &p_sys->stream.tk[p_sys->stream.i_tk];
/* We read but won't increase i_start after initial start + offset */
int i_toread = __MIN( p_sys->stream.i_used, STREAM_CACHE_TRACK_SIZE -
int i_toread =
__MIN( p_sys->stream.i_used, STREAM_CACHE_TRACK_SIZE -
(tk->i_end - tk->i_start - p_sys->stream.i_offset) );
int64_t i_start, i_stop;
......@@ -1058,7 +1063,6 @@ static int AStreamRefillStream( stream_t *s )
p_sys->stream.i_offset -= i_invalid;
}
i_toread -= i_read;
p_sys->stream.i_used -= i_read;
......@@ -1089,9 +1093,8 @@ static void AStreamPrebufferStream( stream_t *s )
int64_t i_date = mdate();
int i_read;
if( s->b_die ||
tk->i_end >= STREAM_CACHE_PREBUFFER_SIZE ||
( i_first > 0 && i_first + STREAM_CACHE_PREBUFFER_LENGTH < i_date ) )
if( s->b_die || tk->i_end >= STREAM_CACHE_PREBUFFER_SIZE ||
(i_first > 0 && i_first + STREAM_CACHE_PREBUFFER_LENGTH < i_date) )
{
int64_t i_byterate;
......@@ -1175,4 +1178,3 @@ char *stream_ReadLine( stream_t *s )
return p_line;
}
}
......@@ -277,7 +277,8 @@ void input_ControlVarNavigation( input_thread_t *p_input )
/* Add Navigation entries */
sprintf( val.psz_string, "title %2i", i );
var_Destroy( p_input, val.psz_string );
var_Create( p_input, val.psz_string, VLC_VAR_INTEGER|VLC_VAR_HASCHOICE|VLC_VAR_ISCOMMAND );
var_Create( p_input, val.psz_string,
VLC_VAR_INTEGER|VLC_VAR_HASCHOICE|VLC_VAR_ISCOMMAND );
var_AddCallback( p_input, val.psz_string, NavigationCallback, (void *)i );
if( p_input->title[i]->psz_name == NULL ||
......@@ -411,8 +412,9 @@ void input_ConfigVarInit ( input_thread_t *p_input )
/*****************************************************************************
* All Callbacks:
*****************************************************************************/
static int StateCallback ( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
static int StateCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void *p_data )
{
input_thread_t *p_input = (input_thread_t*)p_this;
......@@ -425,7 +427,7 @@ static int StateCallback ( vlc_object_t *p_this, char const *psz_cmd,
return VLC_EGENERIC;
}
static int RateCallback ( vlc_object_t *p_this, char const *psz_cmd,
static int RateCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
input_thread_t *p_input = (input_thread_t*)p_this;
......@@ -461,7 +463,8 @@ static int RateCallback ( vlc_object_t *p_this, char const *psz_cmd,
}
static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
vlc_value_t oldval, vlc_value_t newval,
void *p_data )
{
input_thread_t *p_input = (input_thread_t*)p_this;
vlc_value_t val, length;
......@@ -493,7 +496,7 @@ static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd,
}
static int TimeCallback ( vlc_object_t *p_this, char const *psz_cmd,
static int TimeCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
input_thread_t *p_input = (input_thread_t*)p_this;
......@@ -525,8 +528,9 @@ static int TimeCallback ( vlc_object_t *p_this, char const *psz_cmd,
return VLC_SUCCESS;
}
static int ProgramCallback ( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
static int ProgramCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void *p_data )
{
input_thread_t *p_input = (input_thread_t*)p_this;
......@@ -535,8 +539,9 @@ static int ProgramCallback ( vlc_object_t *p_this, char const *psz_cmd,
return VLC_SUCCESS;
}
static int TitleCallback ( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
static int TitleCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void *p_data )
{
input_thread_t *p_input = (input_thread_t*)p_this;
vlc_value_t val, count;
......@@ -567,7 +572,8 @@ static int TitleCallback ( vlc_object_t *p_this, char const *psz_cmd,
}
static int SeekpointCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
vlc_value_t oldval, vlc_value_t newval,
void *p_data )
{
input_thread_t *p_input = (input_thread_t*)p_this;
vlc_value_t val, count;
......@@ -598,7 +604,8 @@ static int SeekpointCallback( vlc_object_t *p_this, char const *psz_cmd,
}
static int NavigationCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
vlc_value_t oldval, vlc_value_t newval,
void *p_data )
{
input_thread_t *p_input = (input_thread_t*)p_this;
vlc_value_t val;
......@@ -617,7 +624,7 @@ static int NavigationCallback( vlc_object_t *p_this, char const *psz_cmd,
return VLC_SUCCESS;
}
static int ESCallback ( vlc_object_t *p_this, char const *psz_cmd,
static int ESCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
input_thread_t *p_input = (input_thread_t*)p_this;
......@@ -658,7 +665,8 @@ static int EsDelayCallback ( vlc_object_t *p_this, char const *psz_cmd,
}
static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
vlc_value_t oldval, vlc_value_t newval,
void *p_data )
{
input_thread_t *p_input = (input_thread_t*)p_this;
......@@ -666,4 +674,3 @@ static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd,
return VLC_SUCCESS;
}
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