Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Divide by Zero Exception #61

Open
da3dsoul opened this issue Jul 30, 2023 · 0 comments
Open

Divide by Zero Exception #61

da3dsoul opened this issue Jul 30, 2023 · 0 comments

Comments

@da3dsoul
Copy link
Contributor

{"type":1,"target":"AVDump:Message","arguments":[{"filePath":"/shoko/(Hi10)_Bleach_-_Sennen_Kessen-hen_-_14_(1080p)_(Lazy)_(14D12867).mkv","videoID":1,"commandID":4,"type":"Ended","progress":100.0,"success":false,"message":"Testing anidb connection\nAccepted files: 1\n\n","errorMessage":"Unhandled exception. System.DivideByZeroException: Attempted to divide by zero.\nat AVDump3CL.AVD3Console.OnWriteProgress(Object _)\nat System.Threading.TimerQueueTimer.<>c.<.cctor>b__27_0(Object state)\nat System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\n--- End of stack trace from previous location ---\nat System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\nat System.Threading.TimerQueueTimer.CallCallback(Boolean isThreadPool)\nat System.Threading.TimerQueueTimer.Fire(Boolean isThreadPool)\nat System.Threading.TimerQueue.FireNextTimers()\nat System.Threading.TimerQueue.AppDomainTimerCallback(Int32 id)\n","startedAt":"2023-07-30T18:17:17.6700343Z","endedAt":"2023-07-30T18:17:23.2006602Z"}]}�

public void WriteProgress(AVD3ConsoleProgressBuilder pb) {
if(state == 0) {
prevP = curP;
curP = getProgress();
}
var interpolationFactor = (state + 1) / (double)UpdatePeriodInTicks;
state++;
state %= UpdatePeriodInTicks;
var processedMiBsInInterval = ((curP.BytesProcessed - prevP.BytesProcessed) >> 20) / UpdatePeriodInTicks;
if((DateTimeOffset.UtcNow - curP.StartedOn).TotalMinutes < 1) {
var now = DateTimeOffset.UtcNow;
var prevSpeed = (prevP.BytesProcessed >> 20) / (now - prevP.StartedOn).TotalSeconds;
var curSpeed = (curP.BytesProcessed >> 20) / (now - curP.StartedOn).TotalSeconds;
totalSpeedAverages[0] = (float)(prevSpeed + interpolationFactor * (curSpeed - prevSpeed));
} else {
var maInterval = MeanAverageMinuteInterval;
totalSpeedAverages[0] = totalSpeedAverages[0] * (maInterval - 1) / maInterval + (processedMiBsInInterval / (float)AVD3Console.TickPeriod * 1000) / maInterval;
}
if((DateTimeOffset.UtcNow - curP.StartedOn).TotalMinutes < 5) {
totalSpeedAverages[1] = totalSpeedAverages[0];
} else {
var maInterval = MeanAverageMinuteInterval * 5;
totalSpeedAverages[1] = totalSpeedAverages[1] * (maInterval - 1) / maInterval + (processedMiBsInInterval / (float)AVD3Console.TickPeriod * 1000) / maInterval;
}
if((DateTimeOffset.UtcNow - curP.StartedOn).TotalMinutes < 15) {
totalSpeedAverages[2] = totalSpeedAverages[1];
} else {
var maInterval = MeanAverageMinuteInterval * 15;
totalSpeedAverages[2] = totalSpeedAverages[2] * (maInterval - 1) / maInterval + (processedMiBsInInterval / (float)AVD3Console.TickPeriod * 1000) / maInterval;
}
if(totalSpeedAverages[0] > 9999999 || totalSpeedAverages[1] > 9999999 || totalSpeedAverages[2] > 9999999) {
totalSpeedDisplayAverages[0] = (int)totalSpeedAverages[0] >> 20;
totalSpeedDisplayAverages[1] = (int)totalSpeedAverages[1] >> 20;
totalSpeedDisplayAverages[2] = (int)totalSpeedAverages[2] >> 20;
totalSpeedDisplayUnit = "TiB/s";
} else if(totalSpeedAverages[0] > 9999 || totalSpeedAverages[1] > 9999 || totalSpeedAverages[2] > 9999) {
totalSpeedDisplayAverages[0] = (int)totalSpeedAverages[0] >> 10;
totalSpeedDisplayAverages[1] = (int)totalSpeedAverages[1] >> 10;
totalSpeedDisplayAverages[2] = (int)totalSpeedAverages[2] >> 10;
totalSpeedDisplayUnit = "GiB/s";
} else {
totalSpeedDisplayAverages[0] = (int)totalSpeedAverages[0];
totalSpeedDisplayAverages[1] = (int)totalSpeedAverages[1];
totalSpeedDisplayAverages[2] = (int)totalSpeedAverages[2];
totalSpeedDisplayUnit = "MiB/s";
}
Display(pb, interpolationFactor);
pb.SpecialJitterEvent = state == 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant