mirror of
https://github.com/mpv-player/mpv
synced 2025-03-25 04:38:01 +00:00
video: reduce error message when loading hwdec backend fails
When using --hwdec=auto, about half of all systems will print: "[vdpau] Error when calling vdp_device_create_x11: 1" this happens because usually mpv will be linked against both vdpau and vaapi libs, but the drivers are not necessarily available. Then trying to load a driver will fail. This is a normal part of probing, but the error messages were printed anyway. Silence them by explicitly distinguishing probing. This pretty much goes through all the layers. We actually consider loading hw backends for vo_opengl always "auto probed", even if a hw backend is explicitly requested. In this case vd_lavc will print a warning message anyway (adjust this message a bit).
This commit is contained in:
parent
b17b8ff7fe
commit
991af7dfb1
@ -307,7 +307,7 @@ static bool create_va_dummy_ctx(struct priv *p)
|
||||
VADisplay *display = vaGetDisplay(p->x11_display);
|
||||
if (!display)
|
||||
goto destroy_ctx;
|
||||
p->ctx = va_initialize(display, p->log);
|
||||
p->ctx = va_initialize(display, p->log, true);
|
||||
if (!p->ctx) {
|
||||
vaTerminate(display);
|
||||
goto destroy_ctx;
|
||||
|
@ -252,10 +252,11 @@ static struct vd_lavc_hwdec *probe_hwdec(struct dec_video *vd, bool autoprobe,
|
||||
if (r >= 0) {
|
||||
return hwdec;
|
||||
} else if (r == HWDEC_ERR_NO_CODEC) {
|
||||
MP_VERBOSE(vd, "Hardware decoder '%s' not found in "
|
||||
"libavcodec.\n", decoder);
|
||||
MP_VERBOSE(vd, "Hardware decoder '%s' not found in libavcodec.\n",
|
||||
decoder);
|
||||
} else if (r == HWDEC_ERR_NO_CTX && !autoprobe) {
|
||||
MP_WARN(vd, "VO does not support requested hardware decoder.\n");
|
||||
MP_WARN(vd, "VO does not support requested hardware decoder, or "
|
||||
"loading it failed.\n");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ static struct gl_hwdec *load_hwdec_driver(struct mp_log *log, GL *gl,
|
||||
};
|
||||
if (hwdec->driver->create(hwdec) < 0) {
|
||||
talloc_free(hwdec);
|
||||
mp_err(log, "Couldn't load hwdec driver '%s'\n", drv->api_name);
|
||||
mp_verbose(log, "Couldn't load hwdec driver '%s'\n", drv->api_name);
|
||||
return NULL;
|
||||
}
|
||||
return hwdec;
|
||||
|
@ -90,7 +90,7 @@ static int create(struct gl_hwdec *hw)
|
||||
p->display = vaGetDisplay(x11disp);
|
||||
if (!p->display)
|
||||
return -1;
|
||||
p->ctx = va_initialize(p->display, p->log);
|
||||
p->ctx = va_initialize(p->display, p->log, true);
|
||||
if (!p->ctx) {
|
||||
vaTerminate(p->display);
|
||||
return -1;
|
||||
|
@ -109,7 +109,7 @@ static int create(struct gl_hwdec *hw)
|
||||
struct priv *p = talloc_zero(hw, struct priv);
|
||||
hw->priv = p;
|
||||
p->log = hw->log;
|
||||
p->ctx = mp_vdpau_create_device_x11(hw->log, x11disp);
|
||||
p->ctx = mp_vdpau_create_device_x11(hw->log, x11disp, true);
|
||||
if (!p->ctx)
|
||||
return -1;
|
||||
if (mp_vdpau_handle_preemption(p->ctx, &p->preemption_counter) < 1)
|
||||
|
@ -600,7 +600,7 @@ static int preinit(struct vo *vo)
|
||||
if (!p->display)
|
||||
goto fail;
|
||||
|
||||
p->mpvaapi = va_initialize(p->display, p->log);
|
||||
p->mpvaapi = va_initialize(p->display, p->log, false);
|
||||
if (!p->mpvaapi) {
|
||||
vaTerminate(p->display);
|
||||
p->display = NULL;
|
||||
|
@ -954,7 +954,7 @@ static int preinit(struct vo *vo)
|
||||
if (!vo_x11_init(vo))
|
||||
return -1;
|
||||
|
||||
vc->mpvdp = mp_vdpau_create_device_x11(vo->log, vo->x11->display);
|
||||
vc->mpvdp = mp_vdpau_create_device_x11(vo->log, vo->x11->display, false);
|
||||
if (!vc->mpvdp) {
|
||||
vo_x11_uninit(vo);
|
||||
return -1;
|
||||
|
@ -114,12 +114,15 @@ static void va_get_formats(struct mp_vaapi_ctx *ctx)
|
||||
ctx->image_formats = formats;
|
||||
}
|
||||
|
||||
struct mp_vaapi_ctx *va_initialize(VADisplay *display, struct mp_log *plog)
|
||||
struct mp_vaapi_ctx *va_initialize(VADisplay *display, struct mp_log *plog,
|
||||
bool probing)
|
||||
{
|
||||
struct mp_vaapi_ctx *res = NULL;
|
||||
struct mp_log *log = mp_log_new(NULL, plog, "/vaapi");
|
||||
int major_version, minor_version;
|
||||
int status = vaInitialize(display, &major_version, &minor_version);
|
||||
if (status != VA_STATUS_SUCCESS && probing)
|
||||
goto error;
|
||||
if (!check_va_status(log, status, "vaInitialize()"))
|
||||
goto error;
|
||||
|
||||
|
@ -111,7 +111,7 @@ bool check_va_status(struct mp_log *log, VAStatus status, const char *msg);
|
||||
|
||||
int va_get_colorspace_flag(enum mp_csp csp);
|
||||
|
||||
struct mp_vaapi_ctx *va_initialize(VADisplay *display, struct mp_log *log);
|
||||
struct mp_vaapi_ctx * va_initialize(VADisplay *display, struct mp_log *plog, bool probing);
|
||||
void va_destroy(struct mp_vaapi_ctx *ctx);
|
||||
|
||||
enum mp_imgfmt va_fourcc_to_imgfmt(uint32_t fourcc);
|
||||
|
@ -113,7 +113,7 @@ static void preemption_callback(VdpDevice device, void *context)
|
||||
pthread_mutex_unlock(&ctx->preempt_lock);
|
||||
}
|
||||
|
||||
static int win_x11_init_vdpau_procs(struct mp_vdpau_ctx *ctx)
|
||||
static int win_x11_init_vdpau_procs(struct mp_vdpau_ctx *ctx, bool probing)
|
||||
{
|
||||
Display *x11 = ctx->x11;
|
||||
VdpStatus vdp_st;
|
||||
@ -142,11 +142,14 @@ static int win_x11_init_vdpau_procs(struct mp_vdpau_ctx *ctx)
|
||||
vdp_st = vdp_device_create_x11(x11, DefaultScreen(x11), &ctx->vdp_device,
|
||||
&get_proc_address);
|
||||
if (vdp_st != VDP_STATUS_OK) {
|
||||
if (ctx->is_preempted)
|
||||
if (ctx->is_preempted) {
|
||||
MP_DBG(ctx, "Error calling vdp_device_create_x11 while preempted: %d\n",
|
||||
vdp_st);
|
||||
else
|
||||
MP_ERR(ctx, "Error when calling vdp_device_create_x11: %d\n", vdp_st);
|
||||
} else {
|
||||
int lev = probing ? MSGL_V : MSGL_ERR;
|
||||
mp_msg(ctx->log, lev, "Error when calling vdp_device_create_x11: %d\n",
|
||||
vdp_st);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -182,7 +185,7 @@ static int handle_preemption(struct mp_vdpau_ctx *ctx)
|
||||
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) {
|
||||
if (win_x11_init_vdpau_procs(ctx, false) < 0) {
|
||||
ctx->last_preemption_retry_fail = mp_time_sec();
|
||||
return -1;
|
||||
}
|
||||
@ -369,7 +372,8 @@ struct mp_image *mp_vdpau_get_video_surface(struct mp_vdpau_ctx *ctx,
|
||||
return mp_vdpau_get_surface(ctx, chroma, 0, false, w, h);
|
||||
}
|
||||
|
||||
struct mp_vdpau_ctx *mp_vdpau_create_device_x11(struct mp_log *log, Display *x11)
|
||||
struct mp_vdpau_ctx *mp_vdpau_create_device_x11(struct mp_log *log, Display *x11,
|
||||
bool probing)
|
||||
{
|
||||
struct mp_vdpau_ctx *ctx = talloc_ptrtype(NULL, ctx);
|
||||
*ctx = (struct mp_vdpau_ctx) {
|
||||
@ -389,7 +393,7 @@ struct mp_vdpau_ctx *mp_vdpau_create_device_x11(struct mp_log *log, Display *x11
|
||||
|
||||
mark_vdpau_objects_uninitialized(ctx);
|
||||
|
||||
if (win_x11_init_vdpau_procs(ctx) < 0) {
|
||||
if (win_x11_init_vdpau_procs(ctx, probing) < 0) {
|
||||
mp_vdpau_destroy(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -79,7 +79,8 @@ struct mp_vdpau_ctx {
|
||||
int getimg_w, getimg_h;
|
||||
};
|
||||
|
||||
struct mp_vdpau_ctx *mp_vdpau_create_device_x11(struct mp_log *log, Display *x11);
|
||||
struct mp_vdpau_ctx *mp_vdpau_create_device_x11(struct mp_log *log, Display *x11,
|
||||
bool probing);
|
||||
void mp_vdpau_destroy(struct mp_vdpau_ctx *ctx);
|
||||
|
||||
int mp_vdpau_handle_preemption(struct mp_vdpau_ctx *ctx, uint64_t *counter);
|
||||
|
Loading…
Reference in New Issue
Block a user