mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-22 10:57:08 +00:00
f_decoder_wrapper: allow VDCTRL_GET_HWDEC to actually fail
a3823ce0e0 made this request a special
case because of all the threading considerations. Unfortunately, the
implementation made it so that VDCTRL_GET_HWDEC always would return
CONTROL_UNKNOWN when using mp_decoder_wrapper_control. This didn't
matter because VDCTRL_GET_HWDEC in vd_lavc would always succeed, but in
reality it shouldn't. It takes some time before we actually know what
the hwdec is and if you query during that time, you'll could get some
bogus value (e.g. during hwdec auto probing). So fix that by returning
false in vd_lavc if hwdec_notified isn't there yet and adjust the
wrapper control logic to take this into account.
This commit is contained in:
@@ -257,15 +257,17 @@ static int decoder_list_help(struct mp_log *log, const m_option_t *opt,
|
||||
|
||||
// Update cached values for main thread which require access to the decoder
|
||||
// thread state. Must run on/locked with decoder thread.
|
||||
static void update_cached_values(struct priv *p)
|
||||
static int update_cached_values(struct priv *p)
|
||||
{
|
||||
int res = CONTROL_UNKNOWN;
|
||||
mp_mutex_lock(&p->cache_lock);
|
||||
|
||||
p->cur_hwdec = NULL;
|
||||
if (p->decoder && p->decoder->control)
|
||||
p->decoder->control(p->decoder->f, VDCTRL_GET_HWDEC, &p->cur_hwdec);
|
||||
res = p->decoder->control(p->decoder->f, VDCTRL_GET_HWDEC, &p->cur_hwdec);
|
||||
|
||||
mp_mutex_unlock(&p->cache_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
// Lock the decoder thread. This may synchronously wait until the decoder thread
|
||||
@@ -346,17 +348,18 @@ int mp_decoder_wrapper_control(struct mp_decoder_wrapper *d,
|
||||
{
|
||||
struct priv *p = d->f->priv;
|
||||
int res = CONTROL_UNKNOWN;
|
||||
thread_lock(p);
|
||||
if (cmd == VDCTRL_GET_HWDEC) {
|
||||
res = update_cached_values(p);
|
||||
mp_mutex_lock(&p->cache_lock);
|
||||
*(char **)arg = p->cur_hwdec;
|
||||
mp_mutex_unlock(&p->cache_lock);
|
||||
} else {
|
||||
thread_lock(p);
|
||||
if (p->decoder && p->decoder->control)
|
||||
res = p->decoder->control(p->decoder->f, cmd, arg);
|
||||
update_cached_values(p);
|
||||
thread_unlock(p);
|
||||
}
|
||||
thread_unlock(p);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user