Add some more locking to work around libxcb bugs
authorJulian Scheel <julian@jusst.de>
Sun, 28 Nov 2010 11:29:52 +0100
changeset 11591c655ca7b6bce
parent 11590 03d01d484189
child 11592 e82fdba2e88d
Add some more locking to work around libxcb bugs
src/video_out/video_out_vdpau.c
     1.1 --- a/src/video_out/video_out_vdpau.c	Thu Sep 23 18:19:29 2010 +0100
     1.2 +++ b/src/video_out/video_out_vdpau.c	Sun Nov 28 11:29:52 2010 +0100
     1.3 @@ -61,6 +61,7 @@
     1.4  #define NUM_FRAMES_BACK 1
     1.5  
     1.6  #define LOCKDISPLAY /*define this if you have a buggy libX11/xcb*/
     1.7 +//#undef LOCKDISPLAY 
     1.8  
     1.9  
    1.10  #define DEINT_BOB                    1
    1.11 @@ -167,12 +168,30 @@
    1.12  static VdpVideoSurfaceCreate *orig_vdp_video_surface_create;
    1.13  static VdpVideoSurfaceDestroy *orig_vdp_video_surface_destroy;
    1.14  
    1.15 +static VdpVideoSurfaceCreate *orig_vdp_output_surface_create;
    1.16 +static VdpVideoSurfaceDestroy *orig_vdp_output_surface_destroy;
    1.17 +
    1.18 +static VdpVideoSurfacePutBitsYCbCr *orig_vdp_video_surface_putbits_ycbcr;
    1.19 +
    1.20  static VdpDecoderCreate *orig_vdp_decoder_create;
    1.21  static VdpDecoderDestroy *orig_vdp_decoder_destroy;
    1.22  static VdpDecoderRender *orig_vdp_decoder_render;
    1.23  
    1.24  static Display *guarded_display;
    1.25  
    1.26 +static VdpStatus guarded_vdp_video_surface_putbits_ycbcr(VdpVideoSurface surface, VdpYCbCrFormat source_ycbcr_format, void const *const *source_data, uint32_t const *source_pitches)
    1.27 +{
    1.28 +  VdpStatus r;
    1.29 +#ifdef LOCKDISPLAY
    1.30 +  XLockDisplay(guarded_display);
    1.31 +#endif
    1.32 +  r = orig_vdp_video_surface_putbits_ycbcr(surface, source_ycbcr_format, source_data, source_pitches);
    1.33 +#ifdef LOCKDISPLAY
    1.34 +  XUnlockDisplay(guarded_display);
    1.35 +#endif
    1.36 +  return r;
    1.37 +}
    1.38 +
    1.39  static VdpStatus guarded_vdp_video_surface_create(VdpDevice device, VdpChromaType chroma_type, uint32_t width, uint32_t height,VdpVideoSurface *surface)
    1.40  {
    1.41    VdpStatus r;
    1.42 @@ -195,6 +214,28 @@
    1.43    return r;
    1.44  }
    1.45  
    1.46 +static VdpStatus guarded_vdp_output_surface_create(VdpDevice device, VdpChromaType chroma_type, uint32_t width, uint32_t height,VdpVideoSurface *surface)
    1.47 +{
    1.48 +  VdpStatus r;
    1.49 +#ifdef LOCKDISPLAY
    1.50 +  XLockDisplay(guarded_display);
    1.51 +#endif
    1.52 +  r = orig_vdp_output_surface_create(device, chroma_type, width, height, surface);
    1.53 +#ifdef LOCKDISPLAY
    1.54 +  XUnlockDisplay(guarded_display);
    1.55 +#endif
    1.56 +  return r;
    1.57 +}
    1.58 +
    1.59 +static VdpStatus guarded_vdp_output_surface_destroy(VdpVideoSurface surface)
    1.60 +{
    1.61 +  VdpStatus r;
    1.62 +  XLockDisplay(guarded_display);
    1.63 +  r = orig_vdp_output_surface_destroy(surface);
    1.64 +  XUnlockDisplay(guarded_display);
    1.65 +  return r;
    1.66 +}
    1.67 +
    1.68  static VdpStatus guarded_vdp_decoder_create(VdpDevice device, VdpDecoderProfile profile, uint32_t width, uint32_t height, uint32_t max_references, VdpDecoder *decoder)
    1.69  {
    1.70    VdpStatus r;
    1.71 @@ -1689,6 +1730,7 @@
    1.72    VdpRect vid_source, out_dest, vid_dest;
    1.73  
    1.74    vdpau_check_output_size( this_gen );
    1.75 +
    1.76    vid_source.x0 = this->sc.displayed_xoffset; vid_source.y0 = this->sc.displayed_yoffset;
    1.77    vid_source.x1 = this->sc.displayed_width+this->sc.displayed_xoffset; vid_source.y1 = this->sc.displayed_height+this->sc.displayed_yoffset;
    1.78    out_dest.x0 = out_dest.y0 = 0;
    1.79 @@ -2417,16 +2459,16 @@
    1.80    st = vdp_get_proc_address( vdp_device, VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , (void*)&orig_vdp_video_surface_destroy ); vdp_video_surface_destroy = guarded_vdp_video_surface_destroy;
    1.81    if ( vdpau_init_error( st, "Can't get VIDEO_SURFACE_DESTROY proc address !!", &this->vo_driver, 1 ) )
    1.82      return NULL;
    1.83 -  st = vdp_get_proc_address( vdp_device, VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , (void*)&vdp_video_surface_putbits_ycbcr );
    1.84 +  st = vdp_get_proc_address( vdp_device, VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , (void*)&orig_vdp_video_surface_putbits_ycbcr ); vdp_video_surface_putbits_ycbcr = guarded_vdp_video_surface_putbits_ycbcr;
    1.85    if ( vdpau_init_error( st, "Can't get VIDEO_SURFACE_PUT_BITS_Y_CB_CR proc address !!", &this->vo_driver, 1 ) )
    1.86      return NULL;
    1.87    st = vdp_get_proc_address( vdp_device, VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , (void*)&vdp_video_surface_getbits_ycbcr );
    1.88    if ( vdpau_init_error( st, "Can't get VIDEO_SURFACE_GET_BITS_Y_CB_CR proc address !!", &this->vo_driver, 1 ) )
    1.89      return NULL;
    1.90 -  st = vdp_get_proc_address( vdp_device, VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , (void*)&vdp_output_surface_create );
    1.91 +  st = vdp_get_proc_address( vdp_device, VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , (void*)&orig_vdp_output_surface_create ); vdp_output_surface_create = guarded_vdp_output_surface_create;
    1.92    if ( vdpau_init_error( st, "Can't get OUTPUT_SURFACE_CREATE proc address !!", &this->vo_driver, 1 ) )
    1.93      return NULL;
    1.94 -  st = vdp_get_proc_address( vdp_device, VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , (void*)&vdp_output_surface_destroy );
    1.95 +  st = vdp_get_proc_address( vdp_device, VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , (void*)&orig_vdp_output_surface_destroy ); vdp_output_surface_destroy = guarded_vdp_output_surface_destroy;
    1.96    if ( vdpau_init_error( st, "Can't get OUTPUT_SURFACE_DESTROY proc address !!", &this->vo_driver, 1 ) )
    1.97      return NULL;
    1.98    st = vdp_get_proc_address( vdp_device, VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE , (void*)&vdp_output_surface_render_bitmap_surface );