[vlc-commits] vout: request the vout with a video context
Steve Lhomme
git at videolan.org
Wed Oct 9 10:16:33 CEST 2019
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Sep 30 10:11:07 2019 +0200| [73c153add5d851572f4d79f81a04ae98a1d7fc76] | committer: Steve Lhomme
vout: request the vout with a video context
instead of the decoder device
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=73c153add5d851572f4d79f81a04ae98a1d7fc76
---
include/vlc_vout_display.h | 5 +++--
modules/video_output/splitter.c | 7 ++-----
modules/video_output/win32/direct3d9.c | 6 +++++-
src/input/decoder.c | 4 +---
src/input/resource.c | 4 ++--
src/input/resource.h | 2 +-
src/video_output/display.c | 10 ++--------
src/video_output/video_output.c | 18 ++++++++++++++----
src/video_output/vout_internal.h | 6 +++---
src/video_output/vout_wrapper.c | 6 +++---
10 files changed, 36 insertions(+), 32 deletions(-)
diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 1a6afe0da2..ed89eb56d2 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -307,9 +307,10 @@ struct vout_display_t {
* Creates video output display.
*/
VLC_API
-vout_display_t *vout_display_New(vlc_object_t *, const video_format_t *,
+vout_display_t *vout_display_New(vlc_object_t *,
+ const video_format_t *, vlc_video_context *,
const vout_display_cfg_t *, const char *module,
- vlc_decoder_device *, const vout_display_owner_t *);
+ const vout_display_owner_t *);
/**
* Destroys a video output display.
diff --git a/modules/video_output/splitter.c b/modules/video_output/splitter.c
index acfe02df5a..8d6532ceb4 100644
--- a/modules/video_output/splitter.c
+++ b/modules/video_output/splitter.c
@@ -290,11 +290,8 @@ static int vlc_vidsplit_Open(vout_display_t *vd,
}
vdcfg.window = part->window;
- vlc_decoder_device *dec_device = vlc_video_context_HoldDevice(ctx);
- vout_display_t *display = vout_display_New(obj, &output->fmt, &vdcfg,
- modname, dec_device, NULL);
- if (dec_device)
- vlc_decoder_device_Release(dec_device);
+ vout_display_t *display = vout_display_New(obj, &output->fmt, ctx, &vdcfg,
+ modname, NULL);
if (display == NULL) {
vout_window_Disable(part->window);
vout_window_Delete(part->window);
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 1de80dac74..04c75e4fd5 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -1661,8 +1661,12 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
if (d3d9_decoder != NULL && d3d9_decoder->device != NULL)
D3D9_CloneExternal( &sys->hd3d, d3d9_decoder->device );
+ d3d9_video_context_t *octx = GetD3D9ContextPrivate(context);
HRESULT hr;
- hr = D3D9_CreateDevice(vd, &sys->hd3d, d3d9_decoder ? d3d9_decoder->adapter : -1, &sys->d3d_dev);
+ if (octx != NULL)
+ hr = D3D9_CreateDeviceExternal(octx->dev, &sys->hd3d, &sys->d3d_dev);
+ else
+ hr = D3D9_CreateDevice(vd, &sys->hd3d, d3d9_decoder ? d3d9_decoder->adapter : -1, &sys->d3d_dev);
if (FAILED(hr)) {
msg_Err( vd, "D3D9 Creation failed! (hr=0x%lX)", hr);
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 2caeb1abd1..7b53b6030c 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -510,11 +510,9 @@ static int ModuleThread_UpdateVideoFormat( decoder_t *p_dec, vlc_video_context *
.dpb_size = dpb_size + p_dec->i_extra_picture_buffers + 1,
.mouse_event = MouseEvent, .mouse_opaque = p_dec,
};
- vlc_decoder_device *dec_dev = p_owner->vctx ? vlc_video_context_HoldDevice(vctx) : NULL;
- int res = input_resource_ReconfigureVout( p_owner->p_resource, dec_dev, &cfg);
+ int res = input_resource_ReconfigureVout( p_owner->p_resource, vctx, &cfg);
if (res == 0)
decoder_Notify(p_owner, on_vout_started, p_vout, vout_order);
- if (dec_dev) vlc_decoder_device_Release(dec_dev);
return res;
}
diff --git a/src/input/resource.c b/src/input/resource.c
index 21a25dd059..c38225973b 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -439,11 +439,11 @@ out:
}
int input_resource_ReconfigureVout(input_resource_t *p_resource,
- vlc_decoder_device *dec_dev,
+ vlc_video_context *vctx,
const vout_configuration_t *cfg)
{
vlc_mutex_lock( &p_resource->lock );
- if (vout_Request(cfg, dec_dev, p_resource->p_input)) {
+ if (vout_Request(cfg, vctx, p_resource->p_input)) {
input_resource_PutVoutLocked(p_resource, cfg->vout, false);
vlc_mutex_unlock(&p_resource->lock);
return -1;
diff --git a/src/input/resource.h b/src/input/resource.h
index 5e9d5c4ce9..7bb2cfbaa3 100644
--- a/src/input/resource.h
+++ b/src/input/resource.h
@@ -41,7 +41,7 @@ vout_thread_t *input_resource_GetVoutDecoderDevice(input_resource_t *,
const vout_configuration_t *,
enum vlc_vout_order *order,
vlc_decoder_device **);
-int input_resource_ReconfigureVout(input_resource_t *, vlc_decoder_device *, const vout_configuration_t *);
+int input_resource_ReconfigureVout(input_resource_t *, vlc_video_context *, const vout_configuration_t *);
void input_resource_PutVout(input_resource_t *, vout_thread_t *);
/**
diff --git a/src/video_output/display.c b/src/video_output/display.c
index f9fb3d0e7c..556406f7c6 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -729,9 +729,9 @@ void vout_SetDisplayViewpoint(vout_display_t *vd,
vout_display_t *vout_display_New(vlc_object_t *parent,
const video_format_t *source,
+ vlc_video_context *vctx,
const vout_display_cfg_t *cfg,
const char *module,
- vlc_decoder_device *dec_device,
const vout_display_owner_t *owner)
{
vout_display_priv_t *osys = vlc_custom_create(parent, sizeof (*osys),
@@ -770,11 +770,9 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
if (owner)
vd->owner = *owner;
- vlc_video_context *fake_vctx = vlc_video_context_Create(dec_device, VLC_VIDEO_CONTEXT_NONE, 0, NULL);
-
if (vlc_module_load(vd, "vout display", module, module && *module != '\0',
vout_display_start, vd, &osys->cfg, &vd->fmt,
- fake_vctx) == NULL)
+ vctx) == NULL)
goto error;
#if defined(__OS2__)
@@ -796,12 +794,8 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
video_format_Clean(&vd->fmt);
goto error;
}
- if (fake_vctx)
- vlc_video_context_Release(fake_vctx);
return vd;
error:
- if (fake_vctx)
- vlc_video_context_Release(fake_vctx);
video_format_Clean(&vd->source);
vlc_object_delete(vd);
return NULL;
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 72c38f3b9c..5bda6d3f4e 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1494,7 +1494,7 @@ static void ThreadProcessMouseState(vout_thread_t *vout,
vout->p->mouse_event(m, vout->p->mouse_opaque);
}
-static int vout_Start(vout_thread_t *vout, vlc_decoder_device *dec_dev, const vout_configuration_t *cfg)
+static int vout_Start(vout_thread_t *vout, vlc_video_context *vctx, const vout_configuration_t *cfg)
{
vout_thread_sys_t *sys = vout->p;
assert(!sys->dummy);
@@ -1532,6 +1532,16 @@ static int vout_Start(vout_thread_t *vout, vlc_decoder_device *dec_dev, const vo
unsigned num, den;
vlc_mutex_lock(&sys->window_lock);
+#ifndef NDEBUG
+ if (vctx)
+ {
+ // make sure the decoder device we receive matches the one we have cached
+ vlc_decoder_device *dec_device = vlc_video_context_HoldDevice(vctx);
+ assert(dec_device && dec_device == sys->dec_device);
+ vlc_decoder_device_Release(dec_device);
+ }
+#endif
+
dcfg = sys->display_cfg;
switch (sys->source.crop.mode) {
@@ -1560,7 +1570,7 @@ static int vout_Start(vout_thread_t *vout, vlc_decoder_device *dec_dev, const vo
vlc_mutex_lock(&sys->display_lock);
vlc_mutex_unlock(&sys->window_lock);
- sys->display = vout_OpenWrapper(vout, sys->splitter_name, &dcfg, dec_dev);
+ sys->display = vout_OpenWrapper(vout, sys->splitter_name, &dcfg, vctx);
if (sys->display == NULL) {
vlc_mutex_unlock(&sys->display_lock);
goto error;
@@ -1969,7 +1979,7 @@ static int VoutEnableWindow(const vout_configuration_t *cfg, const video_format_
return 0;
}
-int vout_Request(const vout_configuration_t *cfg, vlc_decoder_device *dec_dev, input_thread_t *input)
+int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input_thread_t *input)
{
vout_thread_t *vout = cfg->vout;
vout_thread_sys_t *sys = vout->p;
@@ -2010,7 +2020,7 @@ int vout_Request(const vout_configuration_t *cfg, vlc_decoder_device *dec_dev, i
sys->clock = cfg->clock;
sys->delay = 0;
- if (vout_Start(vout, dec_dev, cfg))
+ if (vout_Start(vout, vctx, cfg))
{
vlc_mutex_lock(&sys->window_lock);
vout_window_Disable(sys->display_cfg.window);
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 713751c26d..74c2916606 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -215,11 +215,11 @@ vlc_decoder_device *vout_GetDevice(const vout_configuration_t *cfg);
*
* \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
+ * \param vctx pointer to the video context to use with the vout or NULL
* \retval 0 on success
* \retval -1 on error
*/
-int vout_Request(const vout_configuration_t *cfg, vlc_decoder_device *dec_dev, input_thread_t *input);
+int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input_thread_t *input);
/**
* Disables a vout.
@@ -267,7 +267,7 @@ void vout_IntfDeinit(vlc_object_t *);
/* */
vout_display_t *vout_OpenWrapper(vout_thread_t *, const char *,
- const vout_display_cfg_t *, vlc_decoder_device *);
+ const vout_display_cfg_t *, vlc_video_context *);
void vout_CloseWrapper(vout_thread_t *, vout_display_t *vd);
/* */
diff --git a/src/video_output/vout_wrapper.c b/src/video_output/vout_wrapper.c
index db2d36e67c..48e1ad8a88 100644
--- a/src/video_output/vout_wrapper.c
+++ b/src/video_output/vout_wrapper.c
@@ -56,7 +56,7 @@ static void VoutViewpointMoved(void *sys, const vlc_viewpoint_t *vp)
*****************************************************************************/
vout_display_t *vout_OpenWrapper(vout_thread_t *vout,
const char *splitter_name, const vout_display_cfg_t *cfg,
- vlc_decoder_device *dec_device)
+ vlc_video_context *vctx)
{
vout_thread_sys_t *sys = vout->p;
vout_display_t *vd;
@@ -73,8 +73,8 @@ vout_display_t *vout_OpenWrapper(vout_thread_t *vout,
else
modlist = "splitter,none";
- vd = vout_display_New(VLC_OBJECT(vout), &sys->original, cfg,
- modlist, sys->dec_device, &owner);
+ vd = vout_display_New(VLC_OBJECT(vout), &sys->original, vctx, cfg,
+ modlist, &owner);
free(modlistbuf);
if (vd == NULL)
More information about the vlc-commits
mailing list