(int)(mdate() - i_decoder_buffering_start)/1000 );
/* Here is a good place to destroy unused vout with every demuxer */
- input_ressource_TerminateVout( p_sys->p_input->p->p_ressource );
+ input_resource_TerminateVout( p_sys->p_input->p->p_resource );
/* */
const mtime_t i_wakeup_delay = 10*1000; /* FIXME CLEANUP thread wake up time*/
return VLC_SUCCESS;
}
+/* EsOutProgramFind
+ */
+static es_out_pgrm_t *EsOutProgramFind( es_out_t *p_out, int i_group )
+{
+ es_out_sys_t *p_sys = p_out->p_sys;
+
+ for( int i = 0; i < p_sys->i_pgrm; i++ )
+ {
+ if( p_sys->pgrm[i]->i_id == i_group )
+ return p_sys->pgrm[i];
+ }
+ return EsOutProgramAdd( p_out, i_group );
+}
+
/* EsOutProgramMeta:
*/
static char *EsOutProgramGetMetaName( es_out_pgrm_t *p_pgrm )
static void EsOutProgramMeta( es_out_t *out, int i_group, vlc_meta_t *p_meta )
{
es_out_sys_t *p_sys = out->p_sys;
- es_out_pgrm_t *p_pgrm = NULL;
+ es_out_pgrm_t *p_pgrm;
input_thread_t *p_input = p_sys->p_input;
char *psz_cat;
const char *psz_title = NULL;
return;
}
/* Find program */
- for( i = 0; i < p_sys->i_pgrm; i++ )
- {
- if( p_sys->pgrm[i]->i_id == i_group )
- {
- p_pgrm = p_sys->pgrm[i];
- break;
- }
- }
- if( p_pgrm == NULL )
- p_pgrm = EsOutProgramAdd( out, i_group ); /* Create it */
+ p_pgrm = EsOutProgramFind( out, i_group );
+ if( !p_pgrm )
+ return;
/* */
psz_title = vlc_meta_Get( p_meta, vlc_meta_Title);
}
}
/* Update current */
- vlc_epg_SetCurrent( p_dst, p_src->p_current ? p_src->p_current->i_start : -1 );
+ if( p_src->p_current )
+ vlc_epg_SetCurrent( p_dst, p_src->p_current->i_start );
/* Keep only 1 old event */
if( p_dst->p_current )
{
es_out_sys_t *p_sys = out->p_sys;
input_thread_t *p_input = p_sys->p_input;
- es_out_pgrm_t *p_pgrm = NULL;
+ es_out_pgrm_t *p_pgrm;
char *psz_cat;
int i;
/* Find program */
- for( i = 0; i < p_sys->i_pgrm; i++ )
- {
- if( p_sys->pgrm[i]->i_id == i_group )
- {
- p_pgrm = p_sys->pgrm[i];
- break;
- }
- }
- if( p_pgrm == NULL )
- p_pgrm = EsOutProgramAdd( out, i_group ); /* Create it */
+ p_pgrm = EsOutProgramFind( out, i_group );
+ if( !p_pgrm )
+ return;
/* Merge EPG */
if( !p_pgrm->p_epg )
localtime_r( &t_start, &tm_start );
- snprintf( psz_start, sizeof(psz_start), "%2.2d:%2.2d:%2.2d", tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec );
+ snprintf( psz_start, sizeof(psz_start), "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d",
+ 1900 + tm_start.tm_year, 1 + tm_start.tm_mon, tm_start.tm_mday,
+ tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec );
if( p_evt->psz_short_description || p_evt->psz_description )
input_Control( p_input, INPUT_ADD_INFO, psz_epg, psz_start, "%s (%2.2d:%2.2d) - %s",
p_evt->psz_name,
/* Update now playing */
free( p_pgrm->psz_now_playing );
p_pgrm->psz_now_playing = NULL;
- if( p_epg->p_current && p_epg->p_current->psz_name && *p_epg->p_current->psz_name )
- p_pgrm->psz_now_playing = strdup( p_epg->p_current->psz_name );
+ if( p_pgrm->p_epg->p_current && p_pgrm->p_epg->p_current->psz_name && *p_pgrm->p_epg->p_current->psz_name )
+ p_pgrm->psz_now_playing = strdup( p_pgrm->p_epg->p_current->psz_name );
if( p_pgrm == p_sys->p_pgrm )
{
return NULL;
}
- es_out_id_t *es = malloc( sizeof( *es ) );
- es_out_pgrm_t *p_pgrm = NULL;
+ es_out_id_t *es = malloc( sizeof( *es ) );
+ es_out_pgrm_t *p_pgrm;
int i;
if( !es )
vlc_mutex_lock( &p_sys->lock );
/* Search the program */
- for( i = 0; i < p_sys->i_pgrm; i++ )
- {
- if( fmt->i_group == p_sys->pgrm[i]->i_id )
- {
- p_pgrm = p_sys->pgrm[i];
- break;
- }
- }
- if( p_pgrm == NULL )
+ p_pgrm = EsOutProgramFind( out, fmt->i_group );
+ if( !p_pgrm )
{
- /* Create a new one */
- p_pgrm = EsOutProgramAdd( out, fmt->i_group );
+ vlc_mutex_unlock( &p_sys->lock );
+ free( es );
+ return NULL;
}
/* Increase ref count for program */
break;
}
if( i >= p_sys->i_es )
- input_ressource_TerminateVout( p_sys->p_input->p->p_ressource );
+ input_resource_TerminateVout( p_sys->p_input->p->p_resource );
}
p_sys->b_active = b;
return VLC_SUCCESS;
if( i_query == ES_OUT_SET_PCR )
{
p_pgrm = p_sys->p_pgrm;
+ if( !p_pgrm )
+ p_pgrm = EsOutProgramAdd( out, i_group ); /* Create it */
}
else
{
- int i;
i_group = (int)va_arg( args, int );
- for( i = 0; i < p_sys->i_pgrm; i++ )
- {
- if( p_sys->pgrm[i]->i_id == i_group )
- {
- p_pgrm = p_sys->pgrm[i];
- break;
- }
- }
+ p_pgrm = EsOutProgramFind( out, i_group );
}
- if( p_pgrm == NULL )
- p_pgrm = EsOutProgramAdd( out, i_group ); /* Create it */
+ if( !p_pgrm )
+ return VLC_EGENERIC;
i_pcr = (int64_t)va_arg( args, int64_t );
/* search program
/* Clean up vout after user action (in active mode only).
* FIXME it does not work well with multiple video windows */
if( p_sys->b_active )
- input_ressource_TerminateVout( p_sys->p_input->p->p_ressource );
+ input_resource_TerminateVout( p_sys->p_input->p->p_resource );
return i_ret;
}