| 195 | } |
| 196 | |
| 197 | int tq_receive(ThreadQueue *tq, int *stream_idx, void *data) |
| 198 | { |
| 199 | int ret; |
| 200 | |
| 201 | *stream_idx = -1; |
| 202 | |
| 203 | pthread_mutex_lock(&tq->lock); |
| 204 | |
| 205 | while (1) { |
| 206 | size_t can_read = av_container_fifo_can_read(tq->fifo); |
| 207 | |
| 208 | ret = receive_locked(tq, stream_idx, data); |
| 209 | |
| 210 | // signal other threads if the fifo state changed |
| 211 | if (can_read != av_container_fifo_can_read(tq->fifo)) |
| 212 | pthread_cond_broadcast(&tq->cond); |
| 213 | |
| 214 | if (ret == AVERROR(EAGAIN)) { |
| 215 | pthread_cond_wait(&tq->cond, &tq->lock); |
| 216 | continue; |
| 217 | } |
| 218 | |
| 219 | break; |
| 220 | } |
| 221 | |
| 222 | pthread_mutex_unlock(&tq->lock); |
| 223 | |
| 224 | return ret; |
| 225 | } |
| 226 | |
| 227 | void tq_send_finish(ThreadQueue *tq, unsigned int stream_idx) |
| 228 | { |
no test coverage detected