comparison data/fft/FFTDataServer.cpp @ 929:59e7fe1b1003 warnfix_no_size_t

Unsigned removals and warning fixes in data/
author Chris Cannam
date Tue, 17 Jun 2014 14:33:42 +0100
parents 166e3fc1e962
children e8e6c4e7437b
comparison
equal deleted inserted replaced
928:6a94bb528e9d 929:59e7fe1b1003
46 46
47 FFTDataServer * 47 FFTDataServer *
48 FFTDataServer::getInstance(const DenseTimeValueModel *model, 48 FFTDataServer::getInstance(const DenseTimeValueModel *model,
49 int channel, 49 int channel,
50 WindowType windowType, 50 WindowType windowType,
51 size_t windowSize, 51 int windowSize,
52 size_t windowIncrement, 52 int windowIncrement,
53 size_t fftSize, 53 int fftSize,
54 bool polar, 54 bool polar,
55 StorageAdviser::Criteria criteria, 55 StorageAdviser::Criteria criteria,
56 size_t fillFromColumn) 56 int fillFromColumn)
57 { 57 {
58 QString n = generateFileBasename(model, 58 QString n = generateFileBasename(model,
59 channel, 59 channel,
60 windowType, 60 windowType,
61 windowSize, 61 windowSize,
108 108
109 FFTDataServer * 109 FFTDataServer *
110 FFTDataServer::getFuzzyInstance(const DenseTimeValueModel *model, 110 FFTDataServer::getFuzzyInstance(const DenseTimeValueModel *model,
111 int channel, 111 int channel,
112 WindowType windowType, 112 WindowType windowType,
113 size_t windowSize, 113 int windowSize,
114 size_t windowIncrement, 114 int windowIncrement,
115 size_t fftSize, 115 int fftSize,
116 bool polar, 116 bool polar,
117 StorageAdviser::Criteria criteria, 117 StorageAdviser::Criteria criteria,
118 size_t fillFromColumn) 118 int fillFromColumn)
119 { 119 {
120 // Fuzzy matching: 120 // Fuzzy matching:
121 // 121 //
122 // -- if we're asked for polar and have non-polar, use it (and 122 // -- if we're asked for polar and have non-polar, use it (and
123 // vice versa). This one is vital, and we do it for non-fuzzy as 123 // vice versa). This one is vital, and we do it for non-fuzzy as
481 481
482 FFTDataServer::FFTDataServer(QString fileBaseName, 482 FFTDataServer::FFTDataServer(QString fileBaseName,
483 const DenseTimeValueModel *model, 483 const DenseTimeValueModel *model,
484 int channel, 484 int channel,
485 WindowType windowType, 485 WindowType windowType,
486 size_t windowSize, 486 int windowSize,
487 size_t windowIncrement, 487 int windowIncrement,
488 size_t fftSize, 488 int fftSize,
489 bool polar, 489 bool polar,
490 StorageAdviser::Criteria criteria, 490 StorageAdviser::Criteria criteria,
491 size_t fillFromColumn) : 491 int fillFromColumn) :
492 m_fileBaseName(fileBaseName), 492 m_fileBaseName(fileBaseName),
493 m_model(model), 493 m_model(model),
494 m_channel(channel), 494 m_channel(channel),
495 m_windower(windowType, windowSize), 495 m_windower(windowType, windowSize),
496 m_windowSize(windowSize), 496 m_windowSize(windowSize),
512 cerr << "FFTDataServer(" << this << " [" << (void *)QThread::currentThreadId() << "])::FFTDataServer" << endl; 512 cerr << "FFTDataServer(" << this << " [" << (void *)QThread::currentThreadId() << "])::FFTDataServer" << endl;
513 #endif 513 #endif
514 514
515 //!!! end is not correct until model finished reading -- what to do??? 515 //!!! end is not correct until model finished reading -- what to do???
516 516
517 size_t start = m_model->getStartFrame(); 517 int start = m_model->getStartFrame();
518 size_t end = m_model->getEndFrame(); 518 int end = m_model->getEndFrame();
519 519
520 m_width = (end - start) / m_windowIncrement + 1; 520 m_width = (end - start) / m_windowIncrement + 1;
521 m_height = m_fftSize / 2 + 1; // DC == 0, Nyquist == fftsize/2 521 m_height = m_fftSize / 2 + 1; // DC == 0, Nyquist == fftsize/2
522 522
523 #ifdef DEBUG_FFT_SERVER 523 #ifdef DEBUG_FFT_SERVER
524 cerr << "FFTDataServer(" << this << "): dimensions are " 524 cerr << "FFTDataServer(" << this << "): dimensions are "
525 << m_width << "x" << m_height << endl; 525 << m_width << "x" << m_height << endl;
526 #endif 526 #endif
527 527
528 size_t maxCacheSize = 20 * 1024 * 1024; 528 int maxCacheSize = 20 * 1024 * 1024;
529 size_t columnSize = m_height * sizeof(fftsample) * 2 + sizeof(fftsample); 529 int columnSize = m_height * sizeof(fftsample) * 2 + sizeof(fftsample);
530 if (m_width * columnSize < maxCacheSize * 2) m_cacheWidth = m_width; 530 if (m_width * columnSize < maxCacheSize * 2) m_cacheWidth = m_width;
531 else m_cacheWidth = maxCacheSize / columnSize; 531 else m_cacheWidth = maxCacheSize / columnSize;
532 532
533 #ifdef DEBUG_FFT_SERVER 533 #ifdef DEBUG_FFT_SERVER
534 cerr << "FFTDataServer(" << this << "): cache width nominal " 534 cerr << "FFTDataServer(" << this << "): cache width nominal "
560 m_criteria = StorageAdviser::Criteria 560 m_criteria = StorageAdviser::Criteria
561 (StorageAdviser::PrecisionCritical); 561 (StorageAdviser::PrecisionCritical);
562 } 562 }
563 } 563 }
564 564
565 for (size_t i = 0; i <= m_width / m_cacheWidth; ++i) { 565 for (int i = 0; i <= m_width / m_cacheWidth; ++i) {
566 m_caches.push_back(0); 566 m_caches.push_back(0);
567 } 567 }
568 568
569 m_fftInput = (fftsample *) 569 m_fftInput = (fftsample *)
570 fftf_malloc(fftSize * sizeof(fftsample)); 570 fftf_malloc(fftSize * sizeof(fftsample));
676 } 676 }
677 } 677 }
678 } 678 }
679 679
680 void 680 void
681 FFTDataServer::getStorageAdvice(size_t w, size_t h, 681 FFTDataServer::getStorageAdvice(int w, int h,
682 bool &memoryCache, bool &compactCache) 682 bool &memoryCache, bool &compactCache)
683 { 683 {
684 int cells = w * h; 684 int cells = w * h;
685 int minimumSize = (cells / 1024) * sizeof(uint16_t); // kb 685 int minimumSize = (cells / 1024) * sizeof(uint16_t); // kb
686 int maximumSize = (cells / 1024) * sizeof(float); // kb 686 int maximumSize = (cells / 1024) * sizeof(float); // kb
761 761
762 CacheBlock *cb = new CacheBlock; 762 CacheBlock *cb = new CacheBlock;
763 763
764 QString name = QString("%1-%2").arg(m_fileBaseName).arg(c); 764 QString name = QString("%1-%2").arg(m_fileBaseName).arg(c);
765 765
766 size_t width = m_cacheWidth; 766 int width = m_cacheWidth;
767 if (c * m_cacheWidth + width > m_width) { 767 if (c * m_cacheWidth + width > m_width) {
768 width = m_width - c * m_cacheWidth; 768 width = m_width - c * m_cacheWidth;
769 } 769 }
770 770
771 bool memoryCache = false; 771 bool memoryCache = false;
883 883
884 return true; 884 return true;
885 } 885 }
886 886
887 float 887 float
888 FFTDataServer::getMagnitudeAt(size_t x, size_t y) 888 FFTDataServer::getMagnitudeAt(int x, int y)
889 { 889 {
890 Profiler profiler("FFTDataServer::getMagnitudeAt", false); 890 Profiler profiler("FFTDataServer::getMagnitudeAt", false);
891 891
892 if (x >= m_width || y >= m_height) return 0; 892 if (x >= m_width || y >= m_height) return 0;
893 893
894 float val = 0; 894 float val = 0;
895 895
896 try { 896 try {
897 size_t col; 897 int col;
898 FFTCacheReader *cache = getCacheReader(x, col); 898 FFTCacheReader *cache = getCacheReader(x, col);
899 if (!cache) return 0; 899 if (!cache) return 0;
900 900
901 if (!cache->haveSetColumnAt(col)) { 901 if (!cache->haveSetColumnAt(col)) {
902 Profiler profiler("FFTDataServer::getMagnitudeAt: filling"); 902 Profiler profiler("FFTDataServer::getMagnitudeAt: filling");
915 915
916 return val; 916 return val;
917 } 917 }
918 918
919 bool 919 bool
920 FFTDataServer::getMagnitudesAt(size_t x, float *values, size_t minbin, size_t count, size_t step) 920 FFTDataServer::getMagnitudesAt(int x, float *values, int minbin, int count, int step)
921 { 921 {
922 Profiler profiler("FFTDataServer::getMagnitudesAt", false); 922 Profiler profiler("FFTDataServer::getMagnitudesAt", false);
923 923
924 if (x >= m_width) return false; 924 if (x >= m_width) return false;
925 925
928 else if (minbin + count * step > m_height) { 928 else if (minbin + count * step > m_height) {
929 count = (m_height - minbin) / step; 929 count = (m_height - minbin) / step;
930 } 930 }
931 931
932 try { 932 try {
933 size_t col; 933 int col;
934 FFTCacheReader *cache = getCacheReader(x, col); 934 FFTCacheReader *cache = getCacheReader(x, col);
935 if (!cache) return false; 935 if (!cache) return false;
936 936
937 if (!cache->haveSetColumnAt(col)) { 937 if (!cache->haveSetColumnAt(col)) {
938 Profiler profiler("FFTDataServer::getMagnitudesAt: filling"); 938 Profiler profiler("FFTDataServer::getMagnitudesAt: filling");
948 948
949 return true; 949 return true;
950 } 950 }
951 951
952 float 952 float
953 FFTDataServer::getNormalizedMagnitudeAt(size_t x, size_t y) 953 FFTDataServer::getNormalizedMagnitudeAt(int x, int y)
954 { 954 {
955 Profiler profiler("FFTDataServer::getNormalizedMagnitudeAt", false); 955 Profiler profiler("FFTDataServer::getNormalizedMagnitudeAt", false);
956 956
957 if (x >= m_width || y >= m_height) return 0; 957 if (x >= m_width || y >= m_height) return 0;
958 958
959 float val = 0; 959 float val = 0;
960 960
961 try { 961 try {
962 962
963 size_t col; 963 int col;
964 FFTCacheReader *cache = getCacheReader(x, col); 964 FFTCacheReader *cache = getCacheReader(x, col);
965 if (!cache) return 0; 965 if (!cache) return 0;
966 966
967 if (!cache->haveSetColumnAt(col)) { 967 if (!cache->haveSetColumnAt(col)) {
968 Profiler profiler("FFTDataServer::getNormalizedMagnitudeAt: filling"); 968 Profiler profiler("FFTDataServer::getNormalizedMagnitudeAt: filling");
976 976
977 return val; 977 return val;
978 } 978 }
979 979
980 bool 980 bool
981 FFTDataServer::getNormalizedMagnitudesAt(size_t x, float *values, size_t minbin, size_t count, size_t step) 981 FFTDataServer::getNormalizedMagnitudesAt(int x, float *values, int minbin, int count, int step)
982 { 982 {
983 Profiler profiler("FFTDataServer::getNormalizedMagnitudesAt", false); 983 Profiler profiler("FFTDataServer::getNormalizedMagnitudesAt", false);
984 984
985 if (x >= m_width) return false; 985 if (x >= m_width) return false;
986 986
990 count = (m_height - minbin) / step; 990 count = (m_height - minbin) / step;
991 } 991 }
992 992
993 try { 993 try {
994 994
995 size_t col; 995 int col;
996 FFTCacheReader *cache = getCacheReader(x, col); 996 FFTCacheReader *cache = getCacheReader(x, col);
997 if (!cache) return false; 997 if (!cache) return false;
998 998
999 if (!cache->haveSetColumnAt(col)) { 999 if (!cache->haveSetColumnAt(col)) {
1000 Profiler profiler("FFTDataServer::getNormalizedMagnitudesAt: filling"); 1000 Profiler profiler("FFTDataServer::getNormalizedMagnitudesAt: filling");
1001 fillColumn(x); 1001 fillColumn(x);
1002 } 1002 }
1003 1003
1004 for (size_t i = 0; i < count; ++i) { 1004 for (int i = 0; i < count; ++i) {
1005 values[i] = cache->getNormalizedMagnitudeAt(col, i * step + minbin); 1005 values[i] = cache->getNormalizedMagnitudeAt(col, i * step + minbin);
1006 } 1006 }
1007 1007
1008 } catch (std::exception &e) { 1008 } catch (std::exception &e) {
1009 m_error = e.what(); 1009 m_error = e.what();
1012 1012
1013 return true; 1013 return true;
1014 } 1014 }
1015 1015
1016 float 1016 float
1017 FFTDataServer::getMaximumMagnitudeAt(size_t x) 1017 FFTDataServer::getMaximumMagnitudeAt(int x)
1018 { 1018 {
1019 Profiler profiler("FFTDataServer::getMaximumMagnitudeAt", false); 1019 Profiler profiler("FFTDataServer::getMaximumMagnitudeAt", false);
1020 1020
1021 if (x >= m_width) return 0; 1021 if (x >= m_width) return 0;
1022 1022
1023 float val = 0; 1023 float val = 0;
1024 1024
1025 try { 1025 try {
1026 1026
1027 size_t col; 1027 int col;
1028 FFTCacheReader *cache = getCacheReader(x, col); 1028 FFTCacheReader *cache = getCacheReader(x, col);
1029 if (!cache) return 0; 1029 if (!cache) return 0;
1030 1030
1031 if (!cache->haveSetColumnAt(col)) { 1031 if (!cache->haveSetColumnAt(col)) {
1032 Profiler profiler("FFTDataServer::getMaximumMagnitudeAt: filling"); 1032 Profiler profiler("FFTDataServer::getMaximumMagnitudeAt: filling");
1040 1040
1041 return val; 1041 return val;
1042 } 1042 }
1043 1043
1044 float 1044 float
1045 FFTDataServer::getPhaseAt(size_t x, size_t y) 1045 FFTDataServer::getPhaseAt(int x, int y)
1046 { 1046 {
1047 Profiler profiler("FFTDataServer::getPhaseAt", false); 1047 Profiler profiler("FFTDataServer::getPhaseAt", false);
1048 1048
1049 if (x >= m_width || y >= m_height) return 0; 1049 if (x >= m_width || y >= m_height) return 0;
1050 1050
1051 float val = 0; 1051 float val = 0;
1052 1052
1053 try { 1053 try {
1054 1054
1055 size_t col; 1055 int col;
1056 FFTCacheReader *cache = getCacheReader(x, col); 1056 FFTCacheReader *cache = getCacheReader(x, col);
1057 if (!cache) return 0; 1057 if (!cache) return 0;
1058 1058
1059 if (!cache->haveSetColumnAt(col)) { 1059 if (!cache->haveSetColumnAt(col)) {
1060 Profiler profiler("FFTDataServer::getPhaseAt: filling"); 1060 Profiler profiler("FFTDataServer::getPhaseAt: filling");
1068 1068
1069 return val; 1069 return val;
1070 } 1070 }
1071 1071
1072 bool 1072 bool
1073 FFTDataServer::getPhasesAt(size_t x, float *values, size_t minbin, size_t count, size_t step) 1073 FFTDataServer::getPhasesAt(int x, float *values, int minbin, int count, int step)
1074 { 1074 {
1075 Profiler profiler("FFTDataServer::getPhasesAt", false); 1075 Profiler profiler("FFTDataServer::getPhasesAt", false);
1076 1076
1077 if (x >= m_width) return false; 1077 if (x >= m_width) return false;
1078 1078
1082 count = (m_height - minbin) / step; 1082 count = (m_height - minbin) / step;
1083 } 1083 }
1084 1084
1085 try { 1085 try {
1086 1086
1087 size_t col; 1087 int col;
1088 FFTCacheReader *cache = getCacheReader(x, col); 1088 FFTCacheReader *cache = getCacheReader(x, col);
1089 if (!cache) return false; 1089 if (!cache) return false;
1090 1090
1091 if (!cache->haveSetColumnAt(col)) { 1091 if (!cache->haveSetColumnAt(col)) {
1092 Profiler profiler("FFTDataServer::getPhasesAt: filling"); 1092 Profiler profiler("FFTDataServer::getPhasesAt: filling");
1093 fillColumn(x); 1093 fillColumn(x);
1094 } 1094 }
1095 1095
1096 for (size_t i = 0; i < count; ++i) { 1096 for (int i = 0; i < count; ++i) {
1097 values[i] = cache->getPhaseAt(col, i * step + minbin); 1097 values[i] = cache->getPhaseAt(col, i * step + minbin);
1098 } 1098 }
1099 1099
1100 } catch (std::exception &e) { 1100 } catch (std::exception &e) {
1101 m_error = e.what(); 1101 m_error = e.what();
1104 1104
1105 return true; 1105 return true;
1106 } 1106 }
1107 1107
1108 void 1108 void
1109 FFTDataServer::getValuesAt(size_t x, size_t y, float &real, float &imaginary) 1109 FFTDataServer::getValuesAt(int x, int y, float &real, float &imaginary)
1110 { 1110 {
1111 Profiler profiler("FFTDataServer::getValuesAt", false); 1111 Profiler profiler("FFTDataServer::getValuesAt", false);
1112 1112
1113 if (x >= m_width || y >= m_height) { 1113 if (x >= m_width || y >= m_height) {
1114 real = 0; 1114 real = 0;
1116 return; 1116 return;
1117 } 1117 }
1118 1118
1119 try { 1119 try {
1120 1120
1121 size_t col; 1121 int col;
1122 FFTCacheReader *cache = getCacheReader(x, col); 1122 FFTCacheReader *cache = getCacheReader(x, col);
1123 1123
1124 if (!cache) { 1124 if (!cache) {
1125 real = 0; 1125 real = 0;
1126 imaginary = 0; 1126 imaginary = 0;
1141 m_error = e.what(); 1141 m_error = e.what();
1142 } 1142 }
1143 } 1143 }
1144 1144
1145 bool 1145 bool
1146 FFTDataServer::getValuesAt(size_t x, float *reals, float *imaginaries, size_t minbin, size_t count, size_t step) 1146 FFTDataServer::getValuesAt(int x, float *reals, float *imaginaries, int minbin, int count, int step)
1147 { 1147 {
1148 Profiler profiler("FFTDataServer::getValuesAt", false); 1148 Profiler profiler("FFTDataServer::getValuesAt", false);
1149 1149
1150 if (x >= m_width) return false; 1150 if (x >= m_width) return false;
1151 1151
1155 count = (m_height - minbin) / step; 1155 count = (m_height - minbin) / step;
1156 } 1156 }
1157 1157
1158 try { 1158 try {
1159 1159
1160 size_t col; 1160 int col;
1161 FFTCacheReader *cache = getCacheReader(x, col); 1161 FFTCacheReader *cache = getCacheReader(x, col);
1162 if (!cache) return false; 1162 if (!cache) return false;
1163 1163
1164 if (!cache->haveSetColumnAt(col)) { 1164 if (!cache->haveSetColumnAt(col)) {
1165 Profiler profiler("FFTDataServer::getValuesAt: filling"); 1165 Profiler profiler("FFTDataServer::getValuesAt: filling");
1166 fillColumn(x); 1166 fillColumn(x);
1167 } 1167 }
1168 1168
1169 for (size_t i = 0; i < count; ++i) { 1169 for (int i = 0; i < count; ++i) {
1170 cache->getValuesAt(col, i * step + minbin, reals[i], imaginaries[i]); 1170 cache->getValuesAt(col, i * step + minbin, reals[i], imaginaries[i]);
1171 } 1171 }
1172 1172
1173 } catch (std::exception &e) { 1173 } catch (std::exception &e) {
1174 m_error = e.what(); 1174 m_error = e.what();
1177 1177
1178 return true; 1178 return true;
1179 } 1179 }
1180 1180
1181 bool 1181 bool
1182 FFTDataServer::isColumnReady(size_t x) 1182 FFTDataServer::isColumnReady(int x)
1183 { 1183 {
1184 Profiler profiler("FFTDataServer::isColumnReady", false); 1184 Profiler profiler("FFTDataServer::isColumnReady", false);
1185 1185
1186 if (x >= m_width) return true; 1186 if (x >= m_width) return true;
1187 1187
1198 return false; 1198 return false;
1199 } 1199 }
1200 1200
1201 try { 1201 try {
1202 1202
1203 size_t col; 1203 int col;
1204 FFTCacheReader *cache = getCacheReader(x, col); 1204 FFTCacheReader *cache = getCacheReader(x, col);
1205 if (!cache) return true; 1205 if (!cache) return true;
1206 1206
1207 return cache->haveSetColumnAt(col); 1207 return cache->haveSetColumnAt(col);
1208 1208
1211 return false; 1211 return false;
1212 } 1212 }
1213 } 1213 }
1214 1214
1215 void 1215 void
1216 FFTDataServer::fillColumn(size_t x) 1216 FFTDataServer::fillColumn(int x)
1217 { 1217 {
1218 Profiler profiler("FFTDataServer::fillColumn", false); 1218 Profiler profiler("FFTDataServer::fillColumn", false);
1219 1219
1220 if (!m_model->isReady()) { 1220 if (!m_model->isReady()) {
1221 cerr << "WARNING: FFTDataServer::fillColumn(" 1221 cerr << "WARNING: FFTDataServer::fillColumn("
1235 << "x > width (" << x << " > " << m_width << ")" 1235 << "x > width (" << x << " > " << m_width << ")"
1236 << endl; 1236 << endl;
1237 return; 1237 return;
1238 } 1238 }
1239 1239
1240 size_t col; 1240 int col;
1241 #ifdef DEBUG_FFT_SERVER_FILL 1241 #ifdef DEBUG_FFT_SERVER_FILL
1242 cout << "FFTDataServer::fillColumn(" << x << ")" << endl; 1242 cout << "FFTDataServer::fillColumn(" << x << ")" << endl;
1243 #endif 1243 #endif
1244 FFTCacheWriter *cache = getCacheWriter(x, col); 1244 FFTCacheWriter *cache = getCacheWriter(x, col);
1245 if (!cache) return; 1245 if (!cache) return;
1395 if (m_error != "") return m_error; 1395 if (m_error != "") return m_error;
1396 else if (m_fillThread) return m_fillThread->getError(); 1396 else if (m_fillThread) return m_fillThread->getError();
1397 else return ""; 1397 else return "";
1398 } 1398 }
1399 1399
1400 size_t 1400 int
1401 FFTDataServer::getFillCompletion() const 1401 FFTDataServer::getFillCompletion() const
1402 { 1402 {
1403 if (m_fillThread) return m_fillThread->getCompletion(); 1403 if (m_fillThread) return m_fillThread->getCompletion();
1404 else return 100; 1404 else return 100;
1405 } 1405 }
1406 1406
1407 size_t 1407 int
1408 FFTDataServer::getFillExtent() const 1408 FFTDataServer::getFillExtent() const
1409 { 1409 {
1410 if (m_fillThread) return m_fillThread->getExtent(); 1410 if (m_fillThread) return m_fillThread->getExtent();
1411 else return m_model->getEndFrame(); 1411 else return m_model->getEndFrame();
1412 } 1412 }
1421 1421
1422 QString 1422 QString
1423 FFTDataServer::generateFileBasename(const DenseTimeValueModel *model, 1423 FFTDataServer::generateFileBasename(const DenseTimeValueModel *model,
1424 int channel, 1424 int channel,
1425 WindowType windowType, 1425 WindowType windowType,
1426 size_t windowSize, 1426 int windowSize,
1427 size_t windowIncrement, 1427 int windowIncrement,
1428 size_t fftSize, 1428 int fftSize,
1429 bool polar) 1429 bool polar)
1430 { 1430 {
1431 char buffer[200]; 1431 char buffer[200];
1432 1432
1433 sprintf(buffer, "%u-%u-%u-%u-%u-%u%s", 1433 sprintf(buffer, "%u-%u-%u-%u-%u-%u%s",
1458 #endif 1458 #endif
1459 sleep(1); 1459 sleep(1);
1460 } 1460 }
1461 if (m_server.m_exiting) return; 1461 if (m_server.m_exiting) return;
1462 1462
1463 size_t start = m_server.m_model->getStartFrame(); 1463 int start = m_server.m_model->getStartFrame();
1464 size_t end = m_server.m_model->getEndFrame(); 1464 int end = m_server.m_model->getEndFrame();
1465 size_t remainingEnd = end; 1465 int remainingEnd = end;
1466 1466
1467 int counter = 0; 1467 int counter = 0;
1468 int updateAt = 1; 1468 int updateAt = 1;
1469 int maxUpdateAt = (end / m_server.m_windowIncrement) / 20; 1469 int maxUpdateAt = (end / m_server.m_windowIncrement) / 20;
1470 if (maxUpdateAt < 100) maxUpdateAt = 100; 1470 if (maxUpdateAt < 100) maxUpdateAt = 100;
1471 1471
1472 if (m_fillFrom > start) { 1472 if (m_fillFrom > start) {
1473 1473
1474 for (size_t f = m_fillFrom; f < end; f += m_server.m_windowIncrement) { 1474 for (int f = m_fillFrom; f < end; f += m_server.m_windowIncrement) {
1475 1475
1476 try { 1476 try {
1477 m_server.fillColumn(int((f - start) / m_server.m_windowIncrement)); 1477 m_server.fillColumn(int((f - start) / m_server.m_windowIncrement));
1478 } catch (std::exception &e) { 1478 } catch (std::exception &e) {
1479 std::cerr << "FFTDataServer::FillThread::run: exception: " << e.what() << std::endl; 1479 std::cerr << "FFTDataServer::FillThread::run: exception: " << e.what() << std::endl;
1501 if (m_server.m_exiting) return; 1501 if (m_server.m_exiting) return;
1502 } 1502 }
1503 1503
1504 if (++counter == updateAt) { 1504 if (++counter == updateAt) {
1505 m_extent = f; 1505 m_extent = f;
1506 m_completion = size_t(100 * fabsf(float(f - m_fillFrom) / 1506 m_completion = int(100 * fabsf(float(f - m_fillFrom) /
1507 float(end - start))); 1507 float(end - start)));
1508 counter = 0; 1508 counter = 0;
1509 if (updateAt < maxUpdateAt) { 1509 if (updateAt < maxUpdateAt) {
1510 updateAt *= 2; 1510 updateAt *= 2;
1511 if (updateAt > maxUpdateAt) updateAt = maxUpdateAt; 1511 if (updateAt > maxUpdateAt) updateAt = maxUpdateAt;
1516 remainingEnd = m_fillFrom; 1516 remainingEnd = m_fillFrom;
1517 if (remainingEnd > start) --remainingEnd; 1517 if (remainingEnd > start) --remainingEnd;
1518 else remainingEnd = start; 1518 else remainingEnd = start;
1519 } 1519 }
1520 1520
1521 size_t baseCompletion = m_completion; 1521 int baseCompletion = m_completion;
1522 1522
1523 for (size_t f = start; f < remainingEnd; f += m_server.m_windowIncrement) { 1523 for (int f = start; f < remainingEnd; f += m_server.m_windowIncrement) {
1524 1524
1525 try { 1525 try {
1526 m_server.fillColumn(int((f - start) / m_server.m_windowIncrement)); 1526 m_server.fillColumn(int((f - start) / m_server.m_windowIncrement));
1527 } catch (std::exception &e) { 1527 } catch (std::exception &e) {
1528 std::cerr << "FFTDataServer::FillThread::run: exception: " << e.what() << std::endl; 1528 std::cerr << "FFTDataServer::FillThread::run: exception: " << e.what() << std::endl;
1550 } 1550 }
1551 1551
1552 if (++counter == updateAt) { 1552 if (++counter == updateAt) {
1553 m_extent = f; 1553 m_extent = f;
1554 m_completion = baseCompletion + 1554 m_completion = baseCompletion +
1555 size_t(100 * fabsf(float(f - start) / 1555 int(100 * fabsf(float(f - start) /
1556 float(end - start))); 1556 float(end - start)));
1557 counter = 0; 1557 counter = 0;
1558 if (updateAt < maxUpdateAt) { 1558 if (updateAt < maxUpdateAt) {
1559 updateAt *= 2; 1559 updateAt *= 2;
1560 if (updateAt > maxUpdateAt) updateAt = maxUpdateAt; 1560 if (updateAt > maxUpdateAt) updateAt = maxUpdateAt;