demux: add helper functions to avoid accessing update data directly outside of demux.c
authorSteve Lhomme <robUx4@videolabs.io>
Tue, 7 Jun 2016 09:15:16 +0000 (11:15 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 8 Jun 2016 07:27:04 +0000 (09:27 +0200)
only demux.c code and the demuxer itself should access these data directly

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
src/input/demux.c
src/input/demux.h
src/input/input.c
src/input/stream_demux.c

index 6336742..8f3df7f 100644 (file)
@@ -657,3 +657,22 @@ static bool SkipAPETag( demux_t *p_demux )
     return true;
 }
 
+int demux_GetUpdateFlags( demux_t *p_demux )
+{
+    return p_demux->info.i_update;
+}
+
+void demux_ResetUpdateFlags( demux_t *p_demux, int i_flags )
+{
+    p_demux->info.i_update &= ~i_flags;
+}
+
+int demux_GetTitle( demux_t *p_demux )
+{
+    return p_demux->info.i_title;
+}
+
+int demux_GetSeekpoint( demux_t *p_demux )
+{
+    return p_demux->info.i_seekpoint;
+}
index f841f68..2e5b01a 100644 (file)
@@ -39,4 +39,10 @@ demux_t *demux_NewAdvanced( vlc_object_t *p_obj, input_thread_t *p_parent_input,
 demux_t *input_DemuxNew( vlc_object_t *, const char *access, const char *demux,
                          const char *path, es_out_t *out, bool quick,
                          input_thread_t * );
+
+int demux_GetUpdateFlags( demux_t * );
+void demux_ResetUpdateFlags( demux_t *, int );
+int demux_GetTitle( demux_t * );
+int demux_GetSeekpoint( demux_t * );
+
 #endif
index 7dce0b8..6a2a8a8 100644 (file)
@@ -562,12 +562,12 @@ static void MainLoopDemux( input_thread_t *p_input, bool *pb_changed )
 
     if( i_ret == VLC_DEMUXER_SUCCESS )
     {
-        if( p_demux->info.i_update )
+        if( demux_GetUpdateFlags( p_demux ) )
         {
-            if( p_demux->info.i_update & INPUT_UPDATE_TITLE_LIST )
+            if( demux_GetUpdateFlags( p_demux ) & INPUT_UPDATE_TITLE_LIST )
             {
                 UpdateTitleListfromDemux( p_input );
-                p_demux->info.i_update &= ~INPUT_UPDATE_TITLE_LIST;
+                demux_ResetUpdateFlags( p_demux, INPUT_UPDATE_TITLE_LIST );
             }
             if( p_input->p->master->b_title_demux )
             {
@@ -1933,7 +1933,7 @@ static bool Control( input_thread_t *p_input,
             if( p_input->p->master->i_title <= 0 )
                 break;
 
-            int i_title = p_input->p->master->p_demux->info.i_title;
+            int i_title = demux_GetTitle( p_input->p->master->p_demux );
             if( i_type == INPUT_CONTROL_SET_TITLE_PREV )
                 i_title--;
             else if( i_type == INPUT_CONTROL_SET_TITLE_NEXT )
@@ -1963,8 +1963,8 @@ static bool Control( input_thread_t *p_input,
 
             demux_t *p_demux = p_input->p->master->p_demux;
 
-            int i_title = p_demux->info.i_title;
-            int i_seekpoint = p_demux->info.i_seekpoint;
+            int i_title = demux_GetTitle( p_demux );
+            int i_seekpoint = demux_GetSeekpoint( p_demux );
 
             if( i_type == INPUT_CONTROL_SET_SEEKPOINT_PREV )
             {
@@ -2144,33 +2144,33 @@ static int UpdateTitleSeekpointFromDemux( input_thread_t *p_input )
     demux_t *p_demux = p_input->p->master->p_demux;
 
     /* TODO event-like */
-    if( p_demux->info.i_update & INPUT_UPDATE_TITLE )
+    if( demux_GetUpdateFlags( p_demux ) & INPUT_UPDATE_TITLE )
     {
-        input_SendEventTitle( p_input, p_demux->info.i_title );
+        input_SendEventTitle( p_input, demux_GetTitle( p_demux ) );
 
-        p_demux->info.i_update &= ~INPUT_UPDATE_TITLE;
+        demux_ResetUpdateFlags( p_demux, INPUT_UPDATE_TITLE );
     }
-    if( p_demux->info.i_update & INPUT_UPDATE_SEEKPOINT )
+    if( demux_GetUpdateFlags( p_demux ) & INPUT_UPDATE_SEEKPOINT )
     {
         input_SendEventSeekpoint( p_input,
-                                  p_demux->info.i_title, p_demux->info.i_seekpoint );
+                                  demux_GetTitle( p_demux ), demux_GetSeekpoint( p_demux ) );
 
-        p_demux->info.i_update &= ~INPUT_UPDATE_SEEKPOINT;
+        demux_ResetUpdateFlags( p_demux, INPUT_UPDATE_SEEKPOINT );
     }
 
     return UpdateTitleSeekpoint( p_input,
-                                 p_demux->info.i_title,
-                                 p_demux->info.i_seekpoint );
+                                 demux_GetTitle( p_demux ),
+                                 demux_GetSeekpoint( p_demux ) );
 }
 
 static void UpdateGenericFromDemux( input_thread_t *p_input )
 {
     demux_t *p_demux = p_input->p->master->p_demux;
 
-    if( p_demux->info.i_update & INPUT_UPDATE_META )
+    if( demux_GetUpdateFlags( p_demux ) & INPUT_UPDATE_META )
     {
         InputUpdateMeta( p_input, p_demux );
-        p_demux->info.i_update &= ~INPUT_UPDATE_META;
+        demux_ResetUpdateFlags( p_demux, INPUT_UPDATE_META );
     }
     {
         double quality;
index 76ca3e3..f87c7f6 100644 (file)
@@ -261,7 +261,7 @@ static void* DStreamThread( void *obj )
     mtime_t next_update = 0;
     while( atomic_load( &p_sys->active ) )
     {
-        if( p_demux->info.i_update || mdate() >= next_update )
+        if( demux_GetUpdateFlags( p_demux ) || mdate() >= next_update )
         {
             double newpos;
             int64_t newlen, newtime;
@@ -279,7 +279,7 @@ static void* DStreamThread( void *obj )
             p_sys->stats.time = newtime;
             vlc_mutex_unlock( &p_sys->lock );
 
-            p_demux->info.i_update = 0;
+            demux_ResetUpdateFlags( p_demux, 0xFFFF );
             next_update = mdate() + (CLOCK_FREQ / 4);
         }