http://bugs.gpodder.org/show_bug.cgi?id=69





--- Comment #8 from Thomas Perl <[EMAIL PROTECTED]>  2008-04-02 21:10:07 ---
You have to change the "calculate_speed" function in DownloadThread in
"/src/gpodder/download.py". The reason this function is buggy is because when I
initially wrote it, I didn't think about changing or enabling the throttling
when a download is running. Therefore, my calculation is very simple:

* Remember the start time
* downloaded bytes = count*blockSize
* Use (now - start_time) and downloaded bytes to calculate the real speed
* Use the desired speed, (now - start_time) and downloaded bytes to calculate
the time we have to sleep to get the desired speed (with an upper limit of 10
seconds to prevent timeouts)

With a bit of math and some saved values (maybe a timestamp -> downloaded_bytes
mapping), it should be easy to calculate the average speed for the last minute
(or so) and, based on that, calculate the needed amount of time to sleep (if
any).

Basically the same algorithm, but the start_time is replaced by the last
timestamp and the downloaded bytes are reduced by the amount of bytes
downloaded at the time of the last timestamp. Can you still follow me? ;)


-- 
Configure bugmail: http://bugs.gpodder.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.
_______________________________________________
gPodder-Bugs mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/gpodder-bugs

Reply via email to