Mercurial > hg > vamp-plugin-sdk
comparison src/vamp-sdk/RealTime.cpp @ 414:6f88563ea26f
Avoid endless recursion if NaN passed to fromSeconds
author | Chris Cannam |
---|---|
date | Fri, 04 Sep 2015 13:47:25 +0100 |
parents | 3ee97caa8fb6 |
children | 35fa4733bc5d |
comparison
equal
deleted
inserted
replaced
413:3ee97caa8fb6 | 414:6f88563ea26f |
---|---|
90 } | 90 } |
91 | 91 |
92 RealTime | 92 RealTime |
93 RealTime::fromSeconds(double sec) | 93 RealTime::fromSeconds(double sec) |
94 { | 94 { |
95 if (sec >= 0) { | 95 if (sec != sec) { // NaN |
96 cerr << "ERROR: NaN/Inf passed to Vamp::RealTime::fromSeconds" << endl; | |
97 return RealTime::zeroTime; | |
98 } else if (sec >= 0) { | |
96 return RealTime(int(sec), int((sec - int(sec)) * ONE_BILLION + 0.5)); | 99 return RealTime(int(sec), int((sec - int(sec)) * ONE_BILLION + 0.5)); |
97 } else { | 100 } else { |
98 return -fromSeconds(-sec); | 101 return -fromSeconds(-sec); |
99 } | 102 } |
100 } | 103 } |