[vlc-devel] [PATCH 3/4] libvlc: add a way to disable the GPU callback engine
Steve Lhomme
robux4 at ycbcr.xyz
Wed Feb 12 11:58:30 CET 2020
On 2020-02-11 15:39, Steve Lhomme wrote:
> It should fallback to normal playback into a custom window.
> ---
> include/vlc/libvlc_media_player.h | 2 ++
> lib/media_player.c | 11 +++++++++++
> modules/hw/d3d11/d3d11_device.c | 12 +++++++++---
> modules/hw/d3d9/d3d9_device.c | 15 +++++++++++----
> modules/video_output/vgl.c | 5 +++++
> 5 files changed, 38 insertions(+), 7 deletions(-)
>
> diff --git a/modules/hw/d3d11/d3d11_device.c b/modules/hw/d3d11/d3d11_device.c
> index bec66708919..734ee9bcdf9 100644
> --- a/modules/hw/d3d11/d3d11_device.c
> +++ b/modules/hw/d3d11/d3d11_device.c
> @@ -93,8 +93,11 @@ static int D3D11OpenDecoderDevice(vlc_decoder_device *device, bool forced, vout_
> else
> #endif
> {
> - libvlc_video_output_setup_cb setupDeviceCb = var_InheritAddress( device, "vout-cb-setup" );
> - if ( setupDeviceCb )
> + libvlc_video_engine_t engineType = var_InheritInteger( device, "vout-cb-type" );
This doesn't work when used outside of libvlc. We need to create this
variable and set it to libvlc_video_engine_none in libvlc-module.c. So a
more generic name would be nice.
> + libvlc_video_output_setup_cb setupDeviceCb = NULL;
> + if (engineType == libvlc_video_engine_d3d11)
> + setupDeviceCb = var_InheritAddress( device, "vout-cb-setup" );
> + if ( setupDeviceCb != NULL)
> {
> /* decoder device coming from the external app */
> sys->external.opaque = var_InheritAddress( device, "vout-cb-opaque" );
> @@ -111,7 +114,8 @@ static int D3D11OpenDecoderDevice(vlc_decoder_device *device, bool forced, vout_
> }
> hr = D3D11_CreateDeviceExternal(device, out.device_context, true, &sys->dec_device.d3d_dev);
> }
> - else
> + else if ( engineType == libvlc_video_engine_none ||
> + engineType == libvlc_video_engine_d3d11 )
> {
> /* internal decoder device */
> #if !VLC_WINSTORE_APP
> @@ -131,6 +135,8 @@ static int D3D11OpenDecoderDevice(vlc_decoder_device *device, bool forced, vout_
> true /* is_d3d11_opaque(chroma) */,
> &sys->dec_device.d3d_dev );
> }
> + else
> + goto error;
> }
>
> if ( FAILED( hr ) )
> diff --git a/modules/hw/d3d9/d3d9_device.c b/modules/hw/d3d9/d3d9_device.c
> index 07b76be9ccd..23dead0239e 100644
> --- a/modules/hw/d3d9/d3d9_device.c
> +++ b/modules/hw/d3d9/d3d9_device.c
> @@ -70,11 +70,14 @@ int D3D9OpenDecoderDevice(vlc_decoder_device *device, vout_window_t *wnd)
>
> int adapter;
> sys->cleanupDeviceCb = NULL;
> - libvlc_video_output_setup_cb setupDeviceCb = var_InheritAddress( device, "vout-cb-setup" );
> - if ( setupDeviceCb )
> + libvlc_video_engine_t engineType = var_InheritInteger( device, "vout-cb-type" );
> + libvlc_video_output_setup_cb setupDeviceCb = NULL;
> + if (engineType == libvlc_video_engine_d3d9)
> + setupDeviceCb = var_InheritAddress( device, "vout-cb-setup" );
> + if ( setupDeviceCb != NULL)
> {
> /* external rendering */
> - libvlc_video_setup_device_info_t out = { .device_context = NULL, .adapter = 0 };
> + libvlc_video_setup_device_info_t out = { .adapter = 0 };
> sys->opaque = var_InheritAddress( device, "vout-cb-opaque" );
> sys->cleanupDeviceCb = var_InheritAddress( device, "vout-cb-cleanup" );
> libvlc_video_setup_device_cfg_t cfg = {
> @@ -90,7 +93,9 @@ int D3D9OpenDecoderDevice(vlc_decoder_device *device, vout_window_t *wnd)
> D3D9_CloneExternal( &sys->dec_device.hd3d, (IDirect3D9*) out.device_context );
> adapter = out.adapter;
> }
> - else
> + else if ( engineType == libvlc_video_engine_none ||
> + engineType == libvlc_video_engine_d3d9 ||
> + engineType == libvlc_video_engine_opengl )
> {
> /* internal rendering */
> if (D3D9_Create(device, &sys->dec_device.hd3d) != VLC_SUCCESS)
> @@ -101,6 +106,8 @@ int D3D9OpenDecoderDevice(vlc_decoder_device *device, vout_window_t *wnd)
> /* find the best adapter to use, not based on the HWND used */
> adapter = -1;
> }
> + else
> + goto error;
>
> HRESULT hr = D3D9_CreateDevice( device, &sys->dec_device.hd3d, adapter, &sys->dec_device.d3ddev );
> if ( FAILED(hr) )
> diff --git a/modules/video_output/vgl.c b/modules/video_output/vgl.c
> index 99cf6f747eb..40487ea2476 100644
> --- a/modules/video_output/vgl.c
> +++ b/modules/video_output/vgl.c
> @@ -123,6 +123,11 @@ static int Open(vlc_gl_t *gl, unsigned width, unsigned height)
> {
> vout_display_sys_t * sys;
>
> + libvlc_video_engine_t engineType = var_InheritInteger( gl, "vout-cb-type" );
> + if ( engineType != libvlc_video_engine_opengl &&
> + engineType != libvlc_video_engine_gles2 )
> + return VLC_EBADVAR;
> +
> /* Allocate structure */
> gl->sys = sys = vlc_obj_calloc(VLC_OBJECT(gl), 1, sizeof(*sys));
> if( !sys )
> --
> 2.17.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
More information about the vlc-devel
mailing list