[vlc-commits] demux: merge GetUpdateFlags() and ResetUpdateFlags()
Rémi Denis-Courmont
git at videolan.org
Thu Jun 9 19:59:21 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jun 9 20:58:55 2016 +0300| [ca134b998b49f596aaa0f3e4deab2bdce3eab3bd] | committer: Rémi Denis-Courmont
demux: merge GetUpdateFlags() and ResetUpdateFlags()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ca134b998b49f596aaa0f3e4deab2bdce3eab3bd
---
src/input/demux.c | 11 ++++-------
src/input/demux.h | 3 +--
src/input/input.c | 41 ++++++++++++++---------------------------
src/input/stream_demux.c | 4 ++--
4 files changed, 21 insertions(+), 38 deletions(-)
diff --git a/src/input/demux.c b/src/input/demux.c
index 8f3df7f..b159526 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -657,14 +657,11 @@ static bool SkipAPETag( demux_t *p_demux )
return true;
}
-int demux_GetUpdateFlags( demux_t *p_demux )
+unsigned demux_TestAndClearFlags( demux_t *p_demux, unsigned flags )
{
- return p_demux->info.i_update;
-}
-
-void demux_ResetUpdateFlags( demux_t *p_demux, int i_flags )
-{
- p_demux->info.i_update &= ~i_flags;
+ unsigned ret = p_demux->info.i_update & flags;
+ p_demux->info.i_update &= ~flags;
+ return ret;
}
int demux_GetTitle( demux_t *p_demux )
diff --git a/src/input/demux.h b/src/input/demux.h
index 2e5b01a..5b75cbc 100644
--- a/src/input/demux.h
+++ b/src/input/demux.h
@@ -40,8 +40,7 @@ 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 );
+unsigned demux_TestAndClearFlags( demux_t *, unsigned );
int demux_GetTitle( demux_t * );
int demux_GetSeekpoint( demux_t * );
diff --git a/src/input/input.c b/src/input/input.c
index 6a2a8a8..43965ea 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -562,20 +562,16 @@ static void MainLoopDemux( input_thread_t *p_input, bool *pb_changed )
if( i_ret == VLC_DEMUXER_SUCCESS )
{
- if( demux_GetUpdateFlags( p_demux ) )
+ if( demux_TestAndClearFlags( p_demux, INPUT_UPDATE_TITLE_LIST ) )
+ UpdateTitleListfromDemux( p_input );
+
+ if( p_input->p->master->b_title_demux )
{
- if( demux_GetUpdateFlags( p_demux ) & INPUT_UPDATE_TITLE_LIST )
- {
- UpdateTitleListfromDemux( p_input );
- demux_ResetUpdateFlags( p_demux, INPUT_UPDATE_TITLE_LIST );
- }
- if( p_input->p->master->b_title_demux )
- {
- i_ret = UpdateTitleSeekpointFromDemux( p_input );
- *pb_changed = true;
- }
- UpdateGenericFromDemux( p_input );
+ i_ret = UpdateTitleSeekpointFromDemux( p_input );
+ *pb_changed = true;
}
+
+ UpdateGenericFromDemux( p_input );
}
if( i_ret == VLC_DEMUXER_EOF )
@@ -2144,19 +2140,12 @@ static int UpdateTitleSeekpointFromDemux( input_thread_t *p_input )
demux_t *p_demux = p_input->p->master->p_demux;
/* TODO event-like */
- if( demux_GetUpdateFlags( p_demux ) & INPUT_UPDATE_TITLE )
- {
+ if( demux_TestAndClearFlags( p_demux, INPUT_UPDATE_TITLE ) )
input_SendEventTitle( p_input, demux_GetTitle( p_demux ) );
- demux_ResetUpdateFlags( p_demux, INPUT_UPDATE_TITLE );
- }
- if( demux_GetUpdateFlags( p_demux ) & INPUT_UPDATE_SEEKPOINT )
- {
- input_SendEventSeekpoint( p_input,
- demux_GetTitle( p_demux ), demux_GetSeekpoint( p_demux ) );
-
- demux_ResetUpdateFlags( p_demux, INPUT_UPDATE_SEEKPOINT );
- }
+ if( demux_TestAndClearFlags( p_demux, INPUT_UPDATE_SEEKPOINT ) )
+ input_SendEventSeekpoint( p_input, demux_GetTitle( p_demux ),
+ demux_GetSeekpoint( p_demux ) );
return UpdateTitleSeekpoint( p_input,
demux_GetTitle( p_demux ),
@@ -2167,11 +2156,9 @@ static void UpdateGenericFromDemux( input_thread_t *p_input )
{
demux_t *p_demux = p_input->p->master->p_demux;
- if( demux_GetUpdateFlags( p_demux ) & INPUT_UPDATE_META )
- {
+ if( demux_TestAndClearFlags( p_demux, INPUT_UPDATE_META ) )
InputUpdateMeta( p_input, p_demux );
- demux_ResetUpdateFlags( p_demux, INPUT_UPDATE_META );
- }
+
{
double quality;
double strength;
diff --git a/src/input/stream_demux.c b/src/input/stream_demux.c
index f87c7f6..4ee2904 100644
--- a/src/input/stream_demux.c
+++ b/src/input/stream_demux.c
@@ -261,7 +261,8 @@ static void* DStreamThread( void *obj )
mtime_t next_update = 0;
while( atomic_load( &p_sys->active ) )
{
- if( demux_GetUpdateFlags( p_demux ) || mdate() >= next_update )
+ if( demux_TestAndClearFlags( p_demux, UINT_MAX )
+ || mdate() >= next_update )
{
double newpos;
int64_t newlen, newtime;
@@ -279,7 +280,6 @@ static void* DStreamThread( void *obj )
p_sys->stats.time = newtime;
vlc_mutex_unlock( &p_sys->lock );
- demux_ResetUpdateFlags( p_demux, 0xFFFF );
next_update = mdate() + (CLOCK_FREQ / 4);
}
More information about the vlc-commits
mailing list