[vlc-commits] input: add VLC_INPUT_PROGRAM_UPDATED

Thomas Guillem git at videolan.org
Wed Oct 10 09:44:29 CEST 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Oct 10 09:43:36 2018 +0200| [cff39b31f3260c7bc830fa92c30648045e006d85] | committer: Thomas Guillem

input: add VLC_INPUT_PROGRAM_UPDATED

This avoids to destroy and recreate a program when the title changes.

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

 include/vlc_input.h |  1 +
 src/input/es_out.c  |  4 +---
 src/input/event.h   | 12 ++++++++++++
 src/input/var.c     |  5 +++++
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index 88d1da091f..8f6a7be472 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -429,6 +429,7 @@ struct vlc_input_event_program {
     enum {
         VLC_INPUT_PROGRAM_ADDED,
         VLC_INPUT_PROGRAM_DELETED,
+        VLC_INPUT_PROGRAM_UPDATED,
         VLC_INPUT_PROGRAM_SELECTED,
         VLC_INPUT_PROGRAM_SCRAMBLED,
     } action;
diff --git a/src/input/es_out.c b/src/input/es_out.c
index b215c3bce1..207520fa1b 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -1317,11 +1317,9 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, const vlc_meta_t *p_me
             psz_text = strdup( psz_title );
         }
 
-        /* ugly but it works */
         if( psz_text )
         {
-            input_SendEventProgramDel( p_input, i_group );
-            input_SendEventProgramAdd( p_input, i_group, psz_text );
+            input_SendEventProgramUpdated( p_input, i_group, psz_text );
             if( p_sys->p_pgrm == p_pgrm )
                 input_SendEventProgramSelect( p_input, i_group );
             free( psz_text );
diff --git a/src/input/event.h b/src/input/event.h
index 7b0b1ebcd3..99cc8f3faf 100644
--- a/src/input/event.h
+++ b/src/input/event.h
@@ -197,6 +197,18 @@ static inline void input_SendEventProgramAdd(input_thread_t *p_input,
         }
     });
 }
+static inline void input_SendEventProgramUpdated(input_thread_t *p_input,
+                                int i_program, const char *psz_text)
+{
+    input_SendEvent(p_input, &(struct vlc_input_event) {
+        .type = INPUT_EVENT_PROGRAM,
+        .program = {
+            .action = VLC_INPUT_PROGRAM_UPDATED,
+            .id = i_program,
+            .title = psz_text
+        }
+    });
+}
 static inline void input_SendEventProgramDel(input_thread_t *p_input,
                                              int i_program)
 {
diff --git a/src/input/var.c b/src/input/var.c
index 30f9d7e94f..3ef8c0fa31 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -314,6 +314,11 @@ void input_LegacyEvents( input_thread_t *p_input,
                 case VLC_INPUT_PROGRAM_DELETED:
                     VarListDel( p_input, "program", event->program.id );
                     break;
+                case VLC_INPUT_PROGRAM_UPDATED:
+                    VarListDel( p_input, "program", event->program.id );
+                    VarListAdd( p_input, "program", event->program.id,
+                                event->program.title );
+                    break;
                 case VLC_INPUT_PROGRAM_SELECTED:
                     VarListSelect( p_input, "program", event->program.id );
                     break;



More information about the vlc-commits mailing list