Ignore:
Timestamp:
Jul 4, 2010, 6:07:21 AM (12 years ago)
Author:
charles
Message:

(trunk) #3045 "speed units" -- change the public API of libtransmission based on feedback from livings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r10935 r10937  
    139139        tr_torrentSetDirty( tor );
    140140}
     141void
     142tr_torrentSetSpeedLimit_KBps( tr_torrent * tor, tr_direction dir, int KBps )
     143{
     144    tr_torrentSetSpeedLimit_Bps( tor, dir, toSpeedBytes( KBps ) );
     145}
    141146
    142147int
     
    147152
    148153    return tr_bandwidthGetDesiredSpeed_Bps( tor->bandwidth, dir );
     154}
     155int
     156tr_torrentGetSpeedLimit_KBps( const tr_torrent * tor, tr_direction dir )
     157{
     158    return toSpeedKBps( tr_torrentGetSpeedLimit_Bps( tor, dir ) );
    149159}
    150160
     
    969979    now = tr_date( );
    970980    d = tr_peerMgrGetWebseedSpeed_Bps( tor, now );
    971     s->rawUploadSpeed_Bps     = tr_bandwidthGetRawSpeed_Bps  ( tor->bandwidth, now, TR_UP );
    972     s->pieceUploadSpeed_Bps   = tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_UP );
    973     s->rawDownloadSpeed_Bps   = d + tr_bandwidthGetRawSpeed_Bps  ( tor->bandwidth, now, TR_DOWN );
    974     s->pieceDownloadSpeed_Bps = d + tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_DOWN );
     981    s->rawUploadSpeed_KBps     = toSpeedKBps( tr_bandwidthGetRawSpeed_Bps  ( tor->bandwidth, now, TR_UP ) );
     982    s->pieceUploadSpeed_KBps   = toSpeedKBps( tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_UP ) );
     983    s->rawDownloadSpeed_KBps   = toSpeedKBps( d + tr_bandwidthGetRawSpeed_Bps  ( tor->bandwidth, now, TR_DOWN ) );
     984    s->pieceDownloadSpeed_KBps = toSpeedKBps( d + tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_DOWN ) );
    975985
    976986    usableSeeds += tor->info.webseedCount;
     
    10331043        case TR_STATUS_DOWNLOAD:
    10341044            if( ( tor->etaDLSpeedCalculatedAt + 800 ) < now ) {
    1035                 tor->etaDLSpeed_Bps = ( ( tor->etaDLSpeedCalculatedAt + 4000 ) < now )
    1036                     ? s->pieceDownloadSpeed_Bps /* if no recent previous speed, no need to smooth */
    1037                     : ((tor->etaDLSpeed_Bps*4) + s->pieceDownloadSpeed_Bps)/5; /* smooth across 5 readings */
     1045                tor->etaDLSpeed_KBps = ( ( tor->etaDLSpeedCalculatedAt + 4000 ) < now )
     1046                    ? s->pieceDownloadSpeed_KBps /* if no recent previous speed, no need to smooth */
     1047                    : ((tor->etaDLSpeed_KBps*4.0) + s->pieceDownloadSpeed_KBps)/5.0; /* smooth across 5 readings */
    10381048                tor->etaDLSpeedCalculatedAt = now;
    10391049            }
     
    10411051            if( s->leftUntilDone > s->desiredAvailable )
    10421052                s->eta = TR_ETA_NOT_AVAIL;
    1043             else if( s->pieceDownloadSpeed_Bps < 1 )
     1053            else if( tor->etaDLSpeed_KBps < 1 )
    10441054                s->eta = TR_ETA_UNKNOWN;
    10451055            else
    1046                 s->eta = s->leftUntilDone / tor->etaDLSpeed_Bps;
     1056                s->eta = s->leftUntilDone / toSpeedBytes(tor->etaDLSpeed_KBps);
    10471057            break;
    10481058
     
    10521062            else {
    10531063                if( ( tor->etaULSpeedCalculatedAt + 800 ) < now ) {
    1054                     tor->etaULSpeed_Bps = ( ( tor->etaULSpeedCalculatedAt + 4000 ) < now )
    1055                         ? s->pieceUploadSpeed_Bps /* if no recent previous speed, no need to smooth */
    1056                         : ((tor->etaULSpeed_Bps*4) + s->pieceUploadSpeed_Bps)/5; /* smooth across 5 readings */
     1064                    tor->etaULSpeed_KBps = ( ( tor->etaULSpeedCalculatedAt + 4000 ) < now )
     1065                        ? s->pieceUploadSpeed_KBps /* if no recent previous speed, no need to smooth */
     1066                        : ((tor->etaULSpeed_KBps*4.0) + s->pieceUploadSpeed_KBps)/5.0; /* smooth across 5 readings */
    10571067                    tor->etaULSpeedCalculatedAt = now;
    10581068                }
    1059                 if( s->pieceUploadSpeed_Bps < 1 )
     1069                if( tor->etaULSpeed_KBps < 1 )
    10601070                    s->eta = TR_ETA_UNKNOWN;
    10611071                else
    1062                     s->eta = seedRatioBytesLeft / tor->etaULSpeed_Bps;
     1072                    s->eta = seedRatioBytesLeft / toSpeedBytes(tor->etaULSpeed_KBps);
    10631073            }
    10641074            break;
     
    11941204***/
    11951205
    1196 int*
    1197 tr_torrentWebSpeeds_Bps( const tr_torrent * tor )
    1198 {
    1199     return tr_isTorrent( tor ) ? tr_peerMgrWebSpeeds_Bps( tor ) : NULL;
     1206double*
     1207tr_torrentWebSpeeds_KBps( const tr_torrent * tor )
     1208{
     1209    return tr_isTorrent( tor ) ? tr_peerMgrWebSpeeds_KBps( tor ) : NULL;
    12001210}
    12011211
Note: See TracChangeset for help on using the changeset viewer.