Ignore:
Timestamp:
Jul 3, 2010, 12:25:22 AM (12 years ago)
Author:
charles
Message:

(trunk) #3045 "make libtransmission's API byte-oriented instead of KiB-oriented." -- implemented. This is a largish commit and will break the mac build for a little while.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r10919 r10931  
    130130
    131131void
    132 tr_torrentSetSpeedLimit( tr_torrent * tor, tr_direction dir, int KiB_sec )
     132tr_torrentSetSpeedLimit_Bps( tr_torrent * tor, tr_direction dir, int Bps )
    133133{
    134134    assert( tr_isTorrent( tor ) );
    135135    assert( tr_isDirection( dir ) );
    136 
    137     if( tr_bandwidthSetDesiredSpeed( tor->bandwidth, dir, KiB_sec ) )
     136    assert( Bps >= 0 );
     137
     138    if( tr_bandwidthSetDesiredSpeed_Bps( tor->bandwidth, dir, Bps ) )
    138139        tr_torrentSetDirty( tor );
    139140}
    140141
    141142int
    142 tr_torrentGetSpeedLimit( const tr_torrent * tor, tr_direction dir )
     143tr_torrentGetSpeedLimit_Bps( const tr_torrent * tor, tr_direction dir )
    143144{
    144145    assert( tr_isTorrent( tor ) );
    145146    assert( tr_isDirection( dir ) );
    146147
    147     return tr_bandwidthGetDesiredSpeed( tor->bandwidth, dir );
     148    return tr_bandwidthGetDesiredSpeed_Bps( tor->bandwidth, dir );
    148149}
    149150
     
    244245
    245246    if( tr_torrentUsesSpeedLimit( tor, direction ) )
    246         if( tr_torrentGetSpeedLimit( tor, direction ) <= 0 )
     247        if( tr_torrentGetSpeedLimit_Bps( tor, direction ) <= 0 )
    247248            allowed = FALSE;
    248249
    249250    if( tr_torrentUsesSessionLimits( tor ) )
    250         if( tr_sessionGetActiveSpeedLimit( tor->session, direction, &limit ) )
     251        if( tr_sessionGetActiveSpeedLimit_Bps( tor->session, direction, &limit ) )
    251252            if( limit <= 0 )
    252253                allowed = FALSE;
     
    686687    {
    687688        tr_torrentUseSpeedLimit( tor, TR_UP, FALSE );
    688         tr_torrentSetSpeedLimit( tor, TR_UP, tr_sessionGetSpeedLimit( tor->session, TR_UP ) );
     689        tr_torrentSetSpeedLimit_Bps( tor, TR_UP, tr_sessionGetSpeedLimit_Bps( tor->session, TR_UP ) );
    689690        tr_torrentUseSpeedLimit( tor, TR_DOWN, FALSE );
    690         tr_torrentSetSpeedLimit( tor, TR_DOWN, tr_sessionGetSpeedLimit( tor->session, TR_DOWN ) );
     691        tr_torrentSetSpeedLimit_Bps( tor, TR_DOWN, tr_sessionGetSpeedLimit_Bps( tor->session, TR_DOWN ) );
    691692        tr_torrentUseSessionLimits( tor, TRUE );
    692693    }
     
    967968
    968969    now = tr_date( );
    969     d = tr_peerMgrGetWebseedSpeed( tor, now );
    970     s->rawUploadSpeed     = tr_bandwidthGetRawSpeed  ( tor->bandwidth, now, TR_UP );
    971     s->pieceUploadSpeed   = tr_bandwidthGetPieceSpeed( tor->bandwidth, now, TR_UP );
    972     s->rawDownloadSpeed   = d + tr_bandwidthGetRawSpeed  ( tor->bandwidth, now, TR_DOWN );
    973     s->pieceDownloadSpeed = d + tr_bandwidthGetPieceSpeed( tor->bandwidth, now, TR_DOWN );
     970    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 );
    974975
    975976    usableSeeds += tor->info.webseedCount;
     
    10321033        case TR_STATUS_DOWNLOAD:
    10331034            if( ( tor->etaDLSpeedCalculatedAt + 800 ) < now ) {
    1034                 tor->etaDLSpeed = ( ( tor->etaDLSpeedCalculatedAt + 4000 ) < now )
    1035                     ? s->pieceDownloadSpeed /* if no recent previous speed, no need to smooth */
    1036                     : 0.8*tor->etaDLSpeed + 0.2*s->pieceDownloadSpeed; /* smooth across 5 readings */
     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 */
    10371038                tor->etaDLSpeedCalculatedAt = now;
    10381039            }
     
    10401041            if( s->leftUntilDone > s->desiredAvailable )
    10411042                s->eta = TR_ETA_NOT_AVAIL;
    1042             else if( s->pieceDownloadSpeed < 0.1 )
     1043            else if( s->pieceDownloadSpeed_Bps < 1 )
    10431044                s->eta = TR_ETA_UNKNOWN;
    10441045            else
    1045                 s->eta = s->leftUntilDone / tor->etaDLSpeed / 1024.0;
     1046                s->eta = s->leftUntilDone / tor->etaDLSpeed_Bps;
    10461047            break;
    10471048
     
    10511052            else {
    10521053                if( ( tor->etaULSpeedCalculatedAt + 800 ) < now ) {
    1053                     tor->etaULSpeed = ( ( tor->etaULSpeedCalculatedAt + 4000 ) < now )
    1054                         ? s->pieceUploadSpeed /* if no recent previous speed, no need to smooth */
    1055                         : 0.8*tor->etaULSpeed + 0.2*s->pieceUploadSpeed; /* smooth across 5 readings */
     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 */
    10561057                    tor->etaULSpeedCalculatedAt = now;
    10571058                }
    1058                 if( s->pieceUploadSpeed < 0.1 )
     1059                if( s->pieceUploadSpeed_Bps < 1 )
    10591060                    s->eta = TR_ETA_UNKNOWN;
    10601061                else
    1061                     s->eta = seedRatioBytesLeft / tor->etaULSpeed / 1024.0;
     1062                    s->eta = seedRatioBytesLeft / tor->etaULSpeed_Bps;
    10621063            }
    10631064            break;
     
    11931194***/
    11941195
    1195 float*
    1196 tr_torrentWebSpeeds( const tr_torrent * tor )
    1197 {
    1198     return tr_isTorrent( tor )
    1199          ? tr_peerMgrWebSpeeds( tor )
    1200          : NULL;
     1196int*
     1197tr_torrentWebSpeeds_Bps( const tr_torrent * tor )
     1198{
     1199    return tr_isTorrent( tor ) ? tr_peerMgrWebSpeeds_Bps( tor ) : NULL;
    12011200}
    12021201
Note: See TracChangeset for help on using the changeset viewer.