Ignore:
Timestamp:
May 14, 2009, 6:16:41 PM (12 years ago)
Author:
Pascal Terjan
Message:
  • Adapt refresh rate dynamically and inform the server about it
File:
1 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/main.c

    r3456 r3457  
    180180                char * buf2;
    181181                size_t l = 0;
     182                int dt;
    182183                /* 0 means we have valid data but incomplete, so read the rest */
    183184                while(l == 0)
     
    206207                fcntl(screen_list->socket[SOCK_CLIENT], F_SETFL, O_NONBLOCK);
    207208                caca_refresh_display(screen_list->dp);
    208                 debug("refreshtime=%d", caca_get_display_time(screen_list->dp));
     209                dt = caca_get_display_time(screen_list->dp);
     210                debug("refreshtime=%dms (limit %d, requested %d)", dt/1000, screen_list->delay, screen_list->requested_delay);
     211                /* Adjust refresh delay so that the server do not compute useless things */
     212                if(dt > 2*1000*screen_list->delay)
     213                {
     214                    screen_list->delay*=2;
     215                    send_delay(screen_list);
     216                }
     217                else if(dt < screen_list->delay*1000/2 &&
     218                        screen_list->delay >= 2*screen_list->requested_delay)
     219                {
     220                    screen_list->delay/=2;
     221                    send_delay(screen_list);
     222                }
    209223            }
    210224            else if(!strncmp("CURSOR ", buf, 7))
Note: See TracChangeset for help on using the changeset viewer.