Changeset 10931 for trunk/libtransmission/torrent.c
- Timestamp:
- Jul 3, 2010, 12:25:22 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/torrent.c
r10919 r10931 130 130 131 131 void 132 tr_torrentSetSpeedLimit ( tr_torrent * tor, tr_direction dir, int KiB_sec)132 tr_torrentSetSpeedLimit_Bps( tr_torrent * tor, tr_direction dir, int Bps ) 133 133 { 134 134 assert( tr_isTorrent( tor ) ); 135 135 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 ) ) 138 139 tr_torrentSetDirty( tor ); 139 140 } 140 141 141 142 int 142 tr_torrentGetSpeedLimit ( const tr_torrent * tor, tr_direction dir )143 tr_torrentGetSpeedLimit_Bps( const tr_torrent * tor, tr_direction dir ) 143 144 { 144 145 assert( tr_isTorrent( tor ) ); 145 146 assert( tr_isDirection( dir ) ); 146 147 147 return tr_bandwidthGetDesiredSpeed ( tor->bandwidth, dir );148 return tr_bandwidthGetDesiredSpeed_Bps( tor->bandwidth, dir ); 148 149 } 149 150 … … 244 245 245 246 if( tr_torrentUsesSpeedLimit( tor, direction ) ) 246 if( tr_torrentGetSpeedLimit ( tor, direction ) <= 0 )247 if( tr_torrentGetSpeedLimit_Bps( tor, direction ) <= 0 ) 247 248 allowed = FALSE; 248 249 249 250 if( tr_torrentUsesSessionLimits( tor ) ) 250 if( tr_sessionGetActiveSpeedLimit ( tor->session, direction, &limit ) )251 if( tr_sessionGetActiveSpeedLimit_Bps( tor->session, direction, &limit ) ) 251 252 if( limit <= 0 ) 252 253 allowed = FALSE; … … 686 687 { 687 688 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 ) ); 689 690 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 ) ); 691 692 tr_torrentUseSessionLimits( tor, TRUE ); 692 693 } … … 967 968 968 969 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 ); 974 975 975 976 usableSeeds += tor->info.webseedCount; … … 1032 1033 case TR_STATUS_DOWNLOAD: 1033 1034 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 */ 1037 1038 tor->etaDLSpeedCalculatedAt = now; 1038 1039 } … … 1040 1041 if( s->leftUntilDone > s->desiredAvailable ) 1041 1042 s->eta = TR_ETA_NOT_AVAIL; 1042 else if( s->pieceDownloadSpeed < 0.1 )1043 else if( s->pieceDownloadSpeed_Bps < 1 ) 1043 1044 s->eta = TR_ETA_UNKNOWN; 1044 1045 else 1045 s->eta = s->leftUntilDone / tor->etaDLSpeed / 1024.0;1046 s->eta = s->leftUntilDone / tor->etaDLSpeed_Bps; 1046 1047 break; 1047 1048 … … 1051 1052 else { 1052 1053 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 */ 1056 1057 tor->etaULSpeedCalculatedAt = now; 1057 1058 } 1058 if( s->pieceUploadSpeed < 0.1 )1059 if( s->pieceUploadSpeed_Bps < 1 ) 1059 1060 s->eta = TR_ETA_UNKNOWN; 1060 1061 else 1061 s->eta = seedRatioBytesLeft / tor->etaULSpeed / 1024.0;1062 s->eta = seedRatioBytesLeft / tor->etaULSpeed_Bps; 1062 1063 } 1063 1064 break; … … 1193 1194 ***/ 1194 1195 1195 float* 1196 tr_torrentWebSpeeds( const tr_torrent * tor ) 1197 { 1198 return tr_isTorrent( tor ) 1199 ? tr_peerMgrWebSpeeds( tor ) 1200 : NULL; 1196 int* 1197 tr_torrentWebSpeeds_Bps( const tr_torrent * tor ) 1198 { 1199 return tr_isTorrent( tor ) ? tr_peerMgrWebSpeeds_Bps( tor ) : NULL; 1201 1200 } 1202 1201
Note: See TracChangeset
for help on using the changeset viewer.