Skip to content

Commit

Permalink
utils/frame_queue: don't crash on empty pl_queue_update
Browse files Browse the repository at this point in the history
Can happen when e.g. triggering screenshot in mpv before any frames are
available (empty queue).
  • Loading branch information
haasn committed Aug 21, 2023
1 parent e9b39ab commit 69e40e5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/utils/frame_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,12 @@ static enum pl_queue_status advance(pl_queue p, double pts,
static inline enum pl_queue_status point(pl_queue p, struct pl_frame_mix *mix,
const struct pl_queue_params *params)
{
if (!p->queue.num) {
*mix = (struct pl_frame_mix) {0};
return PL_QUEUE_MORE;
}

// Find closest frame (nearest neighbour semantics)
pl_assert(p->queue.num);
struct entry *entry = p->queue.elem[0];
if (entry->pts > params->pts) { // first frame not visible yet
*mix = (struct pl_frame_mix) {0};
Expand Down Expand Up @@ -697,7 +701,7 @@ static enum pl_queue_status nearest(pl_queue p, struct pl_frame_mix *mix,
return ret;
case PL_QUEUE_OK:
case PL_QUEUE_MORE:
if (mix && point(p, mix, params) != PL_QUEUE_OK)
if (mix && point(p, mix, params) == PL_QUEUE_ERR)
return PL_QUEUE_ERR;
return ret;
}
Expand Down

0 comments on commit 69e40e5

Please sign in to comment.