diff options
| author | Carl Hetherington <cth@carlh.net> | 2026-03-10 22:53:31 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2026-03-10 22:54:04 +0100 |
| commit | 5976445fce49fd656dc5861c4db4dcc60ec11941 (patch) | |
| tree | 3a055089c923506c61a8d21e1cf5a814743b1ab3 /src | |
| parent | 2ecd20b327ce693a1f00ad7dbab8df1c6cea1fd9 (diff) | |
Use a more generic way to request things.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/gl_video_view.cc | 16 | ||||
| -rw-r--r-- | src/wx/gl_video_view.h | 9 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc index 36b863ec1..0e115977d 100644 --- a/src/wx/gl_video_view.cc +++ b/src/wx/gl_video_view.cc @@ -74,7 +74,7 @@ GLVideoView::GLVideoView(FilmViewer* viewer, wxWindow *parent, bool wake) , _rec2020(false) , _vsync_enabled(false) , _playing(false) - , _request_set_image_and_draw(false) + , _pending_request(Request::NONE) { wxGLAttributes attributes; /* We don't need a depth buffer, and indeed there is apparently a bug with Windows/Intel HD 630 @@ -161,7 +161,7 @@ GLVideoView::update() _thread = boost::thread(boost::bind(&GLVideoView::thread, this)); } - request_set_image_and_draw(); + request(Request::SET_IMAGE_AND_DRAW); rethrow(); } @@ -942,15 +942,15 @@ try while (true) { boost::mutex::scoped_lock lm(_playing_mutex); - while (!_playing && !_request_set_image_and_draw) { + while (!_playing && _pending_request == Request::NONE) { _thread_work_condition.wait(lm); } lm.unlock(); if (_playing) { thread_playing(); - } else if (_request_set_image_and_draw) { - _request_set_image_and_draw = false; + } else if (_pending_request == Request::SET_IMAGE_AND_DRAW) { + _pending_request = Request::NONE; set_image_and_draw(); } @@ -972,16 +972,16 @@ VideoView::NextFrameResult GLVideoView::display_next_frame(bool non_blocking) { NextFrameResult const r = get_next_frame(non_blocking); - request_set_image_and_draw(); + request(Request::SET_IMAGE_AND_DRAW); return r; } void -GLVideoView::request_set_image_and_draw() +GLVideoView::request(Request request) { boost::mutex::scoped_lock lm(_playing_mutex); - _request_set_image_and_draw = true; + _pending_request = request; _thread_work_condition.notify_all(); } diff --git a/src/wx/gl_video_view.h b/src/wx/gl_video_view.h index e78d449b2..830156dd9 100644 --- a/src/wx/gl_video_view.h +++ b/src/wx/gl_video_view.h @@ -94,12 +94,17 @@ public: } private: + enum class Request { + NONE, + SET_IMAGE_AND_DRAW, + }; + void set_image(std::shared_ptr<const PlayerVideo> pv); void set_image_and_draw(); void draw(); void thread(); void thread_playing(); - void request_set_image_and_draw(); + void request(Request request); void check_for_butler_errors(); void ensure_context(); void size_changed(wxSizeEvent const &); @@ -150,7 +155,7 @@ private: boost::mutex _playing_mutex; boost::condition _thread_work_condition; boost::atomic<bool> _playing; - boost::atomic<bool> _request_set_image_and_draw; + boost::atomic<Request> _pending_request; GLuint _vao; dcpomatic::gl::Uniform1i _fragment_type; |
