Skip to content

Commit

Permalink
demux: merge GetUpdateFlags() and ResetUpdateFlags()
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi Denis-Courmont committed Jun 9, 2016
1 parent 8a052fe commit ca134b9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 38 deletions.
11 changes: 4 additions & 7 deletions src/input/demux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
3 changes: 1 addition & 2 deletions src/input/demux.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 * );

Expand Down
41 changes: 14 additions & 27 deletions src/input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 ),
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/input/stream_demux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down

0 comments on commit ca134b9

Please sign in to comment.