[vlc-devel] [PATCH 12/31] video_output: split the code after the window/decoder device creation
Steve Lhomme
robux4 at ycbcr.xyz
Fri Jul 5 16:19:51 CEST 2019
This will be used by the HW decoder to create the video context. And then the
display will be created.
Don't create a new display in vout_RequestDisplay() if there's already one.
Maybe we need to check if the format changed to know if a new display is needed.
---
src/video_output/video_output.c | 30 +++++++++++++++++++++++++-----
src/video_output/vout_internal.h | 26 ++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 5 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 7c03b6ed47..8b2fe49bca 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1864,6 +1864,16 @@ vout_thread_t *vout_Hold(vout_thread_t *vout)
int vout_Request(const vout_configuration_t *cfg, vlc_decoder_device **dec_dev,
input_thread_t *input)
+{
+ int res = vout_RequestDevice(cfg, dec_dev);
+ if (res == 0)
+ {
+ res = vout_RequestDisplay(cfg, input);
+ }
+ return res;
+}
+
+int vout_RequestDevice(const vout_configuration_t *cfg, vlc_decoder_device **dec_dev)
{
vout_thread_t *vout = cfg->vout;
vout_thread_sys_t *sys = vout->p;
@@ -1915,7 +1925,8 @@ int vout_Request(const vout_configuration_t *cfg, vlc_decoder_device **dec_dev,
if (vout_window_Enable(sys->display_cfg.window, &wcfg)) {
vlc_mutex_unlock(&sys->window_lock);
- goto error;
+ msg_Err(vout, "video output creation failed");
+ video_format_Clean(&sys->original);
}
sys->window_enabled = true;
@@ -1931,8 +1942,21 @@ int vout_Request(const vout_configuration_t *cfg, vlc_decoder_device **dec_dev,
sys->clock = cfg->clock;
sys->delay = 0;
+ *dec_dev = sys->dec_device ? vlc_decoder_device_Hold( sys->dec_device ) : NULL;
+
vlc_mutex_unlock(&sys->window_lock);
+ return 0;
+}
+
+int vout_RequestDisplay(const vout_configuration_t *cfg, input_thread_t *input)
+{
+ vout_thread_t *vout = cfg->vout;
+ vout_thread_sys_t *sys = vout->p;
+
+ if (sys->display != NULL)
+ return VLC_SUCCESS;
+
if (vout_Start(vout, cfg))
{
vlc_mutex_lock(&sys->window_lock);
@@ -1951,10 +1975,6 @@ error:
return -1;
}
- vlc_mutex_lock(&sys->window_lock);
- *dec_dev = sys->dec_device ? vlc_decoder_device_Hold( sys->dec_device ) : NULL;
- vlc_mutex_unlock(&sys->window_lock);
-
if (input != NULL && sys->spu)
spu_Attach(sys->spu, input);
vout_IntfReinit(vout);
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 247e214c57..af05f2c317 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -200,6 +200,32 @@ vout_thread_t *vout_Create(vlc_object_t *obj) VLC_USED;
vout_thread_t *vout_CreateDummy(vlc_object_t *obj) VLC_USED;
+/**
+ * Returns a suitable vout with an associated decoder device.
+ *
+ * \param cfg the video configuration requested.
+ * \param dec_dev pointer to receive the decoder device to use with the vout
+ * \retval 0 on success
+ * \retval -1 on error
+ */
+int vout_RequestDevice(const vout_configuration_t *cfg, vlc_decoder_device **dec_dev);
+
+/**
+ * Returns a suitable vout or release the given one.
+ *
+ * If cfg->fmt is non NULL and valid, a vout will be returned, reusing cfg->vout
+ * is possible, otherwise it returns NULL.
+ * If cfg->vout is not used, it will be closed and released.
+ *
+ * You can release the returned value either by vout_RequestDisplay() or vout_Close().
+ *
+ * \param cfg the video configuration requested.
+ * \param input used to get attachments for spu filters
+ * \retval 0 on success
+ * \retval -1 on error
+ */
+int vout_RequestDisplay(const vout_configuration_t *cfg, input_thread_t *input);
+
/**
* Returns a suitable vout or release the given one.
*
--
2.17.1
More information about the vlc-devel
mailing list