From 6a5cbe7802ac21c979b32460a1aa57070a6130ac Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 29 May 2015 13:48:18 +0200 Subject: 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. --- video/vdpau.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'video') diff --git a/video/vdpau.c b/video/vdpau.c index 2fd75a2970..339fb59d54 100644 --- a/video/vdpau.c +++ b/video/vdpau.c @@ -197,6 +197,7 @@ static int handle_preemption(struct mp_vdpau_ctx *ctx) // Check whether vdpau display preemption happened. The caller provides a // preemption counter, which contains the logical timestamp of the last // preemption handled by the caller. The counter can be 0 for init. +// If counter is NULL, only ever return -1 or 1. // Return values: // -1: the display is currently preempted, and vdpau can't be used // 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); // First time init - if (!*counter) + if (counter && !*counter) *counter = ctx->preemption_counter; if (handle_preemption(ctx) < 0) r = -1; - if (r > 0 && *counter < ctx->preemption_counter) { + if (counter && r > 0 && *counter < ctx->preemption_counter) { *counter = ctx->preemption_counter; r = 0; // signal recovery after preemption } @@ -329,16 +330,22 @@ static struct mp_image *mp_vdpau_get_surface(struct mp_vdpau_ctx *ctx, e->rgb = rgb; e->w = w; e->h = h; - if (rgb) { - vdp_st = vdp->output_surface_create(ctx->vdp_device, rgb_format, - w, h, &e->osurface); - e->allocated = e->osurface != VDP_INVALID_HANDLE; + if (mp_vdpau_handle_preemption(ctx, NULL) >= 0) { + if (rgb) { + vdp_st = vdp->output_surface_create(ctx->vdp_device, rgb_format, + w, h, &e->osurface); + e->allocated = e->osurface != VDP_INVALID_HANDLE; + } else { + vdp_st = vdp->video_surface_create(ctx->vdp_device, chroma, + w, h, &e->surface); + e->allocated = e->surface != VDP_INVALID_HANDLE; + } + CHECK_VDP_WARNING(ctx, "Error when allocating surface"); } else { - vdp_st = vdp->video_surface_create(ctx->vdp_device, chroma, - w, h, &e->surface); - e->allocated = e->surface != VDP_INVALID_HANDLE; + e->allocated = false; + e->osurface = VDP_INVALID_HANDLE; + e->surface = VDP_INVALID_HANDLE; } - CHECK_VDP_WARNING(ctx, "Error when allocating surface"); surface_index = n; goto done; } -- cgit v1.2.3