Changeset 7069


Ignore:
Timestamp:
Nov 8, 2008, 2:49:04 AM (10 years ago)
Author:
charles
Message:

more fucking around with the speed measurements.

Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/cli.c

    r6978 r7069  
    283283            st->peersSendingToUs,
    284284            st->peersConnected,
    285             st->rateDownload,
     285            st->pieceDownloadSpeed,
    286286            st->peersGettingFromUs,
    287             st->rateUpload,
     287            st->pieceUploadSpeed,
    288288            ratioStr );
    289289    }
     
    296296            "Seeding, uploading to %d of %d peer(s), %.0f KB/s [%s]",
    297297            st->peersGettingFromUs, st->peersConnected,
    298             st->rateUpload, ratioStr );
     298            st->pieceUploadSpeed, ratioStr );
    299299    }
    300300    else *buf = '\0';
  • trunk/gtk/torrent-cell-renderer.c

    r6998 r7069  
    109109
    110110    if( haveDown )
    111         tr_strlspeed( downStr, torStat->rateDownload, sizeof( downStr ) );
     111        tr_strlspeed( downStr, torStat->pieceDownloadSpeed, sizeof( downStr ) );
    112112    if( haveUp )
    113         tr_strlspeed( upStr, torStat->rateUpload, sizeof( upStr ) );
     113        tr_strlspeed( upStr, torStat->pieceUploadSpeed, sizeof( upStr ) );
    114114
    115115    if( haveDown && haveUp )
  • trunk/gtk/tr-core.c

    r6978 r7069  
    309309    sb = tr_torrentStatCached( tb );
    310310
    311     if( ( i = compareDouble( sa->rateUpload + sa->rateDownload,
    312                              sb->rateUpload + sb->rateDownload ) ) )
     311    if( ( i = compareDouble( sa->pieceUploadSpeed + sa->pieceDownloadSpeed,
     312                             sb->pieceUploadSpeed + sb->pieceDownloadSpeed ) ) )
    313313        return i;
    314314
     
    746746    if( !isDisposed( core ) )
    747747    {
    748         tr_sessionGetSpeed( core->priv->session,
    749                             &setme->clientDownloadSpeed,
    750                             &setme->clientUploadSpeed );
    751 
    752         gtk_tree_model_foreach( core->priv->model,
    753                                 statsForeach,
    754                                 setme );
     748        tr_session * session = core->priv->session;
     749
     750        setme->clientDownloadSpeed = tr_sessionGetPieceSpeed( session, TR_DOWN );
     751
     752        setme->clientUploadSpeed = tr_sessionGetPieceSpeed( session, TR_UP );
     753
     754        gtk_tree_model_foreach( core->priv->model, statsForeach, setme );
    755755    }
    756756}
  • trunk/gtk/tr-window.c

    r6998 r7069  
    770770updateSpeeds( PrivateData * p )
    771771{
    772     char        buf[128];
    773     float       u, d;
    774772    tr_session * session = tr_core_session( p->core );
    775773
    776     tr_sessionGetSpeed( session, &d, &u );
    777     tr_strlspeed( buf, d, sizeof( buf ) );
    778     gtk_label_set_text( GTK_LABEL( p->dl_lb ), buf );
    779     tr_strlspeed( buf, u, sizeof( buf ) );
    780     gtk_label_set_text( GTK_LABEL( p->ul_lb ), buf );
     774    if( session != NULL )
     775    {
     776        char buf[128];
     777        double d;
     778
     779        d = tr_sessionGetPieceSpeed( session, TR_DOWN );
     780        tr_strlspeed( buf, d, sizeof( buf ) );
     781        gtk_label_set_text( GTK_LABEL( p->dl_lb ), buf );
     782
     783        d = tr_sessionGetPieceSpeed( session, TR_UP );
     784        tr_strlspeed( buf, d, sizeof( buf ) );
     785        gtk_label_set_text( GTK_LABEL( p->ul_lb ), buf );
     786    }
    781787}
    782788
  • trunk/libtransmission/peer-io.c

    r7055 r7069  
    3030#include "net.h"
    3131#include "peer-io.h"
     32#include "ratecontrol.h"
    3233#include "trevent.h"
    3334#include "utils.h"
     
    204205        b->bytesLeft -= MIN( b->bytesLeft, (size_t)n );
    205206        b->bytesUsed += n;
     207        tr_rcTransferred( io->session->rawSpeed[TR_UP], n );
    206208        dbgmsg( io,
    207209                "wrote %zu bytes to peer... upload bytesLeft is now %zu",
     
    236238        b->bytesLeft -= MIN( b->bytesLeft, (size_t)n );
    237239        b->bytesUsed += n;
     240        tr_rcTransferred( io->session->rawSpeed[TR_DOWN], n );
    238241        dbgmsg( io,
    239242                "%zu new input bytes. bytesUsed is %zu, bytesLeft is %zu",
  • trunk/libtransmission/peer-mgr.c

    r7065 r7069  
    5555    /* how frequently to decide which peers live and die */
    5656    RECONNECT_PERIOD_MSEC = ( 2 * 1000 ),
     57   
     58    /* how frequently to reallocate bandwidth */
     59    BANDWIDTH_PERIOD_MSEC = 250,
    5760
    5861    /* max # of peers to ask fer per torrent per reconnect pulse */
     
    124127struct tr_peerMgr
    125128{
    126     uint8_t        bandwidthPulseNumber;
    127     tr_session *   session;
    128     tr_ptrArray *  torrents; /* Torrent */
    129     tr_ptrArray *  incomingHandshakes; /* tr_handshake */
    130     tr_timer *     bandwidthTimer;
    131     double         globalPoolHistory[2][BANDWIDTH_PULSE_HISTORY];
     129    tr_session      * session;
     130    tr_ptrArray     * torrents; /* Torrent */
     131    tr_ptrArray     * incomingHandshakes; /* tr_handshake */
     132    tr_timer        * bandwidthTimer;
     133    tr_ratecontrol  * globalPoolRawSpeed[2];
    132134};
    133135
     
    506508static int bandwidthPulse( void * vmgr );
    507509
     510
    508511tr_peerMgr*
    509512tr_peerMgrNew( tr_session * session )
     
    514517    m->torrents = tr_ptrArrayNew( );
    515518    m->incomingHandshakes = tr_ptrArrayNew( );
    516     m->bandwidthPulseNumber = -1;
    517     m->bandwidthTimer = tr_timerNew( session, bandwidthPulse,
    518                                      m, 1000 / BANDWIDTH_PULSES_PER_SECOND );
     519    m->globalPoolRawSpeed[TR_CLIENT_TO_PEER] = tr_rcInit( );
     520    m->globalPoolRawSpeed[TR_PEER_TO_CLIENT] = tr_rcInit( );
     521    m->bandwidthTimer = tr_timerNew( session, bandwidthPulse, m, BANDWIDTH_PERIOD_MSEC );
    519522    return m;
    520523}
     
    526529
    527530    tr_timerFree( &manager->bandwidthTimer );
     531    tr_rcClose( manager->globalPoolRawSpeed[TR_CLIENT_TO_PEER] );
     532    tr_rcClose( manager->globalPoolRawSpeed[TR_PEER_TO_CLIENT] );
    528533
    529534    /* free the handshakes.  Abort invokes handshakeDoneCB(), which removes
     
    23272332
    23282333static double
    2329 allocateHowMuch( double         desiredAvgKB,
    2330                  const double * history )
    2331 {
    2332     const double baseline = desiredAvgKB * 1024.0 /
    2333                             BANDWIDTH_PULSES_PER_SECOND;
    2334     const double min = baseline * 0.85;
    2335     const double max = baseline * 1.15;
    2336     int          i;
    2337     double       usedBytes;
    2338     double       n;
    2339     double       clamped;
    2340 
    2341     for( usedBytes = i = 0; i < BANDWIDTH_PULSE_HISTORY; ++i )
    2342         usedBytes += history[i];
    2343 
    2344     n = ( desiredAvgKB * 1024.0 )
    2345       * ( BANDWIDTH_PULSE_HISTORY + 1.0 )
    2346       / BANDWIDTH_PULSES_PER_SECOND
    2347       - usedBytes;
     2334allocateHowMuch( double                  desired_average_kb_per_sec,
     2335                 const tr_ratecontrol  * ratecontrol )
     2336{
     2337    const int pulses_per_history = TR_RATECONTROL_HISTORY_MSEC / BANDWIDTH_PERIOD_MSEC;
     2338    const double seconds_per_pulse = BANDWIDTH_PERIOD_MSEC / 1000.0;
     2339    const double baseline_bytes_per_pulse = desired_average_kb_per_sec * 1024.0 * seconds_per_pulse;
     2340    const double min = baseline_bytes_per_pulse * 0.85;
     2341    const double max = baseline_bytes_per_pulse * 1.15;
     2342    const double current_bytes_per_pulse = tr_rcRate( ratecontrol ) * 1024.0 * seconds_per_pulse;
     2343    const double next_pulse_bytes = baseline_bytes_per_pulse * ( pulses_per_history + 1 )
     2344                                  - ( current_bytes_per_pulse * pulses_per_history );
     2345    double clamped;
    23482346
    23492347    /* clamp the return value to lessen oscillation */
    2350     clamped = n;
     2348    clamped = next_pulse_bytes;
    23512349    clamped = MAX( clamped, min );
    23522350    clamped = MIN( clamped, max );
    2353 /*fprintf( stderr, "desiredAvgKB is %.2f, rate is %.2f, allocating %.2f
    2354   (%.2f)\n", desiredAvgKB,
    2355   ((usedBytes*BANDWIDTH_PULSES_PER_SECOND)/BANDWIDTH_PULSE_HISTORY)/1024.0,
    2356   clamped/1024.0, n/1024.0 );*/
     2351
     2352fprintf( stderr, "desiredAvgKB is %.2f, rate is %.2f, allocating %.2f (%.2f)\n",
     2353         desired_average_kb_per_sec,
     2354         tr_rcRate( ratecontrol ),
     2355         clamped/1024.0,
     2356         next_pulse_bytes/1024.0 );
     2357
    23572358    return clamped;
    23582359}
     
    23672368 */
    23682369static void
    2369 setPeerBandwidth( tr_ptrArray *      peerArray,
    2370                   const tr_direction direction,
    2371                   const double *     history,
    2372                   double             desiredAvgKB )
     2370setPeerBandwidth( tr_ptrArray          * peerArray,
     2371                  const tr_direction     direction,
     2372                  const tr_ratecontrol * ratecontrol,
     2373                  double                 desiredAvgKB )
    23732374{
    23742375    const int    peerCount = tr_ptrArraySize( peerArray );
    2375     const double bytes = allocateHowMuch( desiredAvgKB, history );
     2376    const double bytes = allocateHowMuch( desiredAvgKB, ratecontrol );
    23762377    const double welfareBytes = MIN( 2048, bytes * 0.2 );
    23772378    const double meritBytes = MAX( 0, bytes - welfareBytes );
     
    24902491{
    24912492    tr_session *  session = mgr->session;
    2492     const int     pulseNumber = mgr->bandwidthPulseNumber;
    24932493    const int     torrentCount = tr_ptrArraySize( mgr->torrents );
    24942494    Torrent **    torrents = (Torrent **) tr_ptrArrayBase( mgr->torrents );
     
    25042504    pumpAllPeers( mgr );
    25052505
    2506     for( i = 0; i < torrentCount; ++i )
     2506    for( i=0; i<torrentCount; ++i )
    25072507    {
    25082508        Torrent * t = torrents[i];
    2509         const size_t used = countPeerBandwidth( t->peers, direction );
     2509        size_t used;
    25102510        tr_speedlimit speedMode;
    25112511
     2512        /* no point in allocating bandwidth for stopped torrents */
     2513        if( tr_torrentGetActivity( t->tor ) == TR_STATUS_STOPPED )
     2514            continue;
     2515
     2516        used = countPeerBandwidth( t->peers, direction );
    25122517        countHandshakeBandwidth( t->outgoingHandshakes, direction );
    25132518
    25142519        /* remember this torrent's bytes used */
    2515         t->tor->rateHistory[direction][pulseNumber] = used;
     2520        tr_rcTransferred( t->tor->rawSpeed[direction], used );
    25162521
    25172522        /* add this torrent's bandwidth use to allBytesUsed */
     
    25342539            case TR_SPEEDLIMIT_SINGLE:
    25352540                setPeerBandwidth( t->peers, direction,
    2536                                   t->tor->rateHistory[direction],
    2537                                   tr_torrentGetSpeedLimit( t->tor,
    2538                                                            direction ) );
     2541                                  t->tor->rawSpeed[direction],
     2542                                  tr_torrentGetSpeedLimit( t->tor, direction ) );
    25392543                break;
    25402544
     
    25572561    poolBytesUsed += i;
    25582562
    2559     mgr->globalPoolHistory[direction][pulseNumber] = poolBytesUsed;
     2563    tr_rcTransferred( mgr->globalPoolRawSpeed[direction], poolBytesUsed );
    25602564
    25612565    /* handle the global pool's connections */
     
    25642568    else
    25652569        setPeerBandwidth( globalPool, direction,
    2566                          mgr->globalPoolHistory[direction],
    2567                          tr_sessionGetSpeedLimit( session, direction ) );
     2570                          mgr->globalPoolRawSpeed[direction],
     2571                          tr_sessionGetSpeedLimit( session, direction ) );
    25682572
    25692573    /* now that we've allocated bandwidth, pump all the connected peers */
     
    25832587    managerLock( mgr );
    25842588
    2585     /* keep track of how far we are into the cycle */
    2586     if( ++mgr->bandwidthPulseNumber == BANDWIDTH_PULSE_HISTORY )
    2587         mgr->bandwidthPulseNumber = 0;
    2588 
    25892589    /* allocate the upload and download bandwidth */
    25902590    for( i = 0; i < 2; ++i )
  • trunk/libtransmission/ratecontrol.c

    r6857 r7069  
    3030#include "utils.h"
    3131
    32 #define INTERVAL_MSEC 1000
    33 #define GRANULARITY_MSEC 200
    34 #define HISTORY_SIZE ( INTERVAL_MSEC / GRANULARITY_MSEC )
     32enum
     33{
     34    INTERVAL_MSEC = TR_RATECONTROL_HISTORY_MSEC,
     35
     36    GRANULARITY_MSEC = 250,
     37
     38    HISTORY_SIZE = ( INTERVAL_MSEC / GRANULARITY_MSEC )
     39};
    3540
    3641struct tr_transfer
  • trunk/libtransmission/ratecontrol.h

    r7055 r7069  
    2626#define _TR_RATECONTROL_H_
    2727
     28enum
     29{
     30    TR_RATECONTROL_HISTORY_MSEC = 2000
     31};
     32
    2833typedef struct tr_ratecontrol tr_ratecontrol;
    2934
  • trunk/libtransmission/rpcimpl.c

    r6935 r7069  
    362362    }
    363363    else if( !strcmp( key, "rateDownload" ) )
    364         tr_bencDictAddInt( d, key, (int)( st->rateDownload * 1024 ) );
     364        tr_bencDictAddInt( d, key, (int)( st->pieceDownloadSpeed * 1024 ) );
    365365    else if( !strcmp( key, "rateUpload" ) )
    366         tr_bencDictAddInt( d, key, (int)( st->rateUpload * 1024 ) );
     366        tr_bencDictAddInt( d, key, (int)( st->pieceUploadSpeed * 1024 ) );
    367367    else if( !strcmp( key, "recheckProgress" ) )
    368368        tr_bencDictAddDouble( d, key, st->recheckProgress );
     
    683683    tr_benc *    d = tr_bencDictAddDict( args_out, "session-stats", 10 );
    684684    tr_torrent * tor = NULL;
    685     float        up, down;
    686685    int          running = 0;
    687686    int          total = 0;
    688687
    689     tr_sessionGetSpeed( h, &down, &up );
    690688    while( ( tor = tr_torrentNext( h, tor ) ) )
    691689    {
     
    696694
    697695    tr_bencDictAddInt( d, "activeTorrentCount", running );
    698     tr_bencDictAddInt( d, "downloadSpeed", (int)( down * 1024 ) );
     696    tr_bencDictAddInt( d, "downloadSpeed", (int)( tr_sessionGetPieceSpeed( h, TR_DOWN ) * 1024 ) );
    699697    tr_bencDictAddInt( d, "pausedTorrentCount", total - running );
    700698    tr_bencDictAddInt( d, "torrentCount", total );
    701     tr_bencDictAddInt( d, "uploadSpeed", (int)( up * 1024 ) );
     699    tr_bencDictAddInt( d, "uploadSpeed", (int)( tr_sessionGetPieceSpeed( h, TR_UP ) * 1024 ) );
    702700    return NULL;
    703701}
  • trunk/libtransmission/session.c

    r7055 r7069  
    257257    h->pieceSpeed[TR_PEER_TO_CLIENT] = tr_rcInit( );
    258258    h->pieceSpeed[TR_CLIENT_TO_PEER] = tr_rcInit( );
     259    h->rawSpeed[TR_PEER_TO_CLIENT] = tr_rcInit( );
     260    h->rawSpeed[TR_CLIENT_TO_PEER] = tr_rcInit( );
    259261
    260262    if( configDir == NULL )
     
    501503***/
    502504
    503 void
    504 tr_sessionGetSpeed( const tr_handle * session,
    505                     float *           toClient,
    506                     float *           toPeer )
    507 {
    508     if( session && toClient )
    509         *toClient = tr_rcRate( session->pieceSpeed[TR_PEER_TO_CLIENT] );
    510 
    511     if( session && toPeer )
    512         *toPeer = tr_rcRate( session->pieceSpeed[TR_CLIENT_TO_PEER] );
     505double
     506tr_sessionGetPieceSpeed( const tr_session * session, tr_direction dir )
     507{
     508    assert( dir==TR_UP || dir==TR_DOWN );
     509
     510    return session ? tr_rcRate( session->pieceSpeed[dir] ) : 0.0;
     511}
     512
     513double
     514tr_sessionGetRawSpeed( const tr_session * session, tr_direction dir )
     515{
     516    assert( dir==TR_UP || dir==TR_DOWN );
     517
     518    return session ? tr_rcRate( session->rawSpeed[dir] ) : 0.0;
    513519}
    514520
     
    626632    tr_rcClose( session->pieceSpeed[TR_PEER_TO_CLIENT] );
    627633    tr_rcClose( session->pieceSpeed[TR_CLIENT_TO_PEER] );
     634    tr_rcClose( session->rawSpeed[TR_PEER_TO_CLIENT] );
     635    tr_rcClose( session->rawSpeed[TR_CLIENT_TO_PEER] );
    628636    tr_lockFree( session->lock );
    629637    for( i = 0; i < session->metainfoLookupCount; ++i )
  • trunk/libtransmission/session.h

    r7055 r7069  
    3535 #endif
    3636#endif
    37 
    38 enum
    39 {
    40     /* How frequently to reallocate peer bandwidth. */
    41     BANDWIDTH_PULSES_PER_SECOND = 4,
    42 
    43     /* HOw many pulses to remember for averaging the current speed */
    44     BANDWIDTH_PULSE_HISTORY = ( BANDWIDTH_PULSES_PER_SECOND * 2 )
    45 };
    4637
    4738
     
    118109     * protocol overhead is NOT included; this is only the piece data */
    119110    struct tr_ratecontrol     *  pieceSpeed[2];
     111
     112    /* the rate at which bytes are being transferred between client and peer. */
     113    struct tr_ratecontrol     *  rawSpeed[2];
    120114};
    121115
  • trunk/libtransmission/torrent.c

    r7065 r7069  
    497497    randomizeTiers( info );
    498498
     499    tor->rawSpeed[TR_CLIENT_TO_PEER] = tr_rcInit( );
     500    tor->rawSpeed[TR_PEER_TO_CLIENT] = tr_rcInit( );
    499501    tor->pieceSpeed[TR_CLIENT_TO_PEER] = tr_rcInit( );
    500502    tor->pieceSpeed[TR_PEER_TO_CLIENT] = tr_rcInit( );
     
    745747{
    746748    return tor ? &tor->info : NULL;
    747 }
    748 
    749 static double
    750 tr_torrentGetRate( const tr_torrent * tor,
    751                    tr_direction       direction )
    752 {
    753     assert( tor != NULL );
    754     assert( direction == TR_UP || direction == TR_DOWN );
    755 
    756     return tr_rcRate( tor->pieceSpeed[direction] );
    757749}
    758750
     
    823815                            s->peersFrom );
    824816
    825     s->rateDownload = tr_torrentGetRate( tor, TR_PEER_TO_CLIENT );
    826 
    827     s->rateUpload = tr_torrentGetRate( tor, TR_CLIENT_TO_PEER );
     817    s->rawUploadSpeed     = tr_rcRate( tor->rawSpeed[TR_UP] );
     818    s->rawDownloadSpeed   = tr_rcRate( tor->rawSpeed[TR_DOWN] );
     819    s->pieceUploadSpeed   = tr_rcRate( tor->pieceSpeed[TR_UP] );
     820    s->pieceDownloadSpeed = tr_rcRate( tor->pieceSpeed[TR_DOWN] );
    828821
    829822    usableSeeds += tor->info.webseedCount;
     
    881874    if( s->leftUntilDone > s->desiredAvailable )
    882875        s->eta = TR_ETA_NOT_AVAIL;
    883     else if( s->rateDownload < 0.1 )
     876    else if( s->pieceDownloadSpeed < 0.1 )
    884877        s->eta = TR_ETA_UNKNOWN;
    885878    else
    886         s->eta = s->leftUntilDone / s->rateDownload / 1024.0;
     879        s->eta = s->leftUntilDone / s->pieceDownloadSpeed / 1024.0;
    887880
    888881    s->ratio = tr_getRatio(
     
    11101103    tr_rcClose( tor->pieceSpeed[TR_PEER_TO_CLIENT] );
    11111104    tr_rcClose( tor->pieceSpeed[TR_CLIENT_TO_PEER] );
     1105    tr_rcClose( tor->rawSpeed[TR_PEER_TO_CLIENT] );
     1106    tr_rcClose( tor->rawSpeed[TR_CLIENT_TO_PEER] );
    11121107
    11131108    tr_metainfoFree( inf );
  • trunk/libtransmission/torrent.h

    r7065 r7069  
    230230    int                        uniqueId;
    231231
    232     /* this is the count of raw bytes transferred between the
    233      * client and its peers over the past HISTORY time slices.
    234      * this count is used for bandwidth allocation, and includes
    235      * piece data, protocol overhead, and estimated tcp header overhead. */
    236     double                     rateHistory[2][BANDWIDTH_PULSE_HISTORY];
    237 
    238232    /* the rate at which pieces are being transferred between client and
    239233     * its peers.  protocol overhead is NOT included; only the piece data */
    240234    struct tr_ratecontrol    * pieceSpeed[2];
     235
     236    /* the rate at which bytes are being sent between client and peers */
     237    struct tr_ratecontrol    * rawSpeed[2];
    241238};
    242239
  • trunk/libtransmission/transmission.h

    r7051 r7069  
    560560                                           int             isEnabled );
    561561
    562 void       tr_sessionGetSpeed( const tr_session  * session,
    563                                float             * overall_down_KiBs,
    564                                float             * overall_up_KiBs );
     562double     tr_sessionGetRawSpeed( const tr_session  * session,
     563                                  tr_direction        direection );
     564
     565double     tr_sessionGetPieceSpeed( const tr_session  * session,
     566                                    tr_direction        direection );
    565567
    566568int        tr_sessionIsSpeedLimitEnabled( const tr_session  * session,
     
    11851187tr_torrent_activity;
    11861188
     1189tr_torrent_activity tr_torrentGetActivity( tr_torrent * );
     1190
    11871191#define TR_STATUS_IS_ACTIVE( s ) ( ( s ) != TR_STATUS_STOPPED )
    11881192
     
    11941198}
    11951199tr_lockfile_state_t;
    1196 
    1197 tr_torrent_activity tr_torrentGetActivity( tr_torrent * );
    11981200
    11991201enum
     
    12571259    float    percentDone;
    12581260
    1259     /** Download speed in KiB/s */
    1260     double    rateDownload;
    1261 
    1262     /** Upload speed in KiB/s */
    1263     double    rateUpload;
     1261    /** Speed all data being sent for this torrent. (KiB/s)
     1262        This includes piece data, protocol messages, and TCP overhead */
     1263    double rawUploadSpeed;
     1264
     1265    /** Speed all data being received for this torrent. (KiB/s)
     1266        This includes piece data, protocol messages, and TCP overhead */
     1267    double rawDownloadSpeed;
     1268
     1269    /** Speed all piece being sent for this torrent. (KiB/s)
     1270        This ONLY counts piece data. */
     1271    double pieceUploadSpeed;
     1272
     1273    /** Speed all piece being received for this torrent. (KiB/s)
     1274        This ONLY counts piece data. */
     1275    double pieceDownloadSpeed;
    12641276
    12651277#define TR_ETA_NOT_AVAIL -1
  • trunk/macosx/Badger.m

    r6995 r7069  
    8686    if ([NSApp isOnLeopardOrBetter])
    8787    {
    88         float downloadRate = 0.0, uploadRate = 0.0;
    8988        BOOL badgeDownload = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeDownloadRate"],
    9089            badgeUpload = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeUploadRate"];
    91         if (badgeDownload || badgeUpload)
    92             tr_sessionGetSpeed(fLib, badgeDownload ? &downloadRate : NULL, badgeUpload ? &uploadRate : NULL);
     90        float downloadRate = badgeDownload ? tr_sessionGetPieceSpeed( fLib, TR_DOWN ) : 0.0f;
     91        float uploadRate   = badgeUpload   ? tr_sessionGetPieceSpeed( fLib, TR_UP   ) : 0.0f;
    9392       
    9493        //only update if the badged values change
     
    153152        NSString * downloadRateString = nil, * uploadRateString = nil;
    154153       
    155         float downloadRate, uploadRate;
    156         tr_sessionGetSpeed(fLib, &downloadRate, &uploadRate);
     154        float downloadRate = tr_sessionGetPieceSpeed( fLib, TR_DOWN );
     155        float uploadRate   = tr_sessionGetPieceSpeed( fLib, TR_UP );
    157156       
    158157        if (checkDownload && downloadRate >= 0.1)
  • trunk/macosx/Controller.m

    r7047 r7069  
    15081508            {
    15091509                //set rates
    1510                 float downloadRate, uploadRate;
    1511                 tr_sessionGetSpeed(fLib, &downloadRate, &uploadRate);
     1510                float downloadRate = tr_sessionGetPieceSpeed( fLib, TR_DOWN );
     1511                float uploadRate = tr_sessionGetPieceSpeed( fLib, TR_UP );
    15121512               
    15131513                [fTotalDLField setStringValue: [NSString stringForSpeed: downloadRate]];
  • trunk/macosx/Torrent.m

    r7059 r7069  
    13121312- (CGFloat) downloadRate
    13131313{
    1314     return fStat->rateDownload;
     1314    return fStat->pieceDownloadSpeed;
    13151315}
    13161316
    13171317- (CGFloat) uploadRate
    13181318{
    1319     return fStat->rateUpload;
     1319    return fStat->pieceUploadSpeed;
    13201320}
    13211321
Note: See TracChangeset for help on using the changeset viewer.