[vlc-commits] input: factor INPUT_CONTROL_SET_TITLE code

Rémi Denis-Courmont git at videolan.org
Wed Apr 17 18:38:38 CEST 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Apr 17 19:27:17 2013 +0300| [a87b4b357be399692c624b6653637b250c917640] | committer: Rémi Denis-Courmont

input: factor INPUT_CONTROL_SET_TITLE code

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

 src/input/input.c |   65 +++++++++++++++++++----------------------------------
 1 file changed, 23 insertions(+), 42 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index c3f5f09..5d31afdaa 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1893,56 +1893,37 @@ static bool Control( input_thread_t *p_input,
         case INPUT_CONTROL_SET_TITLE:
         case INPUT_CONTROL_SET_TITLE_NEXT:
         case INPUT_CONTROL_SET_TITLE_PREV:
+        {
             if( p_input->p->b_recording )
             {
                 msg_Err( p_input, "INPUT_CONTROL_SET_TITLE(*) ignored while recording" );
                 break;
             }
-            if( p_input->p->input.b_title_demux &&
-                p_input->p->input.i_title > 0 )
-            {
-                /* TODO */
-                /* FIXME handle demux title */
-                demux_t *p_demux = p_input->p->input.p_demux;
-                int i_title;
-
-                if( i_type == INPUT_CONTROL_SET_TITLE_PREV )
-                    i_title = p_demux->info.i_title - 1;
-                else if( i_type == INPUT_CONTROL_SET_TITLE_NEXT )
-                    i_title = p_demux->info.i_title + 1;
-                else
-                    i_title = val.i_int;
-
-                if( i_title >= 0 && i_title < p_input->p->input.i_title )
-                {
-                    es_out_SetTime( p_input->p->p_es_out, -1 );
-
-                    demux_Control( p_demux, DEMUX_SET_TITLE, i_title );
-                    input_SendEventTitle( p_input, i_title );
-                }
-            }
-            else if( p_input->p->input.i_title > 0 )
-            {
-                access_t *p_access = p_input->p->input.p_access;
-                int i_title;
-
-                if( i_type == INPUT_CONTROL_SET_TITLE_PREV )
-                    i_title = p_access->info.i_title - 1;
-                else if( i_type == INPUT_CONTROL_SET_TITLE_NEXT )
-                    i_title = p_access->info.i_title + 1;
-                else
-                    i_title = val.i_int;
+            if( p_input->p->input.i_title <= 0 )
+                break;
 
-                if( i_title >= 0 && i_title < p_input->p->input.i_title )
-                {
-                    es_out_SetTime( p_input->p->p_es_out, -1 );
+            int i_title = p_input->p->input.b_title_demux
+                        ? p_input->p->input.p_demux->info.i_title
+                        : p_input->p->input.p_access->info.i_title;
+            if( i_type == INPUT_CONTROL_SET_TITLE_PREV )
+                i_title--;
+            else if( i_type == INPUT_CONTROL_SET_TITLE_NEXT )
+                i_title++;
+            else
+                i_title = val.i_int;
+            if( i_title < 0 || i_title >= p_input->p->input.i_title )
+                break;
 
-                    stream_Control( p_input->p->input.p_stream, STREAM_CONTROL_ACCESS,
-                                    ACCESS_SET_TITLE, i_title );
-                    input_SendEventTitle( p_input, i_title );
-                }
-            }
+            es_out_SetTime( p_input->p->p_es_out, -1 );
+            if( p_input->p->input.b_title_demux )
+                demux_Control( p_input->p->input.p_demux,
+                               DEMUX_SET_TITLE, i_title );
+            else
+                stream_Control( p_input->p->input.p_stream,
+                            STREAM_CONTROL_ACCESS, ACCESS_SET_TITLE, i_title );
+            input_SendEventTitle( p_input, i_title );
             break;
+        }
         case INPUT_CONTROL_SET_SEEKPOINT:
         case INPUT_CONTROL_SET_SEEKPOINT_NEXT:
         case INPUT_CONTROL_SET_SEEKPOINT_PREV:



More information about the vlc-commits mailing list