Protected by mutex
| 175 | |
| 176 | // Protected by mutex |
| 177 | void |
| 178 | GenericDataSaver::doCommit(void) |
| 179 | { |
| 180 | // It is okay if the worker thread is still dumping data. This is |
| 181 | // just a way to signal this situation. If it was not ready, we |
| 182 | // do not flip buffers and keep filling the current one. |
| 183 | if (this->bufferReady) { |
| 184 | struct timeval otv = this->lastCommit; |
| 185 | struct timeval sub; |
| 186 | |
| 187 | gettimeofday(&this->lastCommit, nullptr); |
| 188 | timersub(&this->lastCommit, &otv, &sub); |
| 189 | this->writeTime = static_cast<quint64>( |
| 190 | sub.tv_usec + sub.tv_sec * 1000000l); |
| 191 | |
| 192 | this->buffer = 1 - this->buffer; |
| 193 | this->commitedSize = this->ptr; |
| 194 | this->size += this->commitedSize; |
| 195 | this->ptr = 0; |
| 196 | this->bufferReady = false; |
| 197 | |
| 198 | emit commit(); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | void |
| 203 | GenericDataSaver::setSampleRate(unsigned int rate) |