| 206 | } |
| 207 | |
| 208 | static void queue_head_update(SyncQueue *sq) |
| 209 | { |
| 210 | av_assert0(sq->have_limiting); |
| 211 | |
| 212 | if (sq->head_stream < 0) { |
| 213 | unsigned first_limiting = UINT_MAX; |
| 214 | |
| 215 | /* wait for one timestamp in each stream before determining |
| 216 | * the queue head */ |
| 217 | for (unsigned int i = 0; i < sq->nb_streams; i++) { |
| 218 | SyncQueueStream *st = &sq->streams[i]; |
| 219 | if (!st->limiting) |
| 220 | continue; |
| 221 | if (st->head_ts == AV_NOPTS_VALUE) |
| 222 | return; |
| 223 | if (first_limiting == UINT_MAX) |
| 224 | first_limiting = i; |
| 225 | } |
| 226 | |
| 227 | // placeholder value, correct one will be found below |
| 228 | av_assert0(first_limiting < UINT_MAX); |
| 229 | sq->head_stream = first_limiting; |
| 230 | } |
| 231 | |
| 232 | for (unsigned int i = 0; i < sq->nb_streams; i++) { |
| 233 | SyncQueueStream *st_head = &sq->streams[sq->head_stream]; |
| 234 | SyncQueueStream *st_other = &sq->streams[i]; |
| 235 | if (st_other->limiting && st_other->head_ts != AV_NOPTS_VALUE && |
| 236 | av_compare_ts(st_other->head_ts, st_other->tb, |
| 237 | st_head->head_ts, st_head->tb) < 0) |
| 238 | sq->head_stream = i; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | /* update this stream's head timestamp */ |
| 243 | static void stream_update_ts(SyncQueue *sq, unsigned int stream_idx, int64_t ts) |
no test coverage detected