<html><head></head><body>The setup and cleanup callbacks run in display context, AFAIK. That's not synchronized with the window, and in fact, it can't be without risking lock inversion.<br><br><div class="gmail_quote">Le 13 mai 2019 16:30:03 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">On 2019-05-13 15:19, Rémi Denis-Courmont wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">Hi,<br><br>In general, window provider plugins are not reentrant, so you can't <br>simply invoke a callback from a random thread. Unless there are some <br>special provisions for the D3D window provider, this does not look right.<br></blockquote><br>The doc says it can only be called during setup and cleanup calls. As <br>long as this is done, the call should be safe lifecycle-wise. It ends up <br>calling window_ReportSize which is supposed to be thread safe.<br><br>I could add a lock and/or send a custom control that will end up in the <br>vout thread to protect the call. It's like the window report size, it <br>doesn't have to be synchronous with the display calls.<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">Le 13 mai 2019 14:54:51 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<hr>      include/vlc/libvlc_media_player.h       |  8 ++++++++<br>      include/vlc_vout_display.h              |  4 ++++<br>      modules/video_output/win32/direct3d11.c | 10 +++++++++-<br>      modules/video_output/win32/direct3d9.c  | 10 +++++++++-<br>      4 files changed, 30 insertions(+), 2 deletions(-)<br><br>    diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h<br>    index f10fcf7a96..91bc949d01 100644<br>    --- a/include/vlc/libvlc_media_player.h<br>    +++ b/include/vlc/libvlc_media_player.h<br>    @@ -608,6 +608,14 @@ typedef enum libvlc_video_direct3d_engine_t {<br>      typedef struct<br>      {<br>          bool hardware_decoding; /** set if D3D11_CREATE_DEVICE_VIDEO_SUPPORT is needed for D3D11 */<br>    +<br>    +    /** Callback to call when the size of the host changes<br>    +     *<br>    +     * This callback must not be called once the \ref libvlc_video_direct3d_device_cleanup_cb<br>    +     * callback has been called.<br>    +     */<br>    +    void (*repot_size_change)(void *report_opaque, unsigned width, unsigned height);<br>    +    void *report_opaque;<br>      } libvlc_video_direct3d_device_cfg_t;<br>      <br>      typedef struct<br>    diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h<br>    index 687a655cfc..e46696e1d4 100644<br>    --- a/include/vlc_vout_display.h<br>    +++ b/include/vlc_vout_display.h<br>    @@ -388,6 +388,10 @@ static inline void vout_display_SendEventTitle(vout_display_t *vd, const char *t<br>      {<br>          vout_window_SetTitle(vd->cfg->window, title);<br>      }<br>    +static inline void vout_display_SendEventHostSize(vout_display_t *vd, unsigned width, unsigned height)<br>    +{<br>    +    vout_window_SetSize( vd->cfg->window, width, height );<br>    +}<br>      static inline void vout_display_SendEventViewpointMoved(vout_display_t *vd,<br>                                                              const vlc_viewpoint_t *vp)<br>      {<br>    diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c<br>    index b2d5b000f1..bac4f34b94 100644<br>    --- a/modules/video_output/win32/direct3d11.c<br>    +++ b/modules/video_output/win32/direct3d11.c<br>    @@ -1364,13 +1364,21 @@ static const d3d_format_t *GetBlendableFormat(vout_display_t *vd, vlc_fourcc_t i<br>          return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, false, 0, 0, 0, false, supportFlags );<br>      }<br>      <br>    +static void ReportSizeCallback(void *report_opaque, unsigned width, unsigned height)<br>    +{<br>    +    vout_display_t *vd = report_opaque;<br>    +    vout_display_SendEventHostSize( vd, width, height );<br>    +}<br>    +<br>      static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp)<br>      {<br>          vout_display_sys_t *sys = vd->sys;<br>          HRESULT hr = E_FAIL;<br>      <br>          libvlc_video_direct3d_device_cfg_t cfg = {<br>    -        .hardware_decoding = is_d3d11_opaque( vd->source.i_chroma )<br>    +        .hardware_decoding = is_d3d11_opaque( vd->source.i_chroma ),<br>    +        .repot_size_change = ReportSizeCallback,<br>    +        .report_opaque = vd,<br>          };<br>          libvlc_video_direct3d_device_setup_t out;<br>          ID3D11DeviceContext *d3d11_ctx = NULL;<br>    diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c<br>    index 8d5f6b059d..375e6ebcd7 100644<br>    --- a/modules/video_output/win32/direct3d9.c<br>    +++ b/modules/video_output/win32/direct3d9.c<br>    @@ -1662,6 +1662,12 @@ static bool LocalSwapchainStartEndRendering( void *opaque, bool enter, const lib<br>          return true;<br>      }<br>      <br>    +static void ReportSizeCallback(void *report_opaque, unsigned width, unsigned height)<br>    +{<br>    +    vout_display_t *vd = report_opaque;<br>    +    vout_display_SendEventHostSize( vd, width, height );<br>    +}<br>    +<br>      /**<br>       * It creates a Direct3D vout display.<br>       */<br>    @@ -1711,7 +1717,9 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,<br>          }<br>      <br>          libvlc_video_direct3d_device_cfg_t surface_cfg = {<br>    -        .hardware_decoding = is_d3d9_opaque( vd->source.i_chroma )<br>    +        .hardware_decoding = is_d3d9_opaque( vd->source.i_chroma ),<br>    +        .repot_size_change = ReportSizeCallback,<br>    +        .report_opaque = vd,<br>          };<br>          libvlc_video_direct3d_device_setup_t device_setup;<br>          IDirect3DDevice9 *d3d9_device = NULL;<br><br><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser <br>ma brièveté.<hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>