Changeset 92


Ignore:
Timestamp:
Feb 7, 2006, 2:32:50 AM (15 years ago)
Author:
titer
Message:

Force rates to 0 when paused, and download rate to 0 when seeding.
Increased OS X UI update interval to 1 second.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/ratecontrol.c

    r87 r92  
    145145}
    146146
    147 void tr_rcClose( tr_ratecontrol_t * r )
     147void tr_rcReset( tr_ratecontrol_t * r )
    148148{
    149149    tr_transfer_t * t, * next;
     150
     151    tr_lockLock( &r->lock );
    150152    for( t = r->first; t; )
    151153    {
     
    154156        t = next;
    155157    }
     158    r->first = NULL;
     159    r->last  = NULL;
     160    tr_lockUnlock( &r->lock );
     161}
     162
     163void tr_rcClose( tr_ratecontrol_t * r )
     164{
     165    tr_rcReset( r );
    156166    tr_lockClose( &r->lock );
    157167    free( r );
  • trunk/libtransmission/ratecontrol.h

    r63 r92  
    2828void               tr_rcTransferred( tr_ratecontrol_t *, int );
    2929float              tr_rcRate( tr_ratecontrol_t * );
     30void               tr_rcReset( tr_ratecontrol_t * );
    3031void               tr_rcClose( tr_ratecontrol_t * );
  • trunk/libtransmission/transmission.c

    r67 r92  
    157157void tr_torrentRates( tr_handle_t * h, float * dl, float * ul )
    158158{
    159     *dl = tr_rcRate( h->download );
    160     *ul = tr_rcRate( h->upload );
     159    tr_torrent_t * tor;
     160    int i;
     161
     162    *dl = 0.0;
     163    *ul = 0.0;
     164    for( i = 0; i < h->torrentCount; i++ )
     165    {
     166        tor = h->torrents[i];
     167        tr_lockLock( &tor->lock );
     168        if( tor->status & TR_STATUS_DOWNLOAD )
     169            *dl += tr_rcRate( tor->download );
     170        *ul += tr_rcRate( tor->upload );
     171        tr_lockUnlock( &tor->lock );
     172    }
    161173}
    162174
     
    302314    tr_lockLock( &tor->lock );
    303315    tr_trackerStopped( tor->tracker );
     316    tr_rcReset( tor->download );
     317    tr_rcReset( tor->upload );
    304318    tor->status = TR_STATUS_STOPPING;
    305319    tor->stopDate = tr_date();
     
    405419
    406420        s[i].progress     = tr_cpCompletionAsFloat( tor->completion );
    407         s[i].rateDownload = tr_rcRate( tor->download );
    408         s[i].rateUpload   = tr_rcRate( tor->upload );
     421        if( tor->status & TR_STATUS_DOWNLOAD )
     422            s[i].rateDownload = tr_rcRate( tor->download );
     423        else
     424            /* tr_rcRate() doesn't make the difference between 'piece'
     425               messages and other messages, which causes a non-zero
     426               download rate even tough we are not downloading. So we
     427               force it to zero not to confuse the user. */
     428            s[i].rateDownload = 0.0;
     429        s[i].rateUpload = tr_rcRate( tor->upload );
    409430       
    410431        s[i].seeders      = tr_trackerSeeders(tor);
  • trunk/macosx/Controller.m

    r78 r92  
    145145    fCompleted = 0;
    146146    fStat  = nil;
    147     fTimer = [NSTimer scheduledTimerWithTimeInterval: 0.5 target: self
     147    fTimer = [NSTimer scheduledTimerWithTimeInterval: 1.0 target: self
    148148        selector: @selector( updateUI: ) userInfo: NULL repeats: YES];
    149149    [[NSRunLoop currentRunLoop] addTimer: fTimer
Note: See TracChangeset for help on using the changeset viewer.