| 117 | } |
| 118 | |
| 119 | void |
| 120 | TVProcessorWorker::work(const SUFLOAT *samples, SUSCOUNT size) |
| 121 | { |
| 122 | SUSCOUNT currAck, diff; |
| 123 | bool frameSent = false; |
| 124 | |
| 125 | if (this->processor != nullptr) { |
| 126 | if (size > this->maxProcessingBlock) { |
| 127 | size = this->maxProcessingBlock; |
| 128 | } |
| 129 | |
| 130 | while (size-- > 0) { |
| 131 | if (su_tv_processor_feed(this->processor, *samples++)) { |
| 132 | if (!frameSent) { |
| 133 | #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) |
| 134 | currAck = this->frameAck.loadRelaxed(); |
| 135 | #else |
| 136 | currAck = this->frameAck.load(); |
| 137 | #endif // QT_VERSION |
| 138 | |
| 139 | if (currAck > this->frameCount) |
| 140 | this->frameCount = currAck; |
| 141 | |
| 142 | diff = this->frameCount - currAck; |
| 143 | |
| 144 | if (this->blocked) |
| 145 | this->blocked = diff > TV_PROCESSOR_WORKER_MIN_NACK_RESTART; |
| 146 | else |
| 147 | this->blocked = diff > TV_PROCESSOR_WORKER_MAX_NACK_FRAMES; |
| 148 | |
| 149 | if (!this->blocked) { |
| 150 | ++this->frameCount; |
| 151 | emit frame(su_tv_processor_take_frame(this->processor)); |
| 152 | frameSent = true; |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | void |
| 161 | TVProcessorWorker::acknowledgeFrame(void) |