[vlc-commits] win32: vout: use an atomic_bool with no lock for has_moved
Steve Lhomme
git at videolan.org
Tue Jun 7 11:24:42 CEST 2016
vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Mon Jun 6 10:19:39 2016 +0200| [1a0a9e1cc042ed1e509499601cd97fd4b4f703bf] | committer: Jean-Baptiste Kempf
win32: vout: use an atomic_bool with no lock for has_moved
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1a0a9e1cc042ed1e509499601cd97fd4b4f703bf
---
modules/video_output/win32/events.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/modules/video_output/win32/events.c b/modules/video_output/win32/events.c
index c41fd89..c8003c3 100644
--- a/modules/video_output/win32/events.c
+++ b/modules/video_output/win32/events.c
@@ -35,6 +35,7 @@
#include <vlc_common.h>
#include <vlc_vout_display.h>
+#include <vlc_atomic.h>
#include <windows.h>
#include <windowsx.h> /* GET_X_LPARAM */
@@ -93,7 +94,7 @@ struct event_thread_t
HICON vlc_icon;
- bool has_moved;
+ atomic_bool has_moved;
};
/***************************
@@ -444,12 +445,7 @@ void EventThreadUseOverlay( event_thread_t *p_event, bool b_used )
}
bool EventThreadGetAndResetHasMoved( event_thread_t *p_event )
{
- vlc_mutex_lock( &p_event->lock );
- const bool has_moved = p_event->has_moved;
- p_event->has_moved = false;
- vlc_mutex_unlock( &p_event->lock );
-
- return has_moved;
+ return atomic_exchange(&p_event->has_moved, false);
}
event_thread_t *EventThreadCreate( vout_display_t *vd)
@@ -474,6 +470,7 @@ event_thread_t *EventThreadCreate( vout_display_t *vd)
p_event->button_pressed = 0;
p_event->psz_title = NULL;
p_event->source = vd->source;
+ atomic_init(&p_event->has_moved, false);
vout_display_PlacePicture(&p_event->place, &vd->source, vd->cfg, false);
_sntprintf( p_event->class_main, sizeof(p_event->class_main)/sizeof(*p_event->class_main),
@@ -500,7 +497,7 @@ int EventThreadStart( event_thread_t *p_event, event_hwnd_t *p_hwnd, const event
p_event->width = p_cfg->width;
p_event->height = p_cfg->height;
- p_event->has_moved = false;
+ atomic_store(&p_event->has_moved, false);
p_event->b_ready = false;
p_event->b_done = false;
@@ -1002,9 +999,7 @@ static long FAR PASCAL WinVoutEventProc( HWND hwnd, UINT message,
{
case WM_WINDOWPOSCHANGED:
- vlc_mutex_lock( &p_event->lock );
- p_event->has_moved = true;
- vlc_mutex_unlock( &p_event->lock );
+ atomic_store(&p_event->has_moved, true);
return 0;
/* the user wants to close the window */
More information about the vlc-commits
mailing list