Commit 88c8d6c6 authored by Thomas Guillem's avatar Thomas Guillem

core: vout: ensure that the dec-dev matches the input_thread_t one

This commit ensures that the "dec-dev" option can be configured from the
input_thread_t. It will allow to setup the hw decoder for a media via
input_item_AddOption() and libvlc_media_add_option() instead of globally.
Indeed, the vout can be created directly from the player, in that case, the
vout can't inherit options from any input_thread_t.
parent 772e817c
......@@ -73,6 +73,9 @@
/* Better be in advance when awakening than late... */
#define VOUT_MWAIT_TOLERANCE VLC_TICK_FROM_MS(4)
const char *
vlc_decoder_device_GetName(vlc_decoder_device *device);
/* */
static bool VoutCheckFormat(const video_format_t *src)
{
......@@ -1999,6 +2002,7 @@ int vout_ChangeSource( vout_thread_t *vout, const video_format_t *original )
}
static int vout_EnableWindow(vout_thread_t *vout, const video_format_t *original,
input_thread_t *input,
vlc_decoder_device **pp_dec_device)
{
vout_thread_sys_t *sys = vout->p;
......@@ -2032,8 +2036,20 @@ static int vout_EnableWindow(vout_thread_t *vout, const video_format_t *original
if (pp_dec_device)
{
char *name = input ? var_InheritString(input, "dec-dev") : NULL;
if (name != NULL && sys->dec_device != NULL
&& strcmp(name, vlc_decoder_device_GetName(sys->dec_device)) != 0)
{
/* The new input requested a different decoder device than the one
* setup by the vout */
vlc_decoder_device_Release(sys->dec_device);
sys->dec_device = NULL;
}
if (sys->dec_device == NULL)
sys->dec_device = vlc_decoder_device_Create(&vout->obj, NULL, sys->display_cfg.window);
sys->dec_device = vlc_decoder_device_Create(&vout->obj, name, sys->display_cfg.window);
free(name);
*pp_dec_device = sys->dec_device ? vlc_decoder_device_Hold( sys->dec_device ) : NULL;
}
vlc_mutex_unlock(&sys->window_lock);
......@@ -2061,7 +2077,7 @@ int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input
return 0;
}
if (vout_EnableWindow(vout, &original, NULL) != 0)
if (vout_EnableWindow(vout, &original, input, NULL) != 0)
{
/* the window was not enabled, nor the display started */
msg_Err(vout, "failed to enable window");
......@@ -2113,7 +2129,7 @@ vlc_decoder_device *vout_GetDevice(const vout_device_configuration_t *cfg,
video_format_t original;
VoutFixFormat(&original, cfg->fmt);
int res = vout_EnableWindow(cfg->vout, &original, &dec_device);
int res = vout_EnableWindow(cfg->vout, &original, input, &dec_device);
video_format_Clean(&original);
if (res != 0)
return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment