The existing queue initialization function would always sets it's maximum queue size to ctx->queue_size. But because we are introducing more queues we may want the sizes to differ between them. Move the specification of the queue size into an argument, which can be passed from the caller. This patch makes no functional change to the behavior. It is being made to accommodate Marton Balin's request to split out the queue size for the new VANC queue being introduced in a later patch.
Unified · Split
| @@ -390,14 +390,13 @@ int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t directio · 389 unmodified lines | |||
| 390 | return ff_decklink_set_format(avctx, 0, 0, 0, 0, AV_FIELD_UNKNOWN, direction); | 390 | return ff_decklink_set_format(avctx, 0, 0, 0, 0, AV_FIELD_UNKNOWN, direction); |
| 391 | } | 391 | } |
| 392 | 392 | ||
| 393 | void ff_decklink_packet_queue_init(AVFormatContext *avctx, DecklinkPacketQueue *q) | 393 | void ff_decklink_packet_queue_init(AVFormatContext *avctx, DecklinkPacketQueue *q, int64_t queue_size) |
| 394 | { | 394 | { |
| 395 | struct decklink_cctx *ctx = (struct decklink_cctx *)avctx->priv_data; | ||
| 396 | memset(q, 0, sizeof(DecklinkPacketQueue)); | 395 | memset(q, 0, sizeof(DecklinkPacketQueue)); |
| 397 | pthread_mutex_init(&q->mutex, NULL); | 396 | pthread_mutex_init(&q->mutex, NULL); |
| 398 | pthread_cond_init(&q->cond, NULL); | 397 | pthread_cond_init(&q->cond, NULL); |
| 399 | q->avctx = avctx; | 398 | q->avctx = avctx; |
| 400 | q->max_q_size = ctx->queue_size; | 399 | q->max_q_size = queue_size; |
| 401 | } | 400 | } |
| 402 | 401 | ||
| 403 | void ff_decklink_packet_queue_flush(DecklinkPacketQueue *q) | 402 | void ff_decklink_packet_queue_flush(DecklinkPacketQueue *q) |
| @@ -235,7 +235,7 @@ int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct · 234 unmodified lines | |||
| 235 | void ff_decklink_cleanup(AVFormatContext *avctx); | 235 | void ff_decklink_cleanup(AVFormatContext *avctx); |
| 236 | int ff_decklink_init_device(AVFormatContext *avctx, const char* name); | 236 | int ff_decklink_init_device(AVFormatContext *avctx, const char* name); |
| 237 | 237 | ||
| 238 | void ff_decklink_packet_queue_init(AVFormatContext *avctx, DecklinkPacketQueue *q); | 238 | void ff_decklink_packet_queue_init(AVFormatContext *avctx, DecklinkPacketQueue *q, int64_t queue_size); |
| 239 | void ff_decklink_packet_queue_flush(DecklinkPacketQueue *q); | 239 | void ff_decklink_packet_queue_flush(DecklinkPacketQueue *q); |
| 240 | void ff_decklink_packet_queue_end(DecklinkPacketQueue *q); | 240 | void ff_decklink_packet_queue_end(DecklinkPacketQueue *q); |
| 241 | unsigned long long ff_decklink_packet_queue_size(DecklinkPacketQueue *q); | 241 | unsigned long long ff_decklink_packet_queue_size(DecklinkPacketQueue *q); |
| @@ -1297,7 +1297,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 1296 unmodified lines | |||
| 1297 | goto error; | 1297 | goto error; |
| 1298 | } | 1298 | } |
| 1299 | 1299 | ||
| 1300 | ff_decklink_packet_queue_init(avctx, &ctx->queue); | 1300 | ff_decklink_packet_queue_init(avctx, &ctx->queue, cctx->queue_size); |
| 1301 | 1301 | ||
| 1302 | if (ctx->dli->StartStreams() != S_OK) { | 1302 | if (ctx->dli->StartStreams() != S_OK) { |
| 1303 | av_log(avctx, AV_LOG_ERROR, "Cannot start input stream\n"); | 1303 | av_log(avctx, AV_LOG_ERROR, "Cannot start input stream\n"); |