mirror of
https://github.com/mpv-player/mpv
synced 2025-01-31 04:02:06 +00:00
vdpau: do not attempt to allocate surfaces while preempted
This reduces spam while preempted a bit. The remaining message, "hardware accelerator failed to decode picture" on every frame, can not be prevented because it's hardcoded in libavcodec.
This commit is contained in:
parent
c4757ad17c
commit
6a5cbe7802
@ -197,6 +197,7 @@ static int handle_preemption(struct mp_vdpau_ctx *ctx)
|
|||||||
// Check whether vdpau display preemption happened. The caller provides a
|
// Check whether vdpau display preemption happened. The caller provides a
|
||||||
// preemption counter, which contains the logical timestamp of the last
|
// preemption counter, which contains the logical timestamp of the last
|
||||||
// preemption handled by the caller. The counter can be 0 for init.
|
// preemption handled by the caller. The counter can be 0 for init.
|
||||||
|
// If counter is NULL, only ever return -1 or 1.
|
||||||
// Return values:
|
// Return values:
|
||||||
// -1: the display is currently preempted, and vdpau can't be used
|
// -1: the display is currently preempted, and vdpau can't be used
|
||||||
// 0: a preemption event happened, and the caller must recover
|
// 0: a preemption event happened, and the caller must recover
|
||||||
@ -208,13 +209,13 @@ int mp_vdpau_handle_preemption(struct mp_vdpau_ctx *ctx, uint64_t *counter)
|
|||||||
pthread_mutex_lock(&ctx->preempt_lock);
|
pthread_mutex_lock(&ctx->preempt_lock);
|
||||||
|
|
||||||
// First time init
|
// First time init
|
||||||
if (!*counter)
|
if (counter && !*counter)
|
||||||
*counter = ctx->preemption_counter;
|
*counter = ctx->preemption_counter;
|
||||||
|
|
||||||
if (handle_preemption(ctx) < 0)
|
if (handle_preemption(ctx) < 0)
|
||||||
r = -1;
|
r = -1;
|
||||||
|
|
||||||
if (r > 0 && *counter < ctx->preemption_counter) {
|
if (counter && r > 0 && *counter < ctx->preemption_counter) {
|
||||||
*counter = ctx->preemption_counter;
|
*counter = ctx->preemption_counter;
|
||||||
r = 0; // signal recovery after preemption
|
r = 0; // signal recovery after preemption
|
||||||
}
|
}
|
||||||
@ -329,6 +330,7 @@ static struct mp_image *mp_vdpau_get_surface(struct mp_vdpau_ctx *ctx,
|
|||||||
e->rgb = rgb;
|
e->rgb = rgb;
|
||||||
e->w = w;
|
e->w = w;
|
||||||
e->h = h;
|
e->h = h;
|
||||||
|
if (mp_vdpau_handle_preemption(ctx, NULL) >= 0) {
|
||||||
if (rgb) {
|
if (rgb) {
|
||||||
vdp_st = vdp->output_surface_create(ctx->vdp_device, rgb_format,
|
vdp_st = vdp->output_surface_create(ctx->vdp_device, rgb_format,
|
||||||
w, h, &e->osurface);
|
w, h, &e->osurface);
|
||||||
@ -339,6 +341,11 @@ static struct mp_image *mp_vdpau_get_surface(struct mp_vdpau_ctx *ctx,
|
|||||||
e->allocated = e->surface != VDP_INVALID_HANDLE;
|
e->allocated = e->surface != VDP_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
CHECK_VDP_WARNING(ctx, "Error when allocating surface");
|
CHECK_VDP_WARNING(ctx, "Error when allocating surface");
|
||||||
|
} else {
|
||||||
|
e->allocated = false;
|
||||||
|
e->osurface = VDP_INVALID_HANDLE;
|
||||||
|
e->surface = VDP_INVALID_HANDLE;
|
||||||
|
}
|
||||||
surface_index = n;
|
surface_index = n;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user