Changeset 13780


Ignore:
Timestamp:
Jan 6, 2013, 8:15:11 PM (8 years ago)
Author:
jordan
Message:

replace tr_torrent's 'float etaSpeed_KBps' field with an 'unsigned int etaSpeed_Bps' field

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r13762 r13780  
    11871187  uint16_t seedIdleMinutes;
    11881188  const uint64_t now = tr_time_msec ();
     1189  unsigned int pieceUploadSpeed_Bps;
     1190  unsigned int pieceDownloadSpeed_Bps;
    11891191
    11901192  assert (tr_isTorrent (tor));
     
    12101212
    12111213  s->rawUploadSpeed_KBps     = toSpeedKBps (tr_bandwidthGetRawSpeed_Bps (&tor->bandwidth, now, TR_UP));
    1212   s->pieceUploadSpeed_KBps   = toSpeedKBps (tr_bandwidthGetPieceSpeed_Bps (&tor->bandwidth, now, TR_UP));
    12131214  s->rawDownloadSpeed_KBps   = toSpeedKBps (tr_bandwidthGetRawSpeed_Bps (&tor->bandwidth, now, TR_DOWN));
    1214   s->pieceDownloadSpeed_KBps = toSpeedKBps (tr_bandwidthGetPieceSpeed_Bps (&tor->bandwidth, now, TR_DOWN));
     1215  pieceUploadSpeed_Bps       = tr_bandwidthGetPieceSpeed_Bps (&tor->bandwidth, now, TR_UP);
     1216  pieceDownloadSpeed_Bps     = tr_bandwidthGetPieceSpeed_Bps (&tor->bandwidth, now, TR_DOWN);
     1217  s->pieceUploadSpeed_KBps   = toSpeedKBps (pieceUploadSpeed_Bps);
     1218  s->pieceDownloadSpeed_KBps = toSpeedKBps (pieceDownloadSpeed_Bps);
    12151219
    12161220  s->percentComplete = tr_cpPercentComplete (&tor->completion);
     
    12511255        if ((tor->etaDLSpeedCalculatedAt + 800) < now)
    12521256          {
    1253             tor->etaDLSpeed_KBps = ((tor->etaDLSpeedCalculatedAt + 4000) < now)
    1254               ? s->pieceDownloadSpeed_KBps /* if no recent previous speed, no need to smooth */
    1255               : ((tor->etaDLSpeed_KBps*4.0) + s->pieceDownloadSpeed_KBps)/5.0; /* smooth across 5 readings */
    12561257            tor->etaDLSpeedCalculatedAt = now;
     1258            tor->etaDLSpeed_Bps = ((tor->etaDLSpeedCalculatedAt + 4000) < now)
     1259              ? pieceDownloadSpeed_Bps /* if no recent previous speed, no need to smooth */
     1260              : ((tor->etaDLSpeed_Bps*4.0) + pieceDownloadSpeed_Bps)/5.0; /* smooth across 5 readings */
    12571261          }
    12581262
    12591263        if ((s->leftUntilDone > s->desiredAvailable) && (tor->info.webseedCount < 1))
    12601264          s->eta = TR_ETA_NOT_AVAIL;
    1261         else if (tor->etaDLSpeed_KBps < 1)
     1265        else if (tor->etaDLSpeed_Bps == 0)
    12621266          s->eta = TR_ETA_UNKNOWN;
    12631267        else
    1264           s->eta = s->leftUntilDone / toSpeedBytes (tor->etaDLSpeed_KBps);
     1268          s->eta = s->leftUntilDone / tor->etaDLSpeed_Bps;
    12651269
    12661270        s->etaIdle = TR_ETA_NOT_AVAIL;
     
    12761280            if ((tor->etaULSpeedCalculatedAt + 800) < now)
    12771281              {
    1278                 tor->etaULSpeed_KBps = ((tor->etaULSpeedCalculatedAt + 4000) < now)
    1279                   ? s->pieceUploadSpeed_KBps /* if no recent previous speed, no need to smooth */
    1280                   : ((tor->etaULSpeed_KBps*4.0) + s->pieceUploadSpeed_KBps)/5.0; /* smooth across 5 readings */
    12811282                tor->etaULSpeedCalculatedAt = now;
     1283                tor->etaULSpeed_Bps = ((tor->etaULSpeedCalculatedAt + 4000) < now)
     1284                  ? pieceUploadSpeed_Bps /* if no recent previous speed, no need to smooth */
     1285                  : ((tor->etaULSpeed_Bps*4.0) + pieceUploadSpeed_Bps)/5.0; /* smooth across 5 readings */
    12821286              }
    12831287
    1284             if (tor->etaULSpeed_KBps < 1)
     1288            if (tor->etaULSpeed_Bps == 0)
    12851289              s->eta = TR_ETA_UNKNOWN;
    12861290            else
    1287               s->eta = seedRatioBytesLeft / toSpeedBytes (tor->etaULSpeed_KBps);
     1291              s->eta = seedRatioBytesLeft / tor->etaULSpeed_Bps;
    12881292          }
    12891293
    1290         if (tor->etaULSpeed_KBps < 1 && tr_torrentGetSeedIdle (tor, &seedIdleMinutes))
     1294        if (tor->etaULSpeed_Bps < 1 && tr_torrentGetSeedIdle (tor, &seedIdleMinutes))
    12911295          s->etaIdle = seedIdleMinutes * 60 - s->idleSecs;
    12921296        else
  • trunk/libtransmission/torrent.h

    r13670 r13780  
    212212
    213213    uint64_t                   etaDLSpeedCalculatedAt;
    214     float                      etaDLSpeed_KBps;
     214    unsigned int               etaDLSpeed_Bps;
    215215    uint64_t                   etaULSpeedCalculatedAt;
    216     float                      etaULSpeed_KBps;
     216    unsigned int               etaULSpeed_Bps;
    217217
    218218    time_t                     addedDate;
Note: See TracChangeset for help on using the changeset viewer.