[MPlayer-dev-eng] [PATCH] Re: [PATCH] quiet-time Bug #1459 (was Re: [PATCH] output console status only every n frames (-quietframes), Bug #1459)

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri Aug 14 21:13:38 CEST 2009


On Sun, Jun 07, 2009 at 03:05:12PM +0200, D. Jansen wrote:
> Index: mplayer.c
> ===================================================================
> --- mplayer.c	(Revision 29324)
> +++ mplayer.c	(Arbeitskopie)
> @@ -81,6 +81,7 @@
>  int slave_mode=0;
>  int player_idle_mode=0;
>  int quiet=0;
> +int quiet_time=0;
>  int enable_mouse_movements=0;
>  float start_volume = -1;
>  
> @@ -1936,6 +1937,11 @@
>  
>  static void adjust_sync_and_print_status(int between_frames, float timing_error)
>  {
> +    static unsigned last_status_update=0;
> +    unsigned now=GetTimerMS();
> +    if (quiet_time && now >= (last_status_update + quiet_time * 100)) 
> +	last_status_update=now;

That's not good. I calls GetTimerMS uselessly when quiet_time is not
set.
Also it doesn't handle overflow right.
I'd suggest something like this (note explicitly initializing a static
variable to 0 is pointless - in addition 0 is not better than any other
value):
static unsigned last_status_update;
int update = !quiet && !quite_time;
if (!quiet && quiet_time) {
  unsigned now = GetTimerMS();
  if (now - last_status_update >= quiet_time * 100) {
    last_status_update = now;
    update = 1;
  }
}

> @@ -1987,6 +1993,7 @@
>  		c_total+=x;
>  	    }
>  	    if(!quiet)
> +		if (!quiet_time || (last_status_update == now))

And here just replace "!quiet" by "update"

> Index: mencoder.c
> ===================================================================
> --- mencoder.c	(Revision 29324)
> +++ mencoder.c	(Arbeitskopie)
> @@ -131,6 +131,7 @@
>  //void resync_audio_stream(sh_audio_t *sh_audio){}
>  
>  int quiet=0;
> +int quiet_time=0;
>  double video_time_usage=0;
>  double vout_time_usage=0;
>  double max_video_time_usage=0;
> @@ -1420,8 +1421,14 @@
>  	    (int)demuxer->filepos,
>  	    (int)demuxer->movi_end);
>  #else
> +    static unsigned last_status_update=0;
> +    unsigned now=GetTimerMS();

I'd put the declarations to get with all other declarations before the
#if 0 blocks



More information about the MPlayer-dev-eng mailing list