winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
April 2022
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
1024 discussions
Start a n
N
ew thread
Huw Davies : wineoss: Move get_frequency to the unixlib.
by Alexandre Julliard
18 Apr '22
18 Apr '22
Module: wine Branch: master Commit: 4e32993717cc2c127603c199435456ed546eae21 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=4e32993717cc2c127603c199…
Author: Huw Davies <huw(a)codeweavers.com> Date: Fri Apr 15 21:40:40 2022 +0100 wineoss: Move get_frequency to the unixlib. Technically the lock doesn't need to be taken here since the data is static, however doing so keeps the implementation consistent with the others. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Andrew Eikum <aeikum(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wineoss.drv/mmdevdrv.c | 11 +++++------ dlls/wineoss.drv/oss.c | 17 +++++++++++++++++ dlls/wineoss.drv/unixlib.h | 8 ++++++++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index c101d757836..6498a4750d4 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -1427,16 +1427,15 @@ static ULONG WINAPI AudioClock_Release(IAudioClock *iface) static HRESULT WINAPI AudioClock_GetFrequency(IAudioClock *iface, UINT64 *freq) { ACImpl *This = impl_from_IAudioClock(iface); - struct oss_stream *stream = This->stream; + struct get_frequency_params params; TRACE("(%p)->(%p)\n", This, freq); - if(stream->share == AUDCLNT_SHAREMODE_SHARED) - *freq = (UINT64)stream->fmt->nSamplesPerSec * stream->fmt->nBlockAlign; - else - *freq = stream->fmt->nSamplesPerSec; + params.stream = This->stream; + params.frequency = freq; + OSS_CALL(get_frequency, ¶ms); - return S_OK; + return params.result; } static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos, diff --git a/dlls/wineoss.drv/oss.c b/dlls/wineoss.drv/oss.c index ffea1bb8338..3a512c7cd9e 100644 --- a/dlls/wineoss.drv/oss.c +++ b/dlls/wineoss.drv/oss.c @@ -1256,6 +1256,22 @@ static NTSTATUS get_next_packet_size(void *args) return oss_unlock_result(stream, ¶ms->result, S_OK); } +static NTSTATUS get_frequency(void *args) +{ + struct get_frequency_params *params = args; + struct oss_stream *stream = params->stream; + UINT64 *freq = params->frequency; + + oss_lock(stream); + + if(stream->share == AUDCLNT_SHAREMODE_SHARED) + *freq = (UINT64)stream->fmt->nSamplesPerSec * stream->fmt->nBlockAlign; + else + *freq = stream->fmt->nSamplesPerSec; + + return oss_unlock_result(stream, ¶ms->result, S_OK); +} + static NTSTATUS set_event_handle(void *args) { struct set_event_handle_params *params = args; @@ -1296,5 +1312,6 @@ unixlib_entry_t __wine_unix_call_funcs[] = get_latency, get_current_padding, get_next_packet_size, + get_frequency, set_event_handle, }; diff --git a/dlls/wineoss.drv/unixlib.h b/dlls/wineoss.drv/unixlib.h index a809ad41d3e..9a544ae7899 100644 --- a/dlls/wineoss.drv/unixlib.h +++ b/dlls/wineoss.drv/unixlib.h @@ -193,6 +193,13 @@ struct get_next_packet_size_params UINT32 *frames; }; +struct get_frequency_params +{ + struct oss_stream *stream; + HRESULT result; + UINT64 *frequency; +}; + struct set_event_handle_params { struct oss_stream *stream; @@ -220,6 +227,7 @@ enum oss_funcs oss_get_latency, oss_get_current_padding, oss_get_next_packet_size, + oss_get_frequency, oss_set_event_handle, };
1
0
0
0
Huw Davies : wineoss: Move get_next_packet_size to the unixlib.
by Alexandre Julliard
18 Apr '22
18 Apr '22
Module: wine Branch: master Commit: d1ab294002ed8eebc9483d5452f8541f27b62703 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d1ab294002ed8eebc9483d54…
Author: Huw Davies <huw(a)codeweavers.com> Date: Fri Apr 15 21:40:39 2022 +0100 wineoss: Move get_next_packet_size to the unixlib. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Andrew Eikum <aeikum(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wineoss.drv/mmdevdrv.c | 12 +++++------- dlls/wineoss.drv/oss.c | 14 ++++++++++++++ dlls/wineoss.drv/unixlib.h | 8 ++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index 80bac1d9ceb..c101d757836 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -1364,20 +1364,18 @@ static HRESULT WINAPI AudioCaptureClient_GetNextPacketSize( IAudioCaptureClient *iface, UINT32 *frames) { ACImpl *This = impl_from_IAudioCaptureClient(iface); - struct oss_stream *stream = This->stream; + struct get_next_packet_size_params params; TRACE("(%p)->(%p)\n", This, frames); if(!frames) return E_POINTER; - oss_lock(stream); - - *frames = stream->held_frames < stream->period_frames ? 0 : stream->period_frames; - - oss_unlock(stream); + params.stream = This->stream; + params.frames = frames; + OSS_CALL(get_next_packet_size, ¶ms); - return S_OK; + return params.result; } static const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl = diff --git a/dlls/wineoss.drv/oss.c b/dlls/wineoss.drv/oss.c index f1994295618..ffea1bb8338 100644 --- a/dlls/wineoss.drv/oss.c +++ b/dlls/wineoss.drv/oss.c @@ -1243,6 +1243,19 @@ static NTSTATUS get_current_padding(void *args) return oss_unlock_result(stream, ¶ms->result, S_OK); } +static NTSTATUS get_next_packet_size(void *args) +{ + struct get_next_packet_size_params *params = args; + struct oss_stream *stream = params->stream; + UINT32 *frames = params->frames; + + oss_lock(stream); + + *frames = stream->held_frames < stream->period_frames ? 0 : stream->period_frames; + + return oss_unlock_result(stream, ¶ms->result, S_OK); +} + static NTSTATUS set_event_handle(void *args) { struct set_event_handle_params *params = args; @@ -1282,5 +1295,6 @@ unixlib_entry_t __wine_unix_call_funcs[] = get_buffer_size, get_latency, get_current_padding, + get_next_packet_size, set_event_handle, }; diff --git a/dlls/wineoss.drv/unixlib.h b/dlls/wineoss.drv/unixlib.h index 2f0884b9ac5..a809ad41d3e 100644 --- a/dlls/wineoss.drv/unixlib.h +++ b/dlls/wineoss.drv/unixlib.h @@ -186,6 +186,13 @@ struct get_current_padding_params UINT32 *padding; }; +struct get_next_packet_size_params +{ + struct oss_stream *stream; + HRESULT result; + UINT32 *frames; +}; + struct set_event_handle_params { struct oss_stream *stream; @@ -212,6 +219,7 @@ enum oss_funcs oss_get_buffer_size, oss_get_latency, oss_get_current_padding, + oss_get_next_packet_size, oss_set_event_handle, };
1
0
0
0
Jacek Caban : winex11: Use pthread for xrender locking.
by Alexandre Julliard
18 Apr '22
18 Apr '22
Module: wine Branch: master Commit: b8a2198d40de9bb3dd5c4aad7ae860602f4de3f5 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=b8a2198d40de9bb3dd5c4aad…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Apr 18 14:41:37 2022 +0200 winex11: Use pthread for xrender locking. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/xrender.c | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c index fd92bd63389..be64da90290 100644 --- a/dlls/winex11.drv/xrender.c +++ b/dlls/winex11.drv/xrender.c @@ -190,14 +190,7 @@ MAKE_FUNCPTR(XRenderQueryExtension) #undef MAKE_FUNCPTR -static CRITICAL_SECTION xrender_cs; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &xrender_cs, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": xrender_cs") } -}; -static CRITICAL_SECTION xrender_cs = { &critsect_debug, -1, 0, 0, 0, 0 }; +static pthread_mutex_t xrender_mutex = PTHREAD_MUTEX_INITIALIZER; #define MS_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ ( ( (ULONG)_x4 << 24 ) | \ @@ -566,7 +559,7 @@ static Picture get_no_alpha_mask(void) static Pixmap pixmap; static Picture pict; - EnterCriticalSection( &xrender_cs ); + pthread_mutex_lock( &xrender_mutex ); if (!pict) { XRenderPictureAttributes pa; @@ -581,7 +574,7 @@ static Picture get_no_alpha_mask(void) col.alpha = 0; pXRenderFillRectangle( gdi_display, PictOpSrc, pict, &col, 0, 0, 1, 1 ); } - LeaveCriticalSection( &xrender_cs ); + pthread_mutex_unlock( &xrender_mutex ); return pict; } @@ -877,11 +870,11 @@ static HFONT CDECL xrenderdrv_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_fla lfsz_calc_hash(&lfsz); - EnterCriticalSection(&xrender_cs); + pthread_mutex_lock( &xrender_mutex ); if (physdev->cache_index != -1) dec_ref_cache( physdev->cache_index ); physdev->cache_index = GetCacheEntry( &lfsz ); - LeaveCriticalSection(&xrender_cs); + pthread_mutex_unlock( &xrender_mutex ); return ret; } @@ -970,9 +963,9 @@ static BOOL CDECL xrenderdrv_DeleteDC( PHYSDEV dev ) free_xrender_picture( physdev ); - EnterCriticalSection( &xrender_cs ); + pthread_mutex_lock( &xrender_mutex ); if (physdev->cache_index != -1) dec_ref_cache( physdev->cache_index ); - LeaveCriticalSection( &xrender_cs ); + pthread_mutex_unlock( &xrender_mutex ); HeapFree( GetProcessHeap(), 0, physdev ); return TRUE; @@ -1022,7 +1015,7 @@ static void CDECL xrenderdrv_SetDeviceClipping( PHYSDEV dev, HRGN rgn ) /************************************************************************ * UploadGlyph * - * Helper to ExtTextOut. Must be called inside xrender_cs + * Helper to ExtTextOut. Must be called inside xrender_mutex */ static void UploadGlyph(struct xrender_physdev *physDev, UINT glyph, enum glyph_type type) { @@ -1224,7 +1217,7 @@ static void UploadGlyph(struct xrender_physdev *physDev, UINT glyph, enum glyph_ * get_tile_pict * * Returns an appropriate Picture for tiling the text colour. - * Call and use result within the xrender_cs + * Call and use result within the xrender_mutex */ static Picture get_tile_pict( enum wxr_format wxr_format, const XRenderColor *color) { @@ -1273,7 +1266,7 @@ static Picture get_tile_pict( enum wxr_format wxr_format, const XRenderColor *co * get_mask_pict * * Returns an appropriate Picture for masking with the specified alpha. - * Call and use result within the xrender_cs + * Call and use result within the xrender_mutex */ static Picture get_mask_pict( int alpha ) { @@ -1352,7 +1345,7 @@ static BOOL CDECL xrenderdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, if(count == 0) return TRUE; - EnterCriticalSection(&xrender_cs); + pthread_mutex_lock( &xrender_mutex ); entry = glyphsetCache + physdev->cache_index; formatEntry = entry->format[type][aa_type_from_flags( physdev->aa_flags )]; @@ -1369,7 +1362,7 @@ static BOOL CDECL xrenderdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, if (!formatEntry) { WARN("could not upload requested glyphs\n"); - LeaveCriticalSection(&xrender_cs); + pthread_mutex_unlock( &xrender_mutex ); return FALSE; } @@ -1440,7 +1433,7 @@ static BOOL CDECL xrenderdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, 0, 0, 0, 0, elts, count); HeapFree(GetProcessHeap(), 0, elts); - LeaveCriticalSection(&xrender_cs); + pthread_mutex_unlock( &xrender_mutex ); add_device_bounds( physdev->x11dev, &bounds ); return TRUE; } @@ -1557,7 +1550,7 @@ static void xrender_mono_blit( Picture src_pict, Picture dst_pict, * contains a 1x1 picture for tiling. The source data effectively acts as an alpha channel to * the tile data. */ - EnterCriticalSection( &xrender_cs ); + pthread_mutex_lock( &xrender_mutex ); color = *bg; color.alpha = 0xffff; /* tile pict needs 100% alpha */ tile_pict = get_tile_pict( dst_format, &color ); @@ -1581,7 +1574,7 @@ static void xrender_mono_blit( Picture src_pict, Picture dst_pict, } pXRenderComposite(gdi_display, PictOpOver, tile_pict, src_pict, dst_pict, 0, 0, x_offset, y_offset, x_dst, y_dst, width_dst, height_dst ); - LeaveCriticalSection( &xrender_cs ); + pthread_mutex_unlock( &xrender_mutex ); /* force the alpha channel for background pixels, it has been set to 100% by the tile */ if (bg->alpha != 0xffff && (dst_format == WXR_FORMAT_A8R8G8B8 || dst_format == WXR_FORMAT_B8G8R8A8)) @@ -1919,7 +1912,7 @@ static DWORD CDECL xrenderdrv_BlendImage( PHYSDEV dev, BITMAPINFO *info, const s dst_pict = get_xrender_picture( physdev, 0, &dst->visrect ); - EnterCriticalSection( &xrender_cs ); + pthread_mutex_lock( &xrender_mutex ); mask_pict = get_mask_pict( func.SourceConstantAlpha * 257 ); xrender_blit( PictOpOver, src_pict, mask_pict, dst_pict, @@ -1931,7 +1924,7 @@ static DWORD CDECL xrenderdrv_BlendImage( PHYSDEV dev, BITMAPINFO *info, const s pXRenderFreePicture( gdi_display, src_pict ); XFreePixmap( gdi_display, src_pixmap ); - LeaveCriticalSection( &xrender_cs ); + pthread_mutex_unlock( &xrender_mutex ); add_device_bounds( physdev->x11dev, &dst->visrect ); } return ret; @@ -2008,7 +2001,7 @@ static BOOL CDECL xrenderdrv_AlphaBlend( PHYSDEV dst_dev, struct bitblt_coords * if (tmp_pict) src_pict = tmp_pict; - EnterCriticalSection( &xrender_cs ); + pthread_mutex_lock( &xrender_mutex ); mask_pict = get_mask_pict( blendfn.SourceConstantAlpha * 257 ); xrender_blit( PictOpOver, src_pict, mask_pict, dst_pict, @@ -2022,7 +2015,7 @@ static BOOL CDECL xrenderdrv_AlphaBlend( PHYSDEV dst_dev, struct bitblt_coords * if (tmp_pict) pXRenderFreePicture( gdi_display, tmp_pict ); if (tmp_pixmap) XFreePixmap( gdi_display, tmp_pixmap ); - LeaveCriticalSection( &xrender_cs ); + pthread_mutex_unlock( &xrender_mutex ); add_device_bounds( physdev_dst->x11dev, &dst->visrect ); return TRUE; }
1
0
0
0
Jacek Caban : winex11: Use pthread for xrandr locking.
by Alexandre Julliard
18 Apr '22
18 Apr '22
Module: wine Branch: master Commit: 95825139b8f65cb8dae843c2e6ed407024358729 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=95825139b8f65cb8dae843c2…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Apr 18 14:41:30 2022 +0200 winex11: Use pthread for xrandr locking. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/xrandr.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index 9f58246979a..e97034fcb2c 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -334,22 +334,15 @@ static struct current_mode } *current_modes; static int current_mode_count; -static CRITICAL_SECTION current_modes_section; -static CRITICAL_SECTION_DEBUG current_modes_critsect_debug = -{ - 0, 0, ¤t_modes_section, - {¤t_modes_critsect_debug.ProcessLocksList, ¤t_modes_critsect_debug.ProcessLocksList}, - 0, 0, {(DWORD_PTR)(__FILE__ ": current_modes_section")} -}; -static CRITICAL_SECTION current_modes_section = {¤t_modes_critsect_debug, -1, 0, 0, 0, 0}; +static pthread_mutex_t xrandr_mutex = PTHREAD_MUTEX_INITIALIZER; static void xrandr14_invalidate_current_mode_cache(void) { - EnterCriticalSection( ¤t_modes_section ); + pthread_mutex_lock( &xrandr_mutex ); heap_free( current_modes); current_modes = NULL; current_mode_count = 0; - LeaveCriticalSection( ¤t_modes_section ); + pthread_mutex_unlock( &xrandr_mutex ); } static XRRScreenResources *xrandr_get_screen_resources(void) @@ -1228,12 +1221,12 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, ULONG_PTR *id ) return FALSE; /* Update cache */ - EnterCriticalSection( ¤t_modes_section ); + pthread_mutex_lock( &xrandr_mutex ); if (!current_modes) { if (!xrandr14_get_gpus2( &gpus, &gpu_count, FALSE )) { - LeaveCriticalSection( ¤t_modes_section ); + pthread_mutex_unlock( &xrandr_mutex ); return FALSE; } @@ -1274,12 +1267,12 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, ULONG_PTR *id ) if (display_idx >= current_mode_count) { - LeaveCriticalSection( ¤t_modes_section ); + pthread_mutex_unlock( &xrandr_mutex ); return FALSE; } *id = current_modes[display_idx].id; - LeaveCriticalSection( ¤t_modes_section ); + pthread_mutex_unlock( &xrandr_mutex ); return TRUE; } @@ -1440,7 +1433,7 @@ static BOOL xrandr14_get_current_mode( ULONG_PTR id, DEVMODEW *mode ) RECT primary; INT mode_idx; - EnterCriticalSection( ¤t_modes_section ); + pthread_mutex_lock( &xrandr_mutex ); for (mode_idx = 0; mode_idx < current_mode_count; ++mode_idx) { if (current_modes[mode_idx].id != id) @@ -1453,7 +1446,7 @@ static BOOL xrandr14_get_current_mode( ULONG_PTR id, DEVMODEW *mode ) } memcpy( mode, ¤t_modes[mode_idx].mode, sizeof(*mode) ); - LeaveCriticalSection( ¤t_modes_section ); + pthread_mutex_unlock( &xrandr_mutex ); return TRUE; } @@ -1524,7 +1517,7 @@ done: mode_ptr->mode.dmDriverExtra = 0; mode_ptr->loaded = TRUE; } - LeaveCriticalSection( ¤t_modes_section ); + pthread_mutex_unlock( &xrandr_mutex ); if (crtc_info) pXRRFreeCrtcInfo( crtc_info ); if (output_info)
1
0
0
0
Jacek Caban : winex11: Use pthread for error handler locking.
by Alexandre Julliard
18 Apr '22
18 Apr '22
Module: wine Branch: master Commit: 9a320b39387d33e5a180b5db65cea05ce8ba4fe9 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=9a320b39387d33e5a180b5db…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Apr 18 14:41:18 2022 +0200 winex11: Use pthread for error handler locking. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/x11drv_main.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index c286d2fd1f2..203237f24aa 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -96,15 +96,7 @@ static BOOL use_xim = TRUE; static WCHAR input_style[20]; static pthread_mutex_t d3dkmt_mutex = PTHREAD_MUTEX_INITIALIZER; - -static CRITICAL_SECTION x11drv_error_section; -static CRITICAL_SECTION_DEBUG x11drv_error_section_debug = -{ - 0, 0, &x11drv_error_section, - { &x11drv_error_section_debug.ProcessLocksList, &x11drv_error_section_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": x11drv_error_section") } -}; -static CRITICAL_SECTION x11drv_error_section = { &x11drv_error_section_debug, -1, 0, 0, 0, 0 }; +static pthread_mutex_t error_mutex = PTHREAD_MUTEX_INITIALIZER; struct d3dkmt_vidpn_source { @@ -255,7 +247,7 @@ static inline BOOL ignore_error( Display *display, XErrorEvent *event ) */ void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg ) { - EnterCriticalSection( &x11drv_error_section ); + pthread_mutex_lock( &error_mutex ); err_callback = callback; err_callback_display = display; err_callback_arg = arg; @@ -274,7 +266,7 @@ int X11DRV_check_error(void) { int res = err_callback_result; err_callback = NULL; - LeaveCriticalSection( &x11drv_error_section ); + pthread_mutex_unlock( &error_mutex ); return res; }
1
0
0
0
Jacek Caban : winex11: Use pthread for D3DKMT locking.
by Alexandre Julliard
18 Apr '22
18 Apr '22
Module: wine Branch: master Commit: 53978351a07cd81b38ed37e08f7c213d95cb79f7 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=53978351a07cd81b38ed37e0…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Apr 18 14:41:05 2022 +0200 winex11: Use pthread for D3DKMT locking. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/x11drv_main.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 49aff9571bc..c286d2fd1f2 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -95,14 +95,7 @@ static int (*old_error_handler)( Display *, XErrorEvent * ); static BOOL use_xim = TRUE; static WCHAR input_style[20]; -static CRITICAL_SECTION x11drv_section; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &x11drv_section, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": x11drv_section") } -}; -static CRITICAL_SECTION x11drv_section = { &critsect_debug, -1, 0, 0, 0, 0 }; +static pthread_mutex_t d3dkmt_mutex = PTHREAD_MUTEX_INITIALIZER; static CRITICAL_SECTION x11drv_error_section; static CRITICAL_SECTION_DEBUG x11drv_error_section_debug = @@ -863,7 +856,7 @@ NTSTATUS CDECL X11DRV_D3DKMTSetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNE TRACE("(%p)\n", desc); - EnterCriticalSection( &x11drv_section ); + pthread_mutex_lock( &d3dkmt_mutex ); /* Check parameters */ for (i = 0; i < desc->VidPnSourceCount; ++i) @@ -962,7 +955,7 @@ NTSTATUS CDECL X11DRV_D3DKMTSetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNE } done: - LeaveCriticalSection( &x11drv_section ); + pthread_mutex_unlock( &d3dkmt_mutex ); return status; } @@ -978,15 +971,15 @@ NTSTATUS CDECL X11DRV_D3DKMTCheckVidPnExclusiveOwnership( const D3DKMT_CHECKVIDP if (!desc || !desc->hAdapter) return STATUS_INVALID_PARAMETER; - EnterCriticalSection( &x11drv_section ); + pthread_mutex_lock( &d3dkmt_mutex ); LIST_FOR_EACH_ENTRY( source, &d3dkmt_vidpn_sources, struct d3dkmt_vidpn_source, entry ) { if (source->id == desc->VidPnSourceId && source->type == D3DKMT_VIDPNSOURCEOWNER_EXCLUSIVE) { - LeaveCriticalSection( &x11drv_section ); + pthread_mutex_unlock( &d3dkmt_mutex ); return STATUS_GRAPHICS_PRESENT_OCCLUDED; } } - LeaveCriticalSection( &x11drv_section ); + pthread_mutex_unlock( &d3dkmt_mutex ); return STATUS_SUCCESS; }
1
0
0
0
Jacek Caban : winex11: Use pthread for win data locking.
by Alexandre Julliard
18 Apr '22
18 Apr '22
Module: wine Branch: master Commit: fd83308b0b89dc560df77221dcd509bca336a323 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=fd83308b0b89dc560df77221…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Apr 18 14:40:59 2022 +0200 winex11: Use pthread for win data locking. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/window.c | 28 +++++++++++++++------------- dlls/winex11.drv/x11drv.h | 3 +-- dlls/winex11.drv/x11drv_main.c | 4 +--- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index dd5c298c7a6..3f20fc9c7d2 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -86,7 +86,7 @@ BOOL clipping_cursor = FALSE; XContext winContext = 0; /* X context to associate a struct x11drv_win_data to an hwnd */ -XContext win_data_context = 0; +static XContext win_data_context = 0; /* time of last user event and window where it's stored */ static Time last_user_time; @@ -99,14 +99,7 @@ static const WCHAR whole_window_prop[] = static const WCHAR clip_window_prop[] = {'_','_','w','i','n','e','_','x','1','1','_','c','l','i','p','_','w','i','n','d','o','w',0}; -static CRITICAL_SECTION win_data_section; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &win_data_section, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": win_data_section") } -}; -static CRITICAL_SECTION win_data_section = { &critsect_debug, -1, 0, 0, 0, 0 }; +static pthread_mutex_t win_data_mutex = PTHREAD_MUTEX_INITIALIZER; /*********************************************************************** @@ -215,7 +208,7 @@ static struct x11drv_win_data *alloc_win_data( Display *display, HWND hwnd ) data->display = display; data->vis = default_visual; data->hwnd = hwnd; - EnterCriticalSection( &win_data_section ); + pthread_mutex_lock( &win_data_mutex ); XSaveContext( gdi_display, (XID)hwnd, win_data_context, (char *)data ); } return data; @@ -1938,10 +1931,10 @@ struct x11drv_win_data *get_win_data( HWND hwnd ) char *data; if (!hwnd) return NULL; - EnterCriticalSection( &win_data_section ); + pthread_mutex_lock( &win_data_mutex ); if (!XFindContext( gdi_display, (XID)hwnd, win_data_context, &data )) return (struct x11drv_win_data *)data; - LeaveCriticalSection( &win_data_section ); + pthread_mutex_unlock( &win_data_mutex ); return NULL; } @@ -1953,7 +1946,7 @@ struct x11drv_win_data *get_win_data( HWND hwnd ) */ void release_win_data( struct x11drv_win_data *data ) { - if (data) LeaveCriticalSection( &win_data_section ); + if (data) pthread_mutex_unlock( &win_data_mutex ); } @@ -3039,3 +3032,12 @@ void X11DRV_FlashWindowEx( FLASHWINFO *pfinfo ) } release_win_data( data ); } + +void init_win_context(void) +{ + init_recursive_mutex( &win_data_mutex ); + + winContext = XUniqueContext(); + win_data_context = XUniqueContext(); + cursor_context = XUniqueContext(); +} diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index ed7a75a8d17..95e4b4ff29a 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -661,6 +661,7 @@ extern void change_systray_owner( Display *display, Window systray_window ) DECL extern void update_systray_balloon_position(void) DECLSPEC_HIDDEN; extern HWND create_foreign_window( Display *display, Window window ) DECLSPEC_HIDDEN; extern BOOL update_clipboard( HWND hwnd ) DECLSPEC_HIDDEN; +extern void init_win_context(void) DECLSPEC_HIDDEN; static inline void mirror_rect( const RECT *window_rect, RECT *rect ) { @@ -672,8 +673,6 @@ static inline void mirror_rect( const RECT *window_rect, RECT *rect ) /* X context to associate a hwnd to an X window */ extern XContext winContext DECLSPEC_HIDDEN; -/* X context to associate a struct x11drv_win_data to an hwnd */ -extern XContext win_data_context DECLSPEC_HIDDEN; /* X context to associate an X cursor to a Win32 cursor handle */ extern XContext cursor_context DECLSPEC_HIDDEN; diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 539f49197a3..49aff9571bc 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -683,9 +683,7 @@ static BOOL process_attach(void) XInternAtoms( display, (char **)atom_names, NB_XATOMS - FIRST_XATOM, False, X11DRV_Atoms ); - winContext = XUniqueContext(); - win_data_context = XUniqueContext(); - cursor_context = XUniqueContext(); + init_win_context(); if (TRACE_ON(synchronous)) XSynchronize( display, True );
1
0
0
0
Jacek Caban : winex11: Use pthread for synchronization in vulkan.c.
by Alexandre Julliard
18 Apr '22
18 Apr '22
Module: wine Branch: master Commit: 83501c7eaabcff25373910b33b4e5c779b56f398 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=83501c7eaabcff25373910b3…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Apr 18 14:40:54 2022 +0200 winex11: Use pthread for synchronization in vulkan.c. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/vulkan.c | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/dlls/winex11.drv/vulkan.c b/dlls/winex11.drv/vulkan.c index 453b729aa42..f4fe202dfaf 100644 --- a/dlls/winex11.drv/vulkan.c +++ b/dlls/winex11.drv/vulkan.c @@ -44,14 +44,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(vulkan); #ifdef SONAME_LIBVULKAN WINE_DECLARE_DEBUG_CHANNEL(fps); -static CRITICAL_SECTION context_section; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &context_section, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": context_section") } -}; -static CRITICAL_SECTION context_section = { &critsect_debug, -1, 0, 0, 0, 0 }; +static pthread_mutex_t vulkan_mutex; static XContext vulkan_hwnd_context; @@ -109,12 +102,14 @@ static inline struct wine_vk_surface *surface_from_handle(VkSurfaceKHR handle) static void *vulkan_handle; -static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context) +static void wine_vk_init(void) { + init_recursive_mutex(&vulkan_mutex); + if (!(vulkan_handle = dlopen(SONAME_LIBVULKAN, RTLD_NOW))) { ERR("Failed to load %s.\n", SONAME_LIBVULKAN); - return TRUE; + return; } #define LOAD_FUNCPTR(f) if (!(p##f = dlsym(vulkan_handle, #f))) goto fail @@ -143,13 +138,11 @@ static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context) #undef LOAD_OPTIONAL_FUNCPTR vulkan_hwnd_context = XUniqueContext(); - - return TRUE; + return; fail: dlclose(vulkan_handle); vulkan_handle = NULL; - return TRUE; } /* Helper function for converting between win32 and X11 compatible VkInstanceCreateInfo. @@ -213,9 +206,9 @@ static void wine_vk_surface_release(struct wine_vk_surface *surface) if (surface->entry.next) { - EnterCriticalSection(&context_section); + pthread_mutex_lock(&vulkan_mutex); list_remove(&surface->entry); - LeaveCriticalSection(&context_section); + pthread_mutex_unlock(&vulkan_mutex); } if (surface->window) @@ -227,7 +220,7 @@ static void wine_vk_surface_release(struct wine_vk_surface *surface) void wine_vk_surface_destroy(HWND hwnd) { struct wine_vk_surface *surface; - EnterCriticalSection(&context_section); + pthread_mutex_lock(&vulkan_mutex); if (!XFindContext(gdi_display, (XID)hwnd, vulkan_hwnd_context, (char **)&surface)) { surface->hwnd_thread_id = 0; @@ -235,7 +228,7 @@ void wine_vk_surface_destroy(HWND hwnd) wine_vk_surface_release(surface); } XDeleteContext(gdi_display, (XID)hwnd, vulkan_hwnd_context); - LeaveCriticalSection(&context_section); + pthread_mutex_unlock(&vulkan_mutex); } void vulkan_thread_detach(void) @@ -243,7 +236,7 @@ void vulkan_thread_detach(void) struct wine_vk_surface *surface, *next; DWORD thread_id = GetCurrentThreadId(); - EnterCriticalSection(&context_section); + pthread_mutex_lock(&vulkan_mutex); LIST_FOR_EACH_ENTRY_SAFE(surface, next, &surface_list, struct wine_vk_surface, entry) { if (surface->hwnd_thread_id != thread_id) @@ -254,7 +247,7 @@ void vulkan_thread_detach(void) XSync(gdi_display, False); wine_vk_surface_destroy(surface->hwnd); } - LeaveCriticalSection(&context_section); + pthread_mutex_unlock(&vulkan_mutex); } static VkResult X11DRV_vkCreateInstance(const VkInstanceCreateInfo *create_info, @@ -362,14 +355,14 @@ static VkResult X11DRV_vkCreateWin32SurfaceKHR(VkInstance instance, goto err; } - EnterCriticalSection(&context_section); + pthread_mutex_lock(&vulkan_mutex); if (x11_surface->hwnd) { wine_vk_surface_destroy( x11_surface->hwnd ); XSaveContext(gdi_display, (XID)create_info->hwnd, vulkan_hwnd_context, (char *)wine_vk_surface_grab(x11_surface)); } list_add_tail(&surface_list, &x11_surface->entry); - LeaveCriticalSection(&context_section); + pthread_mutex_unlock(&vulkan_mutex); *surface = (uintptr_t)x11_surface; @@ -723,7 +716,7 @@ static void *X11DRV_get_vk_instance_proc_addr(VkInstance instance, const char *n const struct vulkan_funcs *get_vulkan_driver(UINT version) { - static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT; + static pthread_once_t init_once = PTHREAD_ONCE_INIT; if (version != WINE_VULKAN_DRIVER_VERSION) { @@ -731,7 +724,7 @@ const struct vulkan_funcs *get_vulkan_driver(UINT version) return NULL; } - InitOnceExecuteOnce(&init_once, wine_vk_init, NULL, NULL); + pthread_once(&init_once, wine_vk_init); if (vulkan_handle) return &vulkan_funcs;
1
0
0
0
Jacek Caban : winex11: Use pthread for settings locking.
by Alexandre Julliard
18 Apr '22
18 Apr '22
Module: wine Branch: master Commit: 870d0080b04ee1789f2d71767c664ee3d834c502 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=870d0080b04ee1789f2d7176…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Apr 18 14:40:49 2022 +0200 winex11: Use pthread for settings locking. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/settings.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/dlls/winex11.drv/settings.c b/dlls/winex11.drv/settings.c index 1e711354c07..dd1d2a54024 100644 --- a/dlls/winex11.drv/settings.c +++ b/dlls/winex11.drv/settings.c @@ -70,14 +70,7 @@ static DWORD cached_flags; static DEVMODEW *cached_modes; static UINT cached_mode_count; -static CRITICAL_SECTION modes_section; -static CRITICAL_SECTION_DEBUG modes_critsect_debug = -{ - 0, 0, &modes_section, - {&modes_critsect_debug.ProcessLocksList, &modes_critsect_debug.ProcessLocksList}, - 0, 0, {(DWORD_PTR)(__FILE__ ": modes_section")} -}; -static CRITICAL_SECTION modes_section = {&modes_critsect_debug, -1, 0, 0, 0, 0}; +static pthread_mutex_t settings_mutex = PTHREAD_MUTEX_INITIALIZER; void X11DRV_Settings_SetHandler(const struct x11drv_settings_handler *new_handler) { @@ -427,13 +420,13 @@ static void set_display_depth(ULONG_PTR display_id, DWORD depth) { struct x11drv_display_depth *display_depth; - EnterCriticalSection(&modes_section); + pthread_mutex_lock( &settings_mutex ); LIST_FOR_EACH_ENTRY(display_depth, &x11drv_display_depth_list, struct x11drv_display_depth, entry) { if (display_depth->display_id == display_id) { display_depth->depth = depth; - LeaveCriticalSection(&modes_section); + pthread_mutex_unlock( &settings_mutex ); return; } } @@ -442,14 +435,14 @@ static void set_display_depth(ULONG_PTR display_id, DWORD depth) if (!display_depth) { ERR("Failed to allocate memory.\n"); - LeaveCriticalSection(&modes_section); + pthread_mutex_unlock( &settings_mutex ); return; } display_depth->display_id = display_id; display_depth->depth = depth; list_add_head(&x11drv_display_depth_list, &display_depth->entry); - LeaveCriticalSection(&modes_section); + pthread_mutex_unlock( &settings_mutex ); } static DWORD get_display_depth(ULONG_PTR display_id) @@ -457,17 +450,17 @@ static DWORD get_display_depth(ULONG_PTR display_id) struct x11drv_display_depth *display_depth; DWORD depth; - EnterCriticalSection(&modes_section); + pthread_mutex_lock( &settings_mutex ); LIST_FOR_EACH_ENTRY(display_depth, &x11drv_display_depth_list, struct x11drv_display_depth, entry) { if (display_depth->display_id == display_id) { depth = display_depth->depth; - LeaveCriticalSection(&modes_section); + pthread_mutex_unlock( &settings_mutex ); return depth; } } - LeaveCriticalSection(&modes_section); + pthread_mutex_unlock( &settings_mutex ); return screen_bpp; } @@ -507,13 +500,13 @@ BOOL X11DRV_EnumDisplaySettingsEx( LPCWSTR name, DWORD n, LPDEVMODEW devmode, DW goto done; } - EnterCriticalSection(&modes_section); + pthread_mutex_lock( &settings_mutex ); if (n == 0 || lstrcmpiW(cached_device_name, name) || cached_flags != flags) { if (!handler.get_id(name, &id) || !handler.get_modes(id, flags, &modes, &mode_count)) { ERR("Failed to get %s supported display modes.\n", wine_dbgstr_w(name)); - LeaveCriticalSection(&modes_section); + pthread_mutex_unlock( &settings_mutex ); return FALSE; } @@ -529,14 +522,14 @@ BOOL X11DRV_EnumDisplaySettingsEx( LPCWSTR name, DWORD n, LPDEVMODEW devmode, DW if (n >= cached_mode_count) { - LeaveCriticalSection(&modes_section); + pthread_mutex_unlock( &settings_mutex ); WARN("handler:%s device:%s mode index:%#x not found.\n", handler.name, wine_dbgstr_w(name), n); SetLastError(ERROR_NO_MORE_FILES); return FALSE; } memcpy(devmode, (BYTE *)cached_modes + (sizeof(*cached_modes) + cached_modes[0].dmDriverExtra) * n, sizeof(*devmode)); - LeaveCriticalSection(&modes_section); + pthread_mutex_unlock( &settings_mutex ); done: /* Set generic fields */
1
0
0
0
Jacek Caban : winex11: Use pthread for palette locking.
by Alexandre Julliard
18 Apr '22
18 Apr '22
Module: wine Branch: master Commit: 6db4613be926171b747562b41f98527bdc414f91 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=6db4613be926171b747562b4…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Apr 18 14:40:45 2022 +0200 winex11: Use pthread for palette locking. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/palette.c | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/dlls/winex11.drv/palette.c b/dlls/winex11.drv/palette.c index ffed08d1f35..ae4bf38d934 100644 --- a/dlls/winex11.drv/palette.c +++ b/dlls/winex11.drv/palette.c @@ -69,14 +69,7 @@ static unsigned char X11DRV_PALETTE_freeList[256]; static XContext palette_context; /* X context to associate a color mapping to a palette */ -static CRITICAL_SECTION palette_cs; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &palette_cs, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": palette_cs") } -}; -static CRITICAL_SECTION palette_cs = { &critsect_debug, -1, 0, 0, 0, 0 }; +static pthread_mutex_t palette_mutex = PTHREAD_MUTEX_INITIALIZER; /**********************************************************************/ @@ -781,7 +774,7 @@ BOOL X11DRV_IsSolidColor( COLORREF color ) if (X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_VIRTUAL) return TRUE; /* no palette */ - EnterCriticalSection( &palette_cs ); + pthread_mutex_lock( &palette_mutex ); for (i = 0; i < palette_size ; i++, pEntry++) { if( i < COLOR_gapStart || i > COLOR_gapEnd ) @@ -789,11 +782,11 @@ BOOL X11DRV_IsSolidColor( COLORREF color ) (GetGValue(color) == pEntry->peGreen) && (GetBValue(color) == pEntry->peBlue)) { - LeaveCriticalSection( &palette_cs ); + pthread_mutex_unlock( &palette_mutex ); return TRUE; } } - LeaveCriticalSection( &palette_cs ); + pthread_mutex_unlock( &palette_mutex ); return FALSE; } @@ -836,9 +829,9 @@ COLORREF X11DRV_PALETTE_ToLogical(X11DRV_PDEVICE *physDev, int pixel) if ((default_visual.depth <= 8) && (pixel < 256) && !(X11DRV_PALETTE_PaletteFlags & (X11DRV_PALETTE_VIRTUAL | X11DRV_PALETTE_FIXED)) ) { COLORREF ret; - EnterCriticalSection( &palette_cs ); + pthread_mutex_lock( &palette_mutex ); ret = *(COLORREF *)(COLOR_sysPal + (X11DRV_PALETTE_XPixelToPalette ? X11DRV_PALETTE_XPixelToPalette[pixel]: pixel)) & 0x00ffffff; - LeaveCriticalSection( &palette_cs ); + pthread_mutex_unlock( &palette_mutex ); return ret; } @@ -1009,10 +1002,10 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color ) return (((color >> 16) & 0xff) + ((color >> 8) & 0xff) + (color & 0xff) > 255*3/2) ? 1 : 0; - EnterCriticalSection( &palette_cs ); + pthread_mutex_lock( &palette_mutex ); index = X11DRV_SysPaletteLookupPixel( color & 0xffffff, FALSE); if (X11DRV_PALETTE_PaletteToXPixel) index = X11DRV_PALETTE_PaletteToXPixel[index]; - LeaveCriticalSection( &palette_cs ); + pthread_mutex_unlock( &palette_mutex ); } } return index; @@ -1075,11 +1068,11 @@ static int X11DRV_PALETTE_LookupPixel(ColorShifts *shifts, COLORREF color ) if (!mapping) WARN("Palette %p is not realized\n", hPal); - EnterCriticalSection( &palette_cs ); + pthread_mutex_lock( &palette_mutex ); index = X11DRV_SysPaletteLookupPixel( color, FALSE); if (X11DRV_PALETTE_PaletteToXPixel) index = X11DRV_PALETTE_PaletteToXPixel[index]; - LeaveCriticalSection( &palette_cs ); + pthread_mutex_unlock( &palette_mutex ); return index; } } @@ -1221,7 +1214,7 @@ UINT CDECL X11DRV_RealizePalette( PHYSDEV dev, HPALETTE hpal, BOOL primary ) /* reset dynamic system palette entries */ - EnterCriticalSection( &palette_cs ); + pthread_mutex_lock( &palette_mutex ); if( primary && X11DRV_PALETTE_firstFree != -1) X11DRV_PALETTE_FormatSystemPalette(); @@ -1294,7 +1287,7 @@ UINT CDECL X11DRV_RealizePalette( PHYSDEV dev, HPALETTE hpal, BOOL primary ) TRACE("entry %i (%x) -> pixel %i\n", i, *(COLORREF*)&entries[i], index); } - LeaveCriticalSection( &palette_cs ); + pthread_mutex_unlock( &palette_mutex ); return iRemapped; } @@ -1331,7 +1324,7 @@ UINT CDECL X11DRV_GetSystemPaletteEntries( PHYSDEV dev, UINT start, UINT count, if (start >= palette_size) return 0; if (start + count >= palette_size) count = palette_size - start; - EnterCriticalSection( &palette_cs ); + pthread_mutex_lock( &palette_mutex ); for (i = 0; i < count; i++) { entries[i].peRed = COLOR_sysPal[start + i].peRed; @@ -1340,7 +1333,7 @@ UINT CDECL X11DRV_GetSystemPaletteEntries( PHYSDEV dev, UINT start, UINT count, entries[i].peFlags = 0; TRACE("\tidx(%02x) -> RGB(%08x)\n", start + i, *(COLORREF*)(entries + i) ); } - LeaveCriticalSection( &palette_cs ); + pthread_mutex_unlock( &palette_mutex ); return count; } @@ -1378,9 +1371,9 @@ COLORREF CDECL X11DRV_GetNearestColor( PHYSDEV dev, COLORREF color ) color = RGB( entry.peRed, entry.peGreen, entry.peBlue ); } color &= 0x00ffffff; - EnterCriticalSection( &palette_cs ); + pthread_mutex_lock( &palette_mutex ); nearest = (0x00ffffff & *(COLORREF*)(COLOR_sysPal + X11DRV_SysPaletteLookupPixel(color, FALSE))); - LeaveCriticalSection( &palette_cs ); + pthread_mutex_unlock( &palette_mutex ); TRACE("(%06x): returning %06x\n", color, nearest ); return nearest; @@ -1402,7 +1395,7 @@ UINT CDECL X11DRV_RealizeDefaultPalette( PHYSDEV dev ) PALETTEENTRY entries[NB_RESERVED_COLORS]; get_palette_entries( GetStockObject(DEFAULT_PALETTE), 0, NB_RESERVED_COLORS, entries ); - EnterCriticalSection( &palette_cs ); + pthread_mutex_lock( &palette_mutex ); for( i = 0; i < NB_RESERVED_COLORS; i++ ) { index = X11DRV_PALETTE_LookupSystemXPixel( RGB(entries[i].peRed, @@ -1415,7 +1408,7 @@ UINT CDECL X11DRV_RealizeDefaultPalette( PHYSDEV dev ) ret++; } } - LeaveCriticalSection( &palette_cs ); + pthread_mutex_unlock( &palette_mutex ); } return ret; }
1
0
0
0
← Newer
1
...
43
44
45
46
47
48
49
...
103
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
Results per page:
10
25
50
100
200