[vlc-commits] input: item: point to store current epg table

Francois Cartegnie git at videolan.org
Wed Dec 28 11:14:07 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Dec 27 14:41:41 2016 +0100| [e25885c16d2c6614bea41a0bceb942ce9d4db4bf] | committer: Francois Cartegnie

input: item: point to store current epg table

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e25885c16d2c6614bea41a0bceb942ce9d4db4bf
---

 include/vlc_input_item.h    |  1 +
 src/input/es_out.c          |  5 ++++-
 src/input/input_interface.h |  3 ++-
 src/input/item.c            | 30 ++++++++++++++++++++++++++----
 4 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index 30afb02..c8ab221 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -81,6 +81,7 @@ struct input_item_t
 
     int         i_epg;               /**< Number of EPG entries */
     vlc_epg_t   **pp_epg;            /**< EPG entries */
+    const vlc_epg_t *p_epg_table;    /** running/selected program cur/next EPG table */
 
     int         i_slaves;            /**< Number of slaves */
     input_item_slave_t **pp_slaves;  /**< Slave entries that will be loaded by
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 2efecd4..1fd8e6a 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -1054,6 +1054,9 @@ static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )
         EsOutSelect( out, p_sys->es[i], false );
     }
 
+    /* Ensure the correct running EPG table is selected */
+    input_item_ChangeEPGSource( input_priv(p_input)->p_item, p_pgrm->i_id );
+
     /* Update now playing */
     input_item_SetESNowPlaying( input_priv(p_input)->p_item,
                                 p_pgrm->p_meta ? vlc_meta_Get( p_pgrm->p_meta, vlc_meta_ESNowPlaying ) : NULL );
@@ -1359,7 +1362,7 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, const vlc_epg_t *p_epg
     epg = *p_epg;
     epg.psz_name = psz_cat;
 
-    input_item_SetEpg( p_item, &epg );
+    input_item_SetEpg( p_item, &epg, p_epg->i_source_id == p_pgrm->i_id );
     input_SendEventMetaEpg( p_sys->p_input );
 
     /* Update now playing */
diff --git a/src/input/input_interface.h b/src/input/input_interface.h
index f271439..e44893e 100644
--- a/src/input/input_interface.h
+++ b/src/input/input_interface.h
@@ -34,7 +34,8 @@ void input_item_SignalPreparseEnded( input_item_t *p_i, int new_status );
 void input_item_SetPreparsed( input_item_t *p_i, bool b_preparsed );
 void input_item_SetArtNotFound( input_item_t *p_i, bool b_not_found );
 void input_item_SetArtFetched( input_item_t *p_i, bool b_art_fetched );
-void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_epg );
+void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_epg, bool );
+void input_item_ChangeEPGSource( input_item_t *p_item, int i_source_id );
 void input_item_SetEpgEvent( input_item_t *p_item, const vlc_epg_event_t *p_epg_evt );
 void input_item_SetEpgOffline( input_item_t * );
 
diff --git a/src/input/item.c b/src/input/item.c
index 369a78d..d7eb159 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -933,7 +933,7 @@ void input_item_SetEpgEvent( input_item_t *p_item, const vlc_epg_event_t *p_epg_
 }
 
 //#define EPG_DEBUG
-void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_update )
+void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_update, bool b_current_source )
 {
     vlc_epg_t *p_epg = vlc_epg_Duplicate( p_update );
     if( !p_epg )
@@ -957,6 +957,8 @@ void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_update )
     if( pp_epg )
     {
         vlc_epg_Delete( *pp_epg );
+        if( *pp_epg == p_item->p_epg_table ) /* current table can have changed */
+            p_item->p_epg_table = NULL;
         *pp_epg = p_epg;
     }
     else
@@ -964,6 +966,9 @@ void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_update )
         TAB_APPEND( p_item->i_epg, p_item->pp_epg, p_epg );
     }
 
+    if( b_current_source && p_epg->b_present )
+        p_item->p_epg_table = p_epg;
+
     vlc_mutex_unlock( &p_item->lock );
 
     if( !p_epg )
@@ -1010,12 +1015,29 @@ signal:
     } while(0);
 }
 
-void input_item_SetEpgOffline( input_item_t *p_item )
+void input_item_ChangeEPGSource( input_item_t *p_item, int i_source_id )
 {
     vlc_mutex_lock( &p_item->lock );
-    for( int i = 0; i < p_item->i_epg; i++ )
-        vlc_epg_SetCurrent( p_item->pp_epg[i], -1 );
+    p_item->p_epg_table = NULL;
+    if( i_source_id > 0 )
+    {
+        /* Update pointer to current/next table in the full schedule */
+        for( int i = 0; i < p_item->i_epg; i++ )
+        {
+            if( p_item->pp_epg[i]->i_source_id == i_source_id &&
+                p_item->pp_epg[i]->b_present )
+            {
+                p_item->p_epg_table = p_item->pp_epg[i];
+                break;
+            }
+        }
+    }
     vlc_mutex_unlock( &p_item->lock );
+}
+
+void input_item_SetEpgOffline( input_item_t *p_item )
+{
+    input_item_ChangeEPGSource( p_item, -1 );
 
 #ifdef EPG_DEBUG
     vlc_mutex_lock( &p_item->lock );



More information about the vlc-commits mailing list