Commit aa8683fd authored by François Cartegnie's avatar François Cartegnie 🤞

epg: API changes

EIT structs and Events and should be referenced by their
unique ID.
First step towards in depth changes to epg_t et epg_event_t.
parent 3924bed4
...@@ -31,8 +31,9 @@ ...@@ -31,8 +31,9 @@
typedef struct typedef struct
{ {
int64_t i_start; /* Interpreted as a value return by time() */ int64_t i_start; /* Interpreted as a value return by time() */
int i_duration; /* Duration of the event in second */ uint32_t i_duration; /* Duration of the event in second */
uint16_t i_id; /* Unique event id withing the event set */
char *psz_name; char *psz_name;
char *psz_short_description; char *psz_short_description;
...@@ -44,43 +45,60 @@ typedef struct ...@@ -44,43 +45,60 @@ typedef struct
typedef struct typedef struct
{ {
char *psz_name; char *psz_name;
vlc_epg_event_t *p_current; /* Can be null or should be the same than one of pp_event entry */ vlc_epg_event_t *p_current; /* Can be null or should be the same than one of pp_event entry */
uint32_t i_id; /* Unique identifier for this table / events (partial sets) */
uint16_t i_source_id;/* Channel / Program reference id this epg relates to */
int i_event; size_t i_event;
vlc_epg_event_t **pp_event; vlc_epg_event_t **pp_event;
} vlc_epg_t; } vlc_epg_t;
/** /**
* It initializes a vlc_epg_t. * Creates a new vlc_epg_event_t*
* *
* You must call vlc_epg_Clean to release the associated resource. * You must call vlc_epg_event_Delete to release the associated resources.
*
* \p i_id is the event unique id
* \p i_start start in epoch time
* \p i_duration event duration in seconds
*/ */
VLC_API void vlc_epg_Init(vlc_epg_t *p_epg, const char *psz_name); VLC_API vlc_epg_event_t * vlc_epg_event_New(uint16_t i_id,
int64_t i_start, uint32_t i_duration);
/** /**
* It releases all resources associated to a vlc_epg_t * Releases a vlc_epg_event_t*.
*/ */
VLC_API void vlc_epg_Clean(vlc_epg_t *p_epg); VLC_API void vlc_epg_event_Delete(vlc_epg_event_t *p_event);
/** /**
* It creates and appends a new vlc_epg_event_t to a vlc_epg_t. * Returns a vlc_epg_event_t * duplicated from \p p_src.
* *
* \see vlc_epg_t for the definitions of the parameters.
*/ */
VLC_API void vlc_epg_AddEvent(vlc_epg_t *p_epg, int64_t i_start, int i_duration, const char *psz_name, const char *psz_short_description, const char *psz_description, uint8_t i_rating ); VLC_API vlc_epg_event_t * vlc_epg_event_Duplicate(const vlc_epg_event_t *p_src);
/** /**
* It creates a new vlc_epg_t* * It creates a new vlc_epg_t*
* *
* You must call vlc_epg_Delete to release the associated resource. * You must call vlc_epg_Delete to release the associated resource.
*
* \p i_id is computed unique id depending on standard (table id, eit number)
* \p i_source_id is the associated program number
*/ */
VLC_API vlc_epg_t * vlc_epg_New(const char *psz_name) VLC_USED; VLC_API vlc_epg_t * vlc_epg_New(uint32_t i_id, uint16_t i_source_id);
/** /**
* It releases a vlc_epg_t*. * It releases a vlc_epg_t*.
*/ */
VLC_API void vlc_epg_Delete(vlc_epg_t *p_epg); VLC_API void vlc_epg_Delete(vlc_epg_t *p_epg);
/**
* It appends a new vlc_epg_event_t to a vlc_epg_t.
* Takes ownership of \p p_evt or returns false
*
* \p p_evt a vlc_epg_event_t * created with vlc_epg_event_New.
*/
VLC_API bool vlc_epg_AddEvent(vlc_epg_t *p_epg, vlc_epg_event_t *p_evt);
/** /**
* It set the current event of a vlc_epg_t given a start time * It set the current event of a vlc_epg_t given a start time
*/ */
...@@ -89,9 +107,14 @@ VLC_API void vlc_epg_SetCurrent(vlc_epg_t *p_epg, int64_t i_start); ...@@ -89,9 +107,14 @@ VLC_API void vlc_epg_SetCurrent(vlc_epg_t *p_epg, int64_t i_start);
/** /**
* It merges all the event of \p p_src and \p p_dst into \p p_dst. * It merges all the event of \p p_src and \p p_dst into \p p_dst.
* *
* \p p_src is not modified.
*/ */
VLC_API void vlc_epg_Merge(vlc_epg_t *p_dst, const vlc_epg_t *p_src); VLC_API void vlc_epg_Merge(vlc_epg_t *p_dst, const vlc_epg_t *p_src);
/**
* Returns a duplicated \p p_src and its associated events.
*
*/
VLC_API vlc_epg_t * vlc_epg_Duplicate(const vlc_epg_t *p_src);
#endif #endif
...@@ -188,8 +188,8 @@ enum vlc_module_properties ...@@ -188,8 +188,8 @@ enum vlc_module_properties
/** /**
* Current plugin ABI version * Current plugin ABI version
*/ */
# define MODULE_SYMBOL 3_0_0b # define MODULE_SYMBOL 3_0_0c
# define MODULE_SUFFIX "__3_0_0b" # define MODULE_SUFFIX "__3_0_0c"
/***************************************************************************** /*****************************************************************************
* Add a few defines. You do not want to read this section. Really. * Add a few defines. You do not want to read this section. Really.
......
...@@ -55,6 +55,17 @@ ...@@ -55,6 +55,17 @@
#include <assert.h> #include <assert.h>
static inline char *grab_notempty( char **ppsz )
{
char *psz_ret = NULL;
if( *ppsz && **ppsz )
{
psz_ret = *ppsz;
*ppsz = NULL;
}
return psz_ret;
}
/* /*
* Decoders activation order due to dependencies, * Decoders activation order due to dependencies,
* and because callbacks will be fired once per MGT/VCT version * and because callbacks will be fired once per MGT/VCT version
...@@ -368,8 +379,15 @@ static time_t ATSC_AddVLCEPGEvent( demux_t *p_demux, ts_psip_context_t *p_basect ...@@ -368,8 +379,15 @@ static time_t ATSC_AddVLCEPGEvent( demux_t *p_demux, ts_psip_context_t *p_basect
msg_Dbg( p_demux, "EIT Event time %ld +%d %s id 0x%x", msg_Dbg( p_demux, "EIT Event time %ld +%d %s id 0x%x",
i_start, p_evt->i_length_seconds, psz_title, p_evt->i_event_id ); i_start, p_evt->i_length_seconds, psz_title, p_evt->i_event_id );
#endif #endif
vlc_epg_AddEvent( p_epg, i_start, p_evt->i_length_seconds, vlc_epg_event_t *p_epgevt = vlc_epg_event_New( p_evt->i_event_id, i_start, p_evt->i_length_seconds );
psz_title, psz_shortdesc_text, psz_longdesc_text, 0 ); if( p_epgevt )
{
p_epgevt->psz_name = grab_notempty( &psz_title );
p_epgevt->psz_short_description = grab_notempty( &psz_shortdesc_text );
p_epgevt->psz_description = grab_notempty( &psz_longdesc_text );
if( !vlc_epg_AddEvent( p_epg, p_epgevt ) )
vlc_epg_event_Delete( p_epgevt );
}
} }
free( psz_title ); free( psz_title );
...@@ -417,7 +435,8 @@ static void ATSC_EIT_Callback( void *p_pid, dvbpsi_atsc_eit_t* p_eit ) ...@@ -417,7 +435,8 @@ static void ATSC_EIT_Callback( void *p_pid, dvbpsi_atsc_eit_t* p_eit )
EIT_DEBUG_TIMESHIFT( i_current_time ); EIT_DEBUG_TIMESHIFT( i_current_time );
vlc_epg_t *p_epg = vlc_epg_New( NULL ); vlc_epg_t *p_epg = vlc_epg_New( p_basectx->i_tabletype - ATSC_TABLE_TYPE_EIT_0,
i_program_number );
if( !p_epg ) if( !p_epg )
{ {
dvbpsi_atsc_DeleteEIT( p_eit ); dvbpsi_atsc_DeleteEIT( p_eit );
...@@ -510,7 +529,8 @@ static void ATSC_ETT_Callback( void *p_pid, dvbpsi_atsc_ett_t *p_ett ) ...@@ -510,7 +529,8 @@ static void ATSC_ETT_Callback( void *p_pid, dvbpsi_atsc_ett_t *p_ett )
#ifdef ATSC_DEBUG_EIT #ifdef ATSC_DEBUG_EIT
msg_Dbg( p_demux, "Should update EIT %x (matched EIT)", p_event->i_event_id ); msg_Dbg( p_demux, "Should update EIT %x (matched EIT)", p_event->i_event_id );
#endif #endif
vlc_epg_t *p_epg = vlc_epg_New( NULL ); vlc_epg_t *p_epg = vlc_epg_New( p_basectx->i_tabletype - ATSC_TABLE_TYPE_ETT_0,
i_program_number );
if( likely(p_epg) ) if( likely(p_epg) )
{ {
(void) (void)
......
...@@ -62,6 +62,17 @@ ...@@ -62,6 +62,17 @@
} while(0); } while(0);
#endif #endif
static inline char *grab_notempty( char **ppsz )
{
char *psz_ret = NULL;
if( *ppsz && **ppsz )
{
psz_ret = *ppsz;
*ppsz = NULL;
}
return psz_ret;
}
static void SINewTableCallBack( dvbpsi_t *h, uint8_t i_table_id, static void SINewTableCallBack( dvbpsi_t *h, uint8_t i_table_id,
uint16_t i_extension, void *p_pid_cbdata ); uint16_t i_extension, void *p_pid_cbdata );
...@@ -383,7 +394,7 @@ static void EITCallBack( demux_t *p_demux, dvbpsi_eit_t *p_eit ) ...@@ -383,7 +394,7 @@ static void EITCallBack( demux_t *p_demux, dvbpsi_eit_t *p_eit )
p_eit->i_ts_id, p_eit->i_network_id, p_eit->i_ts_id, p_eit->i_network_id,
p_eit->i_segment_last_section_number, p_eit->i_last_table_id ); p_eit->i_segment_last_section_number, p_eit->i_last_table_id );
p_epg = vlc_epg_New( NULL ); p_epg = vlc_epg_New( p_eit->i_table_id, p_eit->i_extension );
for( p_evt = p_eit->p_first_event; p_evt; p_evt = p_evt->p_next ) for( p_evt = p_eit->p_first_event; p_evt; p_evt = p_evt->p_next )
{ {
dvbpsi_descriptor_t *p_dr; dvbpsi_descriptor_t *p_dr;
...@@ -548,14 +559,21 @@ static void EITCallBack( demux_t *p_demux, dvbpsi_eit_t *p_eit ) ...@@ -548,14 +559,21 @@ static void EITCallBack( demux_t *p_demux, dvbpsi_eit_t *p_eit )
/* */ /* */
if( i_start > 0 ) if( i_start > 0 )
{ {
vlc_epg_AddEvent( p_epg, i_start, i_duration, vlc_epg_event_t *p_epgevt = vlc_epg_event_New( p_evt->i_event_id,
(psz_name && *psz_name) ? psz_name : NULL, i_start, i_duration );
(psz_text && *psz_text) ? psz_text : NULL, if( p_epgevt )
(psz_extra && *psz_extra) ? psz_extra : NULL, i_min_age ); {
p_epgevt->psz_name = grab_notempty( &psz_name );
/* Update "now playing" field */ p_epgevt->psz_short_description = grab_notempty( &psz_text );
if( b_current_event ) p_epgevt->psz_description = grab_notempty( &psz_extra );
vlc_epg_SetCurrent( p_epg, i_start ); p_epgevt->i_rating = i_min_age;
if( !vlc_epg_AddEvent( p_epg, p_epgevt ) )
vlc_epg_event_Delete( p_epgevt );
/* Update "now playing" field */
if( b_current_event )
vlc_epg_SetCurrent( p_epg, i_start );
}
} }
free( psz_name ); free( psz_name );
......
...@@ -1430,7 +1430,6 @@ static void DemuxDecodeXds( demux_t *p_demux, uint8_t d1, uint8_t d2 ) ...@@ -1430,7 +1430,6 @@ static void DemuxDecodeXds( demux_t *p_demux, uint8_t d1, uint8_t d2 )
{ {
xds_meta_t *m = &p_sys->xds.meta; xds_meta_t *m = &p_sys->xds.meta;
vlc_meta_t *p_meta; vlc_meta_t *p_meta;
vlc_epg_t *p_epg;
/* Channel meta data */ /* Channel meta data */
p_meta = vlc_meta_New(); p_meta = vlc_meta_New();
...@@ -1444,20 +1443,32 @@ static void DemuxDecodeXds( demux_t *p_demux, uint8_t d1, uint8_t d2 ) ...@@ -1444,20 +1443,32 @@ static void DemuxDecodeXds( demux_t *p_demux, uint8_t d1, uint8_t d2 )
vlc_meta_Delete( p_meta ); vlc_meta_Delete( p_meta );
/* Event meta data (current/future) */ /* Event meta data (current/future) */
p_epg = vlc_epg_New( NULL );
if( m->current.psz_name ) if( m->current.psz_name )
{ {
vlc_epg_AddEvent( p_epg, 0, 0, m->current.psz_name, NULL, NULL, 0 ); vlc_epg_t *p_epg = vlc_epg_New( TY_ES_GROUP, TY_ES_GROUP );
//if( m->current.psz_rating ) if ( p_epg )
// TODO but VLC cannot yet handle rating per epg event {
vlc_epg_SetCurrent( p_epg, 0 ); vlc_epg_event_t *p_evt = vlc_epg_event_New( 0, 0, 0 );
} if ( p_evt )
if( m->future.psz_name ) {
{ if( m->current.psz_name )
p_evt->psz_name = strdup( m->current.psz_name );
if( !vlc_epg_AddEvent( p_epg, p_evt ) )
vlc_epg_event_Delete( p_evt );
}
//if( m->current.psz_rating )
// TODO but VLC cannot yet handle rating per epg event
vlc_epg_SetCurrent( p_epg, 0 );
if( m->future.psz_name )
{
}
if( p_epg->i_event > 0 )
es_out_Control( p_demux->out, ES_OUT_SET_GROUP_EPG,
TY_ES_GROUP, p_epg );
vlc_epg_Delete( p_epg );
}
} }
if( p_epg->i_event > 0 )
es_out_Control( p_demux->out, ES_OUT_SET_GROUP_EPG, TY_ES_GROUP, p_epg );
vlc_epg_Delete( p_epg );
} }
p_demux->p_sys->xds.b_meta_changed = false; p_demux->p_sys->xds.b_meta_changed = false;
} }
......
...@@ -1426,21 +1426,9 @@ static int CmdInitControl( ts_cmd_t *p_cmd, int i_query, va_list args, bool b_co ...@@ -1426,21 +1426,9 @@ static int CmdInitControl( ts_cmd_t *p_cmd, int i_query, va_list args, bool b_co
if( b_copy ) if( b_copy )
{ {
p_cmd->u.control.u.int_epg.p_epg = vlc_epg_New( p_epg->psz_name ); p_cmd->u.control.u.int_epg.p_epg = vlc_epg_Duplicate( p_epg );
if( !p_cmd->u.control.u.int_epg.p_epg ) if( !p_cmd->u.control.u.int_epg.p_epg )
return VLC_EGENERIC; return VLC_EGENERIC;
for( int i = 0; i < p_epg->i_event; i++ )
{
vlc_epg_event_t *p_evt = p_epg->pp_event[i];
vlc_epg_AddEvent( p_cmd->u.control.u.int_epg.p_epg,
p_evt->i_start, p_evt->i_duration,
p_evt->psz_name,
p_evt->psz_short_description,
p_evt->psz_description, 0 );
}
vlc_epg_SetCurrent( p_cmd->u.control.u.int_epg.p_epg,
p_epg->p_current ? p_epg->p_current->i_start : -1 );
} }
else else
{ {
......
...@@ -906,26 +906,24 @@ void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_update ) ...@@ -906,26 +906,24 @@ void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_update )
vlc_epg_t *p_epg = NULL; vlc_epg_t *p_epg = NULL;
for( int i = 0; i < p_item->i_epg; i++ ) for( int i = 0; i < p_item->i_epg; i++ )
{ {
vlc_epg_t *p_tmp = p_item->pp_epg[i]; if( p_item->pp_epg[i]->i_source_id == p_update->i_source_id )
{
if( (p_tmp->psz_name == NULL) != (p_update->psz_name == NULL) ) p_epg = p_item->pp_epg[i];
continue; break;
if( p_tmp->psz_name && p_update->psz_name && strcmp(p_tmp->psz_name, p_update->psz_name) ) }
continue;
p_epg = p_tmp;
break;
} }
/* */ /* */
if( !p_epg ) if( !p_epg )
{ {
p_epg = vlc_epg_New( p_update->psz_name ); p_epg = vlc_epg_Duplicate( p_update );
if( p_epg ) if( p_epg )
TAB_APPEND( p_item->i_epg, p_item->pp_epg, p_epg ); TAB_APPEND( p_item->i_epg, p_item->pp_epg, p_epg );
} }
if( p_epg ) else
{
vlc_epg_Merge( p_epg, p_update ); vlc_epg_Merge( p_epg, p_update );
}
vlc_mutex_unlock( &p_item->lock ); vlc_mutex_unlock( &p_item->lock );
...@@ -940,7 +938,7 @@ void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_update ) ...@@ -940,7 +938,7 @@ void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_update )
input_item_DelInfo( p_item, psz_epg, NULL ); input_item_DelInfo( p_item, psz_epg, NULL );
vlc_mutex_lock( &p_item->lock ); vlc_mutex_lock( &p_item->lock );
for( int i = 0; i < p_epg->i_event; i++ ) for( size_t i = 0; i < p_epg->i_event; i++ )
{ {
const vlc_epg_event_t *p_evt = p_epg->pp_event[i]; const vlc_epg_event_t *p_evt = p_epg->pp_event[i];
time_t t_start = (time_t)p_evt->i_start; time_t t_start = (time_t)p_evt->i_start;
......
...@@ -682,10 +682,12 @@ vlc_timer_getoverrun ...@@ -682,10 +682,12 @@ vlc_timer_getoverrun
vlc_timer_schedule vlc_timer_schedule
vlc_towc vlc_towc
vlc_ureduce vlc_ureduce
vlc_epg_Init vlc_epg_event_Delete
vlc_epg_Clean vlc_epg_event_Duplicate
vlc_epg_event_New
vlc_epg_New vlc_epg_New
vlc_epg_Delete vlc_epg_Delete
vlc_epg_Duplicate
vlc_epg_AddEvent vlc_epg_AddEvent
vlc_epg_SetCurrent vlc_epg_SetCurrent
vlc_epg_Merge vlc_epg_Merge
......
...@@ -32,89 +32,100 @@ ...@@ -32,89 +32,100 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_epg.h> #include <vlc_epg.h>
static void vlc_epg_Event_Delete( vlc_epg_event_t *p_evt ) static void vlc_epg_event_Clean(vlc_epg_event_t *p_event)
{ {
free( p_evt->psz_name ); free(p_event->psz_description);
free( p_evt->psz_short_description ); free(p_event->psz_short_description);
free( p_evt->psz_description ); free(p_event->psz_name);
free( p_evt );
} }
static vlc_epg_event_t * vlc_epg_Event_New( int64_t i_start, int i_duration, void vlc_epg_event_Delete(vlc_epg_event_t *p_event)
const char *psz_name, const char *psz_short_description,
const char *psz_description, uint8_t i_rating )
{ {
vlc_epg_event_t *p_evt = malloc( sizeof(*p_evt) ); vlc_epg_event_Clean(p_event);
free(p_event);
}
static void vlc_epg_event_Init(vlc_epg_event_t *p_event, uint16_t i_id,
int64_t i_start, uint32_t i_duration)
{
memset(p_event, 0, sizeof(*p_event));
p_event->i_start = i_start;
p_event->i_id = i_id;
p_event->i_duration = i_duration;
}
vlc_epg_event_t * vlc_epg_event_New(uint16_t i_id,
int64_t i_start, uint32_t i_duration)
{
vlc_epg_event_t *p_event = (vlc_epg_event_t *) malloc(sizeof(*p_event));
if(p_event)
vlc_epg_event_Init(p_event, i_id, i_start, i_duration);
return p_event;
}
vlc_epg_event_t * vlc_epg_event_Duplicate( const vlc_epg_event_t *p_src )
{
vlc_epg_event_t *p_evt = vlc_epg_event_New( p_src->i_id, p_src->i_start,
p_src->i_duration );
if( likely(p_evt) ) if( likely(p_evt) )
{ {
p_evt->i_start = i_start; if( p_src->psz_description )
p_evt->i_duration = i_duration; p_evt->psz_description = strdup( p_src->psz_description );
p_evt->psz_name = psz_name ? strdup( psz_name ) : NULL; if( p_src->psz_name )
p_evt->psz_short_description = psz_short_description ? strdup( psz_short_description ) : NULL; p_evt->psz_name = strdup( p_src->psz_name );
p_evt->psz_description = psz_description ? strdup( psz_description ) : NULL; if( p_src->psz_short_description )
p_evt->i_rating = i_rating; p_evt->psz_short_description = strdup( p_src->psz_short_description );
p_evt->i_rating = p_src->i_rating;
} }
return p_evt; return p_evt;
} }
static inline vlc_epg_event_t * vlc_epg_Event_Duplicate( const vlc_epg_event_t *p_evt ) static void vlc_epg_Init( vlc_epg_t *p_epg, uint32_t i_id, uint16_t i_source_id )
{ {
return vlc_epg_Event_New( p_evt->i_start, p_evt->i_duration, p_epg->i_id = i_id;
p_evt->psz_name, p_evt->psz_short_description, p_epg->i_source_id = i_source_id;
p_evt->psz_description, p_evt->i_rating ); p_epg->psz_name = NULL;
}
void vlc_epg_Init( vlc_epg_t *p_epg, const char *psz_name )
{
p_epg->psz_name = psz_name ? strdup( psz_name ) : NULL;
p_epg->p_current = NULL; p_epg->p_current = NULL;
TAB_INIT( p_epg->i_event, p_epg->pp_event ); TAB_INIT( p_epg->i_event, p_epg->pp_event );
} }
void vlc_epg_Clean( vlc_epg_t *p_epg ) static void vlc_epg_Clean( vlc_epg_t *p_epg )
{ {
int i; size_t i;
for( i = 0; i < p_epg->i_event; i++ ) for( i = 0; i < p_epg->i_event; i++ )
vlc_epg_Event_Delete( p_epg->pp_event[i] ); vlc_epg_event_Delete( p_epg->pp_event[i] );
TAB_CLEAN( p_epg->i_event, p_epg->pp_event ); TAB_CLEAN( p_epg->i_event, p_epg->pp_event );
free( p_epg->psz_name ); free( p_epg->psz_name );
} }
void vlc_epg_AddEvent( vlc_epg_t *p_epg, int64_t i_start, int i_duration, bool vlc_epg_AddEvent( vlc_epg_t *p_epg, vlc_epg_event_t *p_evt )
const char *psz_name, const char *psz_short_description,
const char *psz_description, uint8_t i_rating )
{ {
vlc_epg_event_t *p_evt = vlc_epg_Event_New( i_start, i_duration, ssize_t i_pos = -1;
psz_name, psz_short_description,
psz_description, i_rating );
if( unlikely(!p_evt) )
return;
int i_pos = -1;
/* Insertions are supposed in sequential order first */ /* Insertions are supposed in sequential order first */
if( p_epg->i_event ) if( p_epg->i_event )
{ {
if( p_epg->pp_event[0]->i_start > i_start ) if( p_epg->pp_event[0]->i_start > p_evt->i_start )
{ {
i_pos = 0; i_pos = 0;
} }
else if ( p_epg->pp_event[p_epg->i_event - 1]->i_start >= i_start ) else if ( p_epg->pp_event[p_epg->i_event - 1]->i_start >= p_evt->i_start )
{ {
/* Do bisect search lower start time entry */ /* Do bisect search lower start time entry */
int i_lower = 0; size_t i_lower = 0;
int i_upper = p_epg->i_event - 1; size_t i_upper = p_epg->i_event - 1;
while( i_lower < i_upper ) while( i_lower < i_upper )
{ {
int i_split = ( (size_t)i_lower + i_upper ) / 2; size_t i_split = ( i_lower + i_upper ) / 2;
vlc_epg_event_t *p_cur = p_epg->pp_event[i_split]; vlc_epg_event_t *p_cur = p_epg->pp_event[i_split];
if( p_cur->i_start < i_start ) if( p_cur->i_start < p_evt->i_start )
{ {
i_lower = i_split + 1; i_lower = i_split + 1;
} }
else if ( p_cur->i_start >= i_start ) else if ( p_cur->i_start >= p_evt->i_start )
{ {
i_upper = i_split; i_upper = i_split;
} }
...@@ -125,13 +136,14 @@ void vlc_epg_AddEvent( vlc_epg_t *p_epg, int64_t i_start, int i_duration, ...@@ -125,13 +136,14 @@ void vlc_epg_AddEvent( vlc_epg_t *p_epg, int64_t i_start, int i_duration,