[vlc-commits] video_output: add vout_GetDevice to get the vout decoder device on demand
Steve Lhomme
git at videolan.org
Wed Oct 9 10:15:54 CEST 2019
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Sep 25 14:03:30 2019 +0200| [e35dcdf6ae583237d57bdb1603d82dbf3bccf169] | committer: Steve Lhomme
video_output: add vout_GetDevice to get the vout decoder device on demand
Only a few decoders will request it.
A decoder device can only be created if the vout has an enabled window.
The caller receives a reference to the decoder device or NULL.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e35dcdf6ae583237d57bdb1603d82dbf3bccf169
---
src/video_output/video_output.c | 36 +++++++++++++++++++++++++++++++++---
src/video_output/vout_internal.h | 10 ++++++++++
2 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index ffd2d3b747..36578f810f 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -49,6 +49,7 @@
#include <vlc_vout_osd.h>
#include <vlc_image.h>
#include <vlc_plugin.h>
+#include <vlc_codec.h>
#include <libvlc.h>
#include "vout_internal.h"
@@ -1737,6 +1738,11 @@ void vout_Stop(vout_thread_t *vout)
vout_StopDisplay(vout);
vlc_mutex_lock(&sys->window_lock);
+ if (sys->dec_device)
+ {
+ vlc_decoder_device_Release(sys->dec_device);
+ sys->dec_device = NULL;
+ }
if (sys->window_enabled) {
vout_window_Disable(sys->display_cfg.window);
sys->window_enabled = false;
@@ -1784,6 +1790,9 @@ void vout_Release(vout_thread_t *vout)
vlc_mutex_destroy(&vout->p->window_lock);
vlc_mutex_destroy(&vout->p->filter.lock);
+ if (sys->dec_device)
+ vlc_decoder_device_Release(sys->dec_device);
+
assert(!sys->window_enabled);
vout_display_window_Delete(sys->display_cfg.window);
@@ -1915,7 +1924,7 @@ vout_thread_t *vout_Hold(vout_thread_t *vout)
return vout;
}
-static int VoutEnableWindow(const vout_configuration_t *cfg)
+static int VoutEnableWindow(const vout_configuration_t *cfg, vlc_decoder_device **pp_dec_device)
{
vout_thread_t *vout = cfg->vout;
vout_thread_sys_t *sys = vout->p;
@@ -1937,6 +1946,8 @@ static int VoutEnableWindow(const vout_configuration_t *cfg)
if (cfg->dpb_size <= sys->dpb_size) {
video_format_Clean(&original);
/* It is assumed that the SPU input matches input already. */
+ if (pp_dec_device)
+ *pp_dec_device = sys->dec_device ? vlc_decoder_device_Hold( sys->dec_device ) : NULL;
return 0;
}
msg_Warn(vout, "DPB need to be increased");
@@ -1973,8 +1984,14 @@ static int VoutEnableWindow(const vout_configuration_t *cfg)
sys->window_enabled = true;
} else
vout_UpdateWindowSizeLocked(vout);
- vlc_mutex_unlock(&sys->window_lock);
+ if (pp_dec_device)
+ {
+ if (sys->dec_device == NULL)
+ sys->dec_device = vlc_decoder_device_Create(sys->display_cfg.window);
+ *pp_dec_device = sys->dec_device ? vlc_decoder_device_Hold( sys->dec_device ) : NULL;
+ }
+ vlc_mutex_unlock(&sys->window_lock);
return 0;
}
@@ -1985,7 +2002,7 @@ int vout_Request(const vout_configuration_t *cfg, input_thread_t *input)
assert(cfg->clock != NULL);
- if (VoutEnableWindow(cfg) != 0)
+ if (VoutEnableWindow(cfg, NULL) != 0)
return -1;
sys->delay = 0;
@@ -1998,6 +2015,11 @@ int vout_Request(const vout_configuration_t *cfg, input_thread_t *input)
vlc_mutex_lock(&sys->window_lock);
vout_window_Disable(sys->display_cfg.window);
sys->window_enabled = false;
+ if (sys->dec_device)
+ {
+ vlc_decoder_device_Release(sys->dec_device);
+ sys->dec_device = NULL;
+ }
vlc_mutex_unlock(&sys->window_lock);
goto error;
}
@@ -2014,3 +2036,11 @@ error:
vout_IntfReinit(vout);
return 0;
}
+
+vlc_decoder_device *vout_GetDevice(const vout_configuration_t *cfg)
+{
+ vlc_decoder_device *dec_device = NULL;
+ if (VoutEnableWindow(cfg, &dec_device) != 0)
+ return NULL;
+ return dec_device;
+}
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 29f2144f82..30f79794e1 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -173,6 +173,7 @@ struct vout_thread_sys_t
/* Video output window */
bool window_enabled;
vlc_mutex_t window_lock;
+ vlc_decoder_device *dec_device;
/* Video output display */
vout_display_cfg_t display_cfg;
@@ -195,6 +196,14 @@ vout_thread_t *vout_Create(vlc_object_t *obj) VLC_USED;
vout_thread_t *vout_CreateDummy(vlc_object_t *obj) VLC_USED;
+/**
+ * Setup the vout for the given configuration and get an associated decoder device.
+ *
+ * \param cfg the video configuration requested.
+ * \return pointer to a decoder device reference to use with the vout or NULL
+ */
+vlc_decoder_device *vout_GetDevice(const vout_configuration_t *cfg);
+
/**
* Returns a suitable vout or release the given one.
*
@@ -206,6 +215,7 @@ vout_thread_t *vout_CreateDummy(vlc_object_t *obj) VLC_USED;
*
* \param cfg the video configuration requested.
* \param input used to get attachments for spu filters
+ * \param dec_dev pointer to receive the decoder device reference to use with the vout or NULL
* \retval 0 on success
* \retval -1 on error
*/
More information about the vlc-commits
mailing list