Ignore:
Timestamp:
Sep 17, 2008, 7:44:24 PM (13 years ago)
Author:
charles
Message:

first draft at having more accurate speed controls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/ratecontrol.c

    r6425 r6782  
    3030#include "utils.h"
    3131
    32 #define GRANULARITY_MSEC 500
    33 #define SHORT_INTERVAL_MSEC 1000
    34 #define LONG_INTERVAL_MSEC 8000
    35 #define HISTORY_SIZE (LONG_INTERVAL_MSEC / GRANULARITY_MSEC)
     32#define INTERVAL_MSEC 1000
     33#define GRANULARITY_MSEC 200
     34#define HISTORY_SIZE (INTERVAL_MSEC / GRANULARITY_MSEC)
    3635
    3736struct tr_transfer
     
    8483tr_rcClose( tr_ratecontrol * r )
    8584{
    86     tr_rcReset( r );
     85    memset( r, 0, sizeof( tr_ratecontrol ) );
    8786    tr_free( r );
    8887}
     
    9291***/
    9392
    94 size_t
    95 tr_rcBytesLeft( const tr_ratecontrol * r )
    96 {
    97     size_t bytes = 0;
    98 
    99     if( r )
    100     {
    101         const float cur = rateForInterval( r, SHORT_INTERVAL_MSEC );
    102         const float max = r->limit;
    103         const float kb = max>cur ? max-cur : 0;
    104         bytes = (size_t)(kb * 1024);
    105     }
    106 
    107     return bytes;
    108 }
    109 
    11093float
    11194tr_rcRate( const tr_ratecontrol * r )
     
    11497
    11598    if( r )
    116         ret = rateForInterval( r, LONG_INTERVAL_MSEC );
     99        ret = rateForInterval( r, INTERVAL_MSEC );
    117100
    118101    return ret;
     
    138121
    139122void
    140 tr_rcReset( tr_ratecontrol * r )
    141 {
    142     r->newest = 0;
    143     memset( r->transfers, 0, sizeof(struct tr_transfer) * HISTORY_SIZE );
    144 }
    145 
    146 void
    147123tr_rcSetLimit( tr_ratecontrol * r, int limit )
    148124{
Note: See TracChangeset for help on using the changeset viewer.