Esempio n. 1
0
static int handle_preemption(struct mp_vdpau_ctx *ctx)
{
    if (!ctx->is_preempted)
        return 0;
    mark_vdpau_objects_uninitialized(ctx);
    if (!ctx->preemption_user_notified) {
        MP_ERR(ctx, "Got display preemption notice! Will attempt to recover.\n");
        ctx->preemption_user_notified = true;
    }
    /* Trying to initialize seems to be quite slow, so only try once a
     * second to avoid using 100% CPU. */
    if (ctx->last_preemption_retry_fail &&
        mp_time_sec() - ctx->last_preemption_retry_fail < 1.0)
        return -1;
    if (win_x11_init_vdpau_procs(ctx) < 0) {
        ctx->last_preemption_retry_fail = mp_time_sec();
        return -1;
    }
    ctx->preemption_user_notified = false;
    ctx->last_preemption_retry_fail = 0;
    ctx->is_preempted = false;
    ctx->preemption_counter++;
    MP_INFO(ctx, "Recovered from display preemption.\n");
    return 1;
}
Esempio n. 2
0
static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image,
                     GLuint *out_textures)
{
    struct priv *p = hw->priv;
    GL *gl = hw->gl;

    assert(hw_image && hw_image->imgfmt == IMGFMT_VDPAU);

    int pe = mp_vdpau_handle_preemption(p->ctx, &p->preemption_counter);
    if (pe < 1) {
        mark_vdpau_objects_uninitialized(hw);
        if (pe < 0)
            return -1;
        if (reinit(hw, &p->image_params) < 0)
            return -1;
    }

    if (!p->vdpgl_surface)
        return -1;

    if (p->mapped)
        gl->VDPAUUnmapSurfacesNV(1, &p->vdpgl_surface);

    mp_vdpau_mixer_render(p->mixer, NULL, p->vdp_surface, NULL, hw_image, NULL);

    gl->VDPAUMapSurfacesNV(1, &p->vdpgl_surface);
    p->mapped = true;
    out_textures[0] = p->gl_texture;
    return 0;
}
Esempio n. 3
0
static int handle_preemption(struct gl_hwdec *hw)
{
    struct priv *p = hw->priv;

    if (!mp_vdpau_status_ok(p->ctx)) {
        mark_vdpau_objects_uninitialized(hw);
        return -1;
    }

    if (p->preemption_counter == p->ctx->preemption_counter)
        return 0;

    mark_vdpau_objects_uninitialized(hw);

    p->preemption_counter = p->ctx->preemption_counter;

    if (reinit(hw, &p->image_params) < 0)
        return -1;

    return 1;
}